@uipath/pm-tool 1.205.0-preview.276 → 1.206.0-preview.279

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/pm-tool",
2102
2083
  author: "UiPath",
2103
2084
  license: "SEE LICENSE IN LICENSE.txt",
2104
- version: "1.205.0-preview.276",
2085
+ version: "1.206.0-preview.279",
2105
2086
  description: "Process Mining — process apps, transformations, and data ingestion.",
2106
2087
  private: false,
2107
2088
  repository: {
@@ -2128,6 +2109,7 @@ var package_default = {
2128
2109
  ],
2129
2110
  scripts: {
2130
2111
  build: "bun ../../tools/build-tool.ts",
2112
+ typecheck: "tsc --noEmit",
2131
2113
  test: "vitest run",
2132
2114
  "test:coverage": "vitest run --coverage",
2133
2115
  lint: "biome check .",
@@ -2144,7 +2126,7 @@ var package_default = {
2144
2126
  };
2145
2127
 
2146
2128
  // ../filesystem/src/node.ts
2147
- import { randomUUID } from "node:crypto";
2129
+ import { createHash, randomUUID } from "node:crypto";
2148
2130
  import { existsSync } from "node:fs";
2149
2131
  import * as fs from "node:fs/promises";
2150
2132
  import * as os from "node:os";
@@ -2155,6 +2137,9 @@ var LOCK_MAX_WAIT_MS = 20000;
2155
2137
  var LOCK_MAX_HOLD_MS = 60000;
2156
2138
  var LOCK_RETRY_MIN_MS = 100;
2157
2139
  var LOCK_RETRY_JITTER_MS = 200;
2140
+ var HASH_CHUNK_BYTES = 256 * 1024;
2141
+ var hashBuffers = [];
2142
+ var HASH_BUFFERS_KEPT = 64;
2158
2143
 
2159
2144
  class NodeFileSystem {
2160
2145
  path = {
@@ -2173,7 +2158,7 @@ class NodeFileSystem {
2173
2158
  };
2174
2159
  utils = {
2175
2160
  open: async (url) => {
2176
- const { default: open } = await import("./index-sby22td6.js");
2161
+ const { default: open } = await import("./index-nzr4mx5p.js");
2177
2162
  await open(url);
2178
2163
  }
2179
2164
  };
@@ -2212,6 +2197,15 @@ class NodeFileSystem {
2212
2197
  throw error;
2213
2198
  }
2214
2199
  }
2200
+ async readdirEntries(dirPath) {
2201
+ try {
2202
+ return await fs.readdir(dirPath, { withFileTypes: true });
2203
+ } catch (error) {
2204
+ if (this.isEnoent(error))
2205
+ return [];
2206
+ throw error;
2207
+ }
2208
+ }
2215
2209
  async stat(filePath) {
2216
2210
  try {
2217
2211
  const stats = await fs.stat(filePath);
@@ -2219,7 +2213,8 @@ class NodeFileSystem {
2219
2213
  isFile: () => stats.isFile(),
2220
2214
  isDirectory: () => stats.isDirectory(),
2221
2215
  size: stats.size,
2222
- mtimeMs: stats.mtimeMs
2216
+ mtimeMs: stats.mtimeMs,
2217
+ ctimeMs: stats.ctimeMs
2223
2218
  };
2224
2219
  } catch (error) {
2225
2220
  if (this.isEnoent(error))
@@ -2333,6 +2328,42 @@ class NodeFileSystem {
2333
2328
  throw error;
2334
2329
  }
2335
2330
  }
2331
+ async hashFile(filePath) {
2332
+ let handle;
2333
+ try {
2334
+ handle = await fs.open(filePath, "r");
2335
+ } catch (error) {
2336
+ if (this.isEnoent(error))
2337
+ return null;
2338
+ throw error;
2339
+ }
2340
+ const buffer = hashBuffers.pop() ?? Buffer.allocUnsafe(HASH_CHUNK_BYTES);
2341
+ try {
2342
+ const opened = await handle.stat();
2343
+ const stats = {
2344
+ isFile: () => opened.isFile(),
2345
+ isDirectory: () => opened.isDirectory(),
2346
+ size: opened.size,
2347
+ mtimeMs: opened.mtimeMs,
2348
+ ctimeMs: opened.ctimeMs
2349
+ };
2350
+ const hash = createHash("sha256");
2351
+ let size = 0;
2352
+ for (;; ) {
2353
+ const { bytesRead } = await handle.read(buffer, 0, buffer.byteLength, null);
2354
+ if (bytesRead === 0)
2355
+ break;
2356
+ hash.update(buffer.subarray(0, bytesRead));
2357
+ size += bytesRead;
2358
+ }
2359
+ return { sha256: hash.digest("hex"), size, stats };
2360
+ } finally {
2361
+ if (hashBuffers.length < HASH_BUFFERS_KEPT) {
2362
+ hashBuffers.push(buffer);
2363
+ }
2364
+ await handle.close();
2365
+ }
2366
+ }
2336
2367
  async realpath(filePath) {
2337
2368
  try {
2338
2369
  return await fs.realpath(filePath);
@@ -2383,6 +2414,208 @@ class NodeFileSystem {
2383
2414
  var fsInstance = new NodeFileSystem;
2384
2415
  var getFileSystem = () => fsInstance;
2385
2416
 
2417
+ // ../common/src/telemetry/telemetry-dimensions.ts
2418
+ var BaseDimensions = {
2419
+ ApplicationName: "ApplicationName",
2420
+ ProductVersion: "ProductVersion",
2421
+ InstallationId: "InstallationId",
2422
+ CloudUserId: "CloudUserId",
2423
+ CloudTenantId: "CloudTenantId",
2424
+ CloudOrganizationId: "CloudOrganizationId",
2425
+ IsInternalUser: "IsInternalUser",
2426
+ Environment: "Environment",
2427
+ BaseUrl: "BaseUrl",
2428
+ Region: "Region",
2429
+ Agent: "Agent",
2430
+ AgentVersion: "AgentVersion",
2431
+ AgentModel: "AgentModel",
2432
+ ToolName: "ToolName",
2433
+ ToolVersion: "ToolVersion",
2434
+ ExecutionContext: "ExecutionContext",
2435
+ CiProvider: "CiProvider",
2436
+ SessionIdSource: "SessionIdSource",
2437
+ SessionId: "SessionId"
2438
+ };
2439
+ var CommandDimensions = {
2440
+ IsCommand: "IsCommand",
2441
+ IsReexec: "IsReexec",
2442
+ CommandName: "CommandName",
2443
+ ExitCode: "ExitCode",
2444
+ TerminalOutcome: "TerminalOutcome",
2445
+ ErrorClass: "ErrorClass",
2446
+ TerminalSignal: "TerminalSignal",
2447
+ ErrorMessage: "ErrorMessage",
2448
+ SkillName: "SkillName",
2449
+ ProductArea: "ProductArea",
2450
+ Mode: "Mode"
2451
+ };
2452
+ var ProjectDimensions = {
2453
+ ProjectKey: "ProjectKey",
2454
+ ProjectType: "ProjectType",
2455
+ ProjectIdentityStatus: "ProjectIdentityStatus",
2456
+ SolutionKey: "SolutionKey",
2457
+ SolutionProjectKey: "SolutionProjectKey",
2458
+ SolutionIdentityStatus: "SolutionIdentityStatus",
2459
+ PreviousSolutionKey: "PreviousSolutionKey"
2460
+ };
2461
+ var GUID_KEY_DIMENSIONS = new Set([
2462
+ ProjectDimensions.ProjectKey,
2463
+ ProjectDimensions.SolutionKey,
2464
+ ProjectDimensions.SolutionProjectKey,
2465
+ ProjectDimensions.PreviousSolutionKey
2466
+ ]);
2467
+ var ShipDimensions = {
2468
+ ShipKind: "ShipKind",
2469
+ Target: "Target",
2470
+ ProjectType: "ProjectType",
2471
+ ProjectTypes: "ProjectTypes",
2472
+ ArtifactCorrelationKey: "ArtifactCorrelationKey",
2473
+ PackageName: "PackageName",
2474
+ PackageVersion: "PackageVersion",
2475
+ PackageVersionKey: "PackageVersionKey",
2476
+ DeploymentKey: "DeploymentKey",
2477
+ SolutionId: "SolutionId",
2478
+ FolderKey: "FolderKey",
2479
+ FeedId: "FeedId"
2480
+ };
2481
+ var ErrorDimensions = {
2482
+ Result: "Result",
2483
+ ErrorCode: "ErrorCode",
2484
+ Retry: "Retry",
2485
+ ErrorMessage: "ErrorMessage",
2486
+ HttpStatus: "HttpStatus",
2487
+ UpstreamErrorCode: "UpstreamErrorCode"
2488
+ };
2489
+ var AuthDimensions = {
2490
+ AuthenticationMethod: "AuthenticationMethod",
2491
+ Success: "Success",
2492
+ Reason: "Reason"
2493
+ };
2494
+ var SkillsDimensions = {
2495
+ SchemaVersion: "SchemaVersion",
2496
+ AgentType: "AgentType",
2497
+ SkillsVersion: "SkillsVersion",
2498
+ UipSubcommand: "UipSubcommand",
2499
+ FileExtension: "FileExtension",
2500
+ SubagentModel: "SubagentModel",
2501
+ SubagentType: "SubagentType",
2502
+ PermissionMode: "PermissionMode",
2503
+ EffortLevel: "EffortLevel",
2504
+ SessionSource: "SessionSource",
2505
+ Outcome: "Outcome",
2506
+ DurationMs: "DurationMs",
2507
+ Source: "Source"
2508
+ };
2509
+ var PackagerDimensions = {
2510
+ ProjectId: "ProjectId",
2511
+ ProjectType: "ProjectType",
2512
+ SolutionId: "SolutionId"
2513
+ };
2514
+ var ScopeDimensions = {
2515
+ FolderId: "FolderId"
2516
+ };
2517
+ var ID_DIMENSIONS = new Set([
2518
+ BaseDimensions.CloudUserId,
2519
+ BaseDimensions.CloudTenantId,
2520
+ BaseDimensions.CloudOrganizationId,
2521
+ BaseDimensions.InstallationId,
2522
+ ShipDimensions.ArtifactCorrelationKey,
2523
+ ShipDimensions.PackageVersionKey,
2524
+ ShipDimensions.DeploymentKey,
2525
+ ShipDimensions.SolutionId,
2526
+ ShipDimensions.FolderKey,
2527
+ ShipDimensions.FeedId,
2528
+ PackagerDimensions.ProjectId
2529
+ ]);
2530
+ var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
2531
+ var RESERVED_DIMENSION_NAMES = new Set([
2532
+ ...Object.values(BaseDimensions),
2533
+ ...Object.values(CommandDimensions),
2534
+ ...Object.values(ShipDimensions),
2535
+ ...Object.values(ProjectDimensions),
2536
+ ...Object.values(ErrorDimensions),
2537
+ ...Object.values(AuthDimensions),
2538
+ ...Object.values(SkillsDimensions),
2539
+ ...Object.values(PackagerDimensions),
2540
+ ...Object.values(ScopeDimensions)
2541
+ ]);
2542
+ var CURATED_DIMENSIONS = new Set([
2543
+ BaseDimensions.ApplicationName,
2544
+ BaseDimensions.ProductVersion,
2545
+ BaseDimensions.InstallationId,
2546
+ BaseDimensions.CloudUserId,
2547
+ BaseDimensions.CloudTenantId,
2548
+ BaseDimensions.CloudOrganizationId,
2549
+ BaseDimensions.IsInternalUser,
2550
+ BaseDimensions.Environment,
2551
+ BaseDimensions.BaseUrl,
2552
+ BaseDimensions.Region,
2553
+ BaseDimensions.Agent,
2554
+ BaseDimensions.AgentVersion,
2555
+ BaseDimensions.ToolVersion,
2556
+ BaseDimensions.ExecutionContext,
2557
+ BaseDimensions.CiProvider,
2558
+ BaseDimensions.SessionIdSource,
2559
+ BaseDimensions.SessionId,
2560
+ ...Object.values(CommandDimensions),
2561
+ ...Object.values(ShipDimensions),
2562
+ ...Object.values(ProjectDimensions)
2563
+ ]);
2564
+ function lowercaseIdDimensionValues(properties) {
2565
+ let changed = false;
2566
+ const result = {
2567
+ ...properties
2568
+ };
2569
+ for (const key of Object.keys(result)) {
2570
+ const value = result[key];
2571
+ if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
2572
+ continue;
2573
+ }
2574
+ const lowered = value.toLowerCase();
2575
+ if (lowered !== value) {
2576
+ result[key] = lowered;
2577
+ changed = true;
2578
+ }
2579
+ }
2580
+ return changed ? result : properties;
2581
+ }
2582
+
2583
+ // ../common/src/telemetry/project-identity.ts
2584
+ function projectKey(id) {
2585
+ if (typeof id !== "string")
2586
+ return;
2587
+ const key = id.trim().toLowerCase().replaceAll("-", "");
2588
+ return /^[0-9a-f]{32}$/.test(key) ? key : undefined;
2589
+ }
2590
+ function projectIdentityProperties(identity) {
2591
+ const key = identity.id ? projectKey(identity.id) : undefined;
2592
+ return {
2593
+ [ProjectDimensions.ProjectIdentityStatus]: identity.status === "resolved" && !key ? "invalid" : identity.status,
2594
+ [ProjectDimensions.ProjectType]: identity.projectType,
2595
+ ...identity.status === "resolved" && key ? {
2596
+ [ProjectDimensions.ProjectKey]: key
2597
+ } : {}
2598
+ };
2599
+ }
2600
+ var PROJECT_IDENTITY_LOOKUP_BUDGET_MS = 1000;
2601
+ async function withinProjectIdentityBudget(work, onTimeout) {
2602
+ work.catch(() => {
2603
+ return;
2604
+ });
2605
+ let timer;
2606
+ const expired = new Promise((resolve) => {
2607
+ timer = setTimeout(() => {
2608
+ onTimeout?.();
2609
+ resolve(undefined);
2610
+ }, PROJECT_IDENTITY_LOOKUP_BUDGET_MS);
2611
+ });
2612
+ try {
2613
+ return await Promise.race([work, expired]);
2614
+ } finally {
2615
+ clearTimeout(timer);
2616
+ }
2617
+ }
2618
+
2386
2619
  // ../common/src/telemetry/pseudonymize.ts
2387
2620
  var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2388
2621
  var PSEUDONYM_HEX_LENGTH = 32;
@@ -2751,8 +2984,8 @@ function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
2751
2984
  return `${redactUrl(core)}${trailing}`;
2752
2985
  });
2753
2986
  out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
2754
- out = out.replace(UNC_PATH_PATTERN, (_match, before, path2) => {
2755
- const [core, trailing] = peelTrailingPunctuation(path2);
2987
+ out = out.replace(UNC_PATH_PATTERN, (_match, before, path) => {
2988
+ const [core, trailing] = peelTrailingPunctuation(path);
2756
2989
  return `${before}unc#${pseudonymize(core)}${trailing}`;
2757
2990
  });
2758
2991
  out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
@@ -2846,6 +3079,8 @@ function redactProperty(name, value) {
2846
3079
  if (isSensitiveName(name)) {
2847
3080
  return REDACTED;
2848
3081
  }
3082
+ if (GUID_KEY_DIMENSIONS.has(name))
3083
+ return projectKey(value);
2849
3084
  if (typeof value === "boolean" || typeof value === "number") {
2850
3085
  return value;
2851
3086
  }
@@ -2920,6 +3155,63 @@ function settlePromiseLike(thenable) {
2920
3155
  return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
2921
3156
  }
2922
3157
 
3158
+ // ../common/src/error-codes.ts
3159
+ var CLI_ERROR_CODES = [
3160
+ "invalid_argument",
3161
+ "authentication_required",
3162
+ "permission_denied",
3163
+ "local_permission_denied",
3164
+ "not_found",
3165
+ "rate_limited",
3166
+ "network_error",
3167
+ "timeout",
3168
+ "server_error",
3169
+ "method_not_allowed",
3170
+ "not_supported",
3171
+ "configuration_error",
3172
+ "execution_failed",
3173
+ "unknown_error"
3174
+ ];
3175
+ var RETRY_HINTS = [
3176
+ "RetryWillNotFix",
3177
+ "RetryLater",
3178
+ "RetryAfter1Second",
3179
+ "RetryAfter10Seconds",
3180
+ "RetryAfter30Seconds",
3181
+ "RetryAfter60Seconds"
3182
+ ];
3183
+ var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
3184
+ var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
3185
+ function isCliErrorCode(value) {
3186
+ return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
3187
+ }
3188
+ function isRetryHint(value) {
3189
+ return typeof value === "string" && RETRY_HINT_VALUES.has(value);
3190
+ }
3191
+ function carriedErrorCode(error) {
3192
+ if (!error || typeof error !== "object")
3193
+ return;
3194
+ const code = error.errorCode;
3195
+ return isCliErrorCode(code) ? code : undefined;
3196
+ }
3197
+ function carriedRetry(error) {
3198
+ if (!error || typeof error !== "object")
3199
+ return;
3200
+ const retry = error.retry;
3201
+ return isRetryHint(retry) ? retry : undefined;
3202
+ }
3203
+ function defaultRetryForErrorCode(errorCode) {
3204
+ switch (errorCode) {
3205
+ case "network_error":
3206
+ case "rate_limited":
3207
+ case "server_error":
3208
+ case "timeout":
3209
+ return "RetryLater";
3210
+ default:
3211
+ return "RetryWillNotFix";
3212
+ }
3213
+ }
3214
+
2923
3215
  // ../common/src/error-graph.ts
2924
3216
  function* walkErrorGraph(error) {
2925
3217
  const queue = [error];
@@ -2964,17 +3256,58 @@ function findHttpStatusInGraph(error) {
2964
3256
  return;
2965
3257
  }
2966
3258
 
2967
- // ../common/src/local-permission-codes.ts
2968
- var LOCAL_PERMISSION_ERROR_CODES = new Set([
2969
- "EACCES",
2970
- "EPERM",
2971
- "EROFS"
2972
- ]);
2973
-
2974
- // ../common/src/error-handler.ts
2975
- var NETWORK_ERROR_CODES = new Set([
2976
- "ECONNREFUSED",
2977
- "ECONNRESET",
3259
+ // ../common/src/http-status.ts
3260
+ function classifyHttpStatus(status) {
3261
+ if (status === undefined)
3262
+ return;
3263
+ if (status === 400 || status === 409 || status === 413 || status === 422) {
3264
+ return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
3265
+ }
3266
+ if (status === 401) {
3267
+ return {
3268
+ errorCode: "authentication_required",
3269
+ retry: "RetryWillNotFix"
3270
+ };
3271
+ }
3272
+ if (status === 403) {
3273
+ return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
3274
+ }
3275
+ if (status === 404) {
3276
+ return { errorCode: "not_found", retry: "RetryWillNotFix" };
3277
+ }
3278
+ if (status === 405) {
3279
+ return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
3280
+ }
3281
+ if (status === 408) {
3282
+ return { errorCode: "timeout", retry: "RetryLater" };
3283
+ }
3284
+ if (status === 429) {
3285
+ return { errorCode: "rate_limited", retry: "RetryLater" };
3286
+ }
3287
+ if (status >= 500 && status < 600) {
3288
+ return { errorCode: "server_error", retry: "RetryLater" };
3289
+ }
3290
+ return;
3291
+ }
3292
+
3293
+ // ../common/src/local-permission-codes.ts
3294
+ var LOCAL_PERMISSION_ERROR_CODES = new Set([
3295
+ "EACCES",
3296
+ "EPERM",
3297
+ "EROFS"
3298
+ ]);
3299
+
3300
+ // ../common/src/error-handler.ts
3301
+ 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.";
3302
+ 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.";
3303
+ var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
3304
+ 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.";
3305
+ 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.";
3306
+ 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.";
3307
+ var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
3308
+ var NETWORK_ERROR_CODES = new Set([
3309
+ "ECONNREFUSED",
3310
+ "ECONNRESET",
2978
3311
  "ENOTFOUND",
2979
3312
  "EAI_AGAIN",
2980
3313
  "ETIMEDOUT",
@@ -2996,10 +3329,407 @@ var TLS_ERROR_CODES = new Set([
2996
3329
  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.";
2997
3330
  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.";
2998
3331
  var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
2999
- // ../common/src/exit-code.ts
3000
- function setExitCode(code) {
3001
- process.exitCode = code;
3332
+ function localPermissionInstructions(code, path) {
3333
+ const target = path !== undefined ? `'${path}'` : "a local file or resource";
3334
+ if (code === "EROFS") {
3335
+ 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.";
3336
+ }
3337
+ const onWindows = typeof process !== "undefined" && process.platform === "win32";
3338
+ const remedy = onWindows ? "Re-run from an elevated terminal, close any program holding " + "the file open, or grant your user access to the path." : "Grant this user (or the sandbox the command runs in) access " + "to the path, or run the command outside the sandbox.";
3339
+ return `The operating system denied access to ${target} (${code}). This is ` + "a local permission problem, not a UiPath service error — retrying " + `without a permission change will not help. ${remedy}`;
3340
+ }
3341
+ function describeConnectivityError(error) {
3342
+ for (const cur of walkErrorGraph(error)) {
3343
+ const code = typeof cur.code === "string" ? cur.code : undefined;
3344
+ const message = typeof cur.message === "string" ? cur.message : undefined;
3345
+ if (code && TLS_ERROR_CODES.has(code)) {
3346
+ return {
3347
+ code,
3348
+ kind: "tls",
3349
+ message: message ?? code,
3350
+ instructions: TLS_INSTRUCTIONS
3351
+ };
3352
+ }
3353
+ if (code && NETWORK_ERROR_CODES.has(code)) {
3354
+ return {
3355
+ code,
3356
+ kind: "network",
3357
+ message: message ?? code,
3358
+ instructions: NETWORK_INSTRUCTIONS
3359
+ };
3360
+ }
3361
+ }
3362
+ return;
3363
+ }
3364
+ function describePermissionError(error) {
3365
+ for (const cur of walkErrorGraph(error)) {
3366
+ const message = typeof cur.message === "string" ? cur.message : undefined;
3367
+ const code = matchLocalPermissionCode(cur.code, message);
3368
+ if (!code)
3369
+ continue;
3370
+ const path = localPermissionPath(cur.path, message);
3371
+ return {
3372
+ code,
3373
+ message: message ?? code,
3374
+ ...path !== undefined ? { path } : {},
3375
+ instructions: localPermissionInstructions(code, path)
3376
+ };
3377
+ }
3378
+ return;
3379
+ }
3380
+ function matchLocalPermissionCode(code, message) {
3381
+ if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
3382
+ return code;
3383
+ }
3384
+ const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
3385
+ return match ? match[1] : undefined;
3386
+ }
3387
+ function localPermissionPath(path, message) {
3388
+ if (typeof path === "string")
3389
+ return path;
3390
+ return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
3391
+ }
3392
+ function readHeader(response, name) {
3393
+ const headers = response?.headers;
3394
+ if (!headers || typeof headers !== "object")
3395
+ return;
3396
+ if (typeof headers.get === "function") {
3397
+ const value = headers.get(name);
3398
+ if (value)
3399
+ return value;
3400
+ }
3401
+ const plain = headers;
3402
+ const key = Object.keys(plain).find((k) => k.toLowerCase() === name.toLowerCase());
3403
+ const value = key === undefined ? undefined : plain[key];
3404
+ return typeof value === "string" && value !== "" ? value : undefined;
3405
+ }
3406
+ function isHtmlDocument(body) {
3407
+ return /^\s*(<!doctype html|<html\b)/i.test(body);
3408
+ }
3409
+ function retryHintForRetryAfter(seconds) {
3410
+ if (seconds <= 1) {
3411
+ return "RetryAfter1Second";
3412
+ }
3413
+ if (seconds <= 10) {
3414
+ return "RetryAfter10Seconds";
3415
+ }
3416
+ if (seconds <= 30) {
3417
+ return "RetryAfter30Seconds";
3418
+ }
3419
+ return "RetryAfter60Seconds";
3420
+ }
3421
+ function classifyError(status, error) {
3422
+ const byStatus = classifyHttpStatus(status);
3423
+ if (byStatus)
3424
+ return byStatus;
3425
+ if (status === undefined && describePermissionError(error)) {
3426
+ return {
3427
+ errorCode: "local_permission_denied",
3428
+ retry: "RetryWillNotFix"
3429
+ };
3430
+ }
3431
+ const connectivity = describeConnectivityError(error);
3432
+ if (connectivity) {
3433
+ return {
3434
+ errorCode: "network_error",
3435
+ retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
3436
+ };
3437
+ }
3438
+ return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
3439
+ }
3440
+ function withCarriedClass(inferred, error) {
3441
+ const errorCode = carriedErrorCode(error);
3442
+ const retry = carriedRetry(error);
3443
+ if (errorCode === undefined || errorCode === inferred.errorCode) {
3444
+ return {
3445
+ errorCode: inferred.errorCode,
3446
+ retry: retry ?? inferred.retry
3447
+ };
3448
+ }
3449
+ return { errorCode, retry: retry ?? defaultRetryForErrorCode(errorCode) };
3450
+ }
3451
+ function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
3452
+ if (extractedMessage) {
3453
+ return `HTTP ${status}: ${extractedMessage}`;
3454
+ }
3455
+ return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
3456
+ }
3457
+ async function extractErrorDetails(error, options) {
3458
+ const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
3459
+ const response = err.response;
3460
+ const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
3461
+ const explicitStatus = err.status ?? response?.status;
3462
+ const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
3463
+ const status = explicitStatus ?? inferredStatus;
3464
+ const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
3465
+ let rawBody;
3466
+ let extractedMessage;
3467
+ let parsedBody;
3468
+ const textFn = response?.text?.bind(response);
3469
+ if (textFn) {
3470
+ const [bodyError, body] = await catchError((async () => textFn())());
3471
+ if (!bodyError && body) {
3472
+ rawBody = body;
3473
+ const [parseError, parsed] = catchError(() => JSON.parse(body));
3474
+ if (!parseError && parsed && typeof parsed === "object") {
3475
+ parsedBody = parsed;
3476
+ if (parsedBody.errors && typeof parsedBody.errors === "object") {
3477
+ for (const field of Object.values(parsedBody.errors)) {
3478
+ if (Array.isArray(field) && field.length > 0) {
3479
+ const first = field[0];
3480
+ if (first && typeof first.message === "string") {
3481
+ extractedMessage = first.message;
3482
+ break;
3483
+ }
3484
+ }
3485
+ }
3486
+ }
3487
+ if (!extractedMessage) {
3488
+ extractedMessage = typeof parsedBody.message === "string" ? parsedBody.message : typeof parsedBody.errorMessage === "string" ? parsedBody.errorMessage : typeof parsedBody.title === "string" ? parsedBody.title : undefined;
3489
+ }
3490
+ if (!extractedMessage) {
3491
+ extractedMessage = body;
3492
+ }
3493
+ if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
3494
+ extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
3495
+ }
3496
+ } else {
3497
+ extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
3498
+ }
3499
+ }
3500
+ }
3501
+ let message;
3502
+ let result = "Failure";
3503
+ const classificationStatus = status ?? findHttpStatusInGraph(error);
3504
+ const classification = classifyError(classificationStatus, error);
3505
+ let retry = classification.retry;
3506
+ const htmlForbidden = status === 403 && rawBody !== undefined && isHtmlDocument(rawBody);
3507
+ const rayId = htmlForbidden ? readHeader(response, "cf-ray") : undefined;
3508
+ const cloudflareBlock = htmlForbidden && (rayId !== undefined || /\bcloudflare\b/i.test(readHeader(response, "server") ?? ""));
3509
+ if (status === 401) {
3510
+ message = DEFAULT_401;
3511
+ result = "AuthenticationError";
3512
+ } else if (cloudflareBlock) {
3513
+ message = rayId ? `${CLOUDFLARE_BLOCK_403} Cloudflare Ray ID: ${rayId}.` : CLOUDFLARE_BLOCK_403;
3514
+ } else if (status === 403) {
3515
+ message = options?.forbiddenMessage ?? DEFAULT_403;
3516
+ result = "AuthenticationError";
3517
+ } else if (status === 405) {
3518
+ message = DEFAULT_405;
3519
+ } else if (status === 413) {
3520
+ message = DEFAULT_413;
3521
+ } else if (status === 400 || status === 422) {
3522
+ message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
3523
+ result = "ValidationError";
3524
+ } else if (status === 429) {
3525
+ message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
3526
+ } else if (extractedMessage) {
3527
+ if (isSuccessfulResponse && rawMessage !== "Unknown error") {
3528
+ message = rawMessage;
3529
+ } else {
3530
+ message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
3531
+ }
3532
+ } else if (status) {
3533
+ if (inferredStatus !== undefined) {
3534
+ message = rawMessage;
3535
+ } else if (rawMessage === "Unknown error" && response) {
3536
+ const statusText = response.statusText;
3537
+ message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
3538
+ } else {
3539
+ message = `HTTP ${status}: ${rawMessage}`;
3540
+ }
3541
+ } else {
3542
+ message = rawMessage;
3543
+ }
3544
+ if (status === undefined) {
3545
+ const connectivity = describeConnectivityError(error);
3546
+ if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
3547
+ message = `${message}: ${connectivity.message}`;
3548
+ }
3549
+ }
3550
+ const permission = status === undefined ? describePermissionError(error) : undefined;
3551
+ if (permission) {
3552
+ if (permission.message !== message && !message.includes(permission.message)) {
3553
+ message = `${message}: ${permission.message}`;
3554
+ }
3555
+ if (!message.includes(permission.instructions)) {
3556
+ const punctuated = message.endsWith(".") ? message : `${message}.`;
3557
+ message = `${punctuated} ${permission.instructions}`;
3558
+ }
3559
+ }
3560
+ let details = rawMessage;
3561
+ if (htmlForbidden) {
3562
+ details = cloudflareBlock ? CLOUDFLARE_BLOCK_403_INSTRUCTIONS : HTML_RESPONSE_MESSAGE;
3563
+ } else if (rawBody) {
3564
+ if (parsedBody) {
3565
+ const extra = {};
3566
+ if (parsedBody.errorCode)
3567
+ extra.errorCode = parsedBody.errorCode;
3568
+ if (parsedBody.detail)
3569
+ extra.detail = parsedBody.detail;
3570
+ if (parsedBody.details)
3571
+ extra.details = parsedBody.details;
3572
+ if (parsedBody.errors != null)
3573
+ extra.errors = parsedBody.errors;
3574
+ if (parsedBody.data && typeof parsedBody.data === "object" && Object.keys(parsedBody.data).length > 0) {
3575
+ extra.data = parsedBody.data;
3576
+ }
3577
+ details = Object.keys(extra).length > 0 ? JSON.stringify(extra) : rawBody;
3578
+ } else {
3579
+ details = rawBody;
3580
+ }
3581
+ } else if (typeof err.message === "string") {
3582
+ details = err.message;
3583
+ } else {
3584
+ details = describeThrownValue(error);
3585
+ }
3586
+ const context = {};
3587
+ if (classificationStatus) {
3588
+ context.httpStatus = classificationStatus;
3589
+ }
3590
+ if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
3591
+ context.errorCode = parsedBody.errorCode;
3592
+ } else if (parsedBody?.code && typeof parsedBody.code === "string") {
3593
+ context.errorCode = parsedBody.code;
3594
+ }
3595
+ if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
3596
+ context.requestId = parsedBody.requestId;
3597
+ } else if (cloudflareBlock && rayId) {
3598
+ context.requestId = rayId;
3599
+ }
3600
+ if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
3601
+ context.traceId = parsedBody.traceId;
3602
+ }
3603
+ if (permission?.path !== undefined) {
3604
+ context.path = permission.path;
3605
+ }
3606
+ if (status === 429) {
3607
+ const retryAfterValue = readHeader(response, "retry-after");
3608
+ if (retryAfterValue) {
3609
+ const seconds = Number(retryAfterValue);
3610
+ if (!Number.isNaN(seconds)) {
3611
+ context.retryAfter = seconds;
3612
+ retry = retryHintForRetryAfter(seconds);
3613
+ }
3614
+ }
3615
+ }
3616
+ const hasContext = Object.keys(context).length > 0;
3617
+ let parsedErrors;
3618
+ if (parsedBody?.errors && typeof parsedBody.errors === "object") {
3619
+ const errors = {};
3620
+ for (const [field, raw] of Object.entries(parsedBody.errors)) {
3621
+ if (Array.isArray(raw)) {
3622
+ const messages = raw.map((entry) => {
3623
+ if (typeof entry === "string")
3624
+ return entry;
3625
+ if (entry && typeof entry === "object" && typeof entry.message === "string") {
3626
+ return entry.message;
3627
+ }
3628
+ return String(entry);
3629
+ }).filter(Boolean);
3630
+ if (messages.length > 0)
3631
+ errors[field] = messages;
3632
+ } else if (typeof raw === "string") {
3633
+ errors[field] = [raw];
3634
+ }
3635
+ }
3636
+ if (Object.keys(errors).length > 0)
3637
+ parsedErrors = errors;
3638
+ }
3639
+ return {
3640
+ result,
3641
+ ...withCarriedClass({ errorCode: classification.errorCode, retry }, error),
3642
+ message,
3643
+ details,
3644
+ ...hasContext ? { context } : {},
3645
+ ...parsedErrors ? { parsedErrors } : {}
3646
+ };
3002
3647
  }
3648
+ // ../common/src/result-types.ts
3649
+ var RESULTS = {
3650
+ Success: "Success",
3651
+ Failure: "Failure",
3652
+ ConfigError: "ConfigError",
3653
+ AuthenticationError: "AuthenticationError",
3654
+ ValidationError: "ValidationError",
3655
+ TimeoutError: "TimeoutError"
3656
+ };
3657
+ // ../../node_modules/commander/index.js
3658
+ var exports_commander = {};
3659
+ __exportCjs(exports_commander, {
3660
+ program: () => $program,
3661
+ createCommand: () => $createCommand,
3662
+ createOption: () => $createOption,
3663
+ createArgument: () => $createArgument,
3664
+ Command: () => $Command,
3665
+ Option: () => $Option,
3666
+ Argument: () => $Argument,
3667
+ Help: () => $Help,
3668
+ CommanderError: () => $CommanderError,
3669
+ InvalidArgumentError: () => $InvalidArgumentError,
3670
+ InvalidOptionArgumentError: () => $InvalidOptionArgumentError
3671
+ }, {
3672
+ program: (value) => $program = value,
3673
+ createCommand: (value) => $createCommand = value,
3674
+ createOption: (value) => $createOption = value,
3675
+ createArgument: (value) => $createArgument = value,
3676
+ Command: (value) => $Command = value,
3677
+ Option: (value) => $Option = value,
3678
+ Argument: (value) => $Argument = value,
3679
+ Help: (value) => $Help = value,
3680
+ CommanderError: (value) => $CommanderError = value,
3681
+ InvalidArgumentError: (value) => $InvalidArgumentError = value,
3682
+ InvalidOptionArgumentError: (value) => $InvalidOptionArgumentError = value
3683
+ });
3684
+ var { Argument } = require_argument();
3685
+ var { Command: Command2 } = require_command();
3686
+ var { CommanderError, InvalidArgumentError } = require_error();
3687
+ var { Help } = require_help();
3688
+ var { Option } = require_option();
3689
+ var $program = new Command2;
3690
+ var $createCommand = (name) => new Command2(name);
3691
+ var $createOption = (flags, description) => new Option(flags, description);
3692
+ var $createArgument = (name, description) => new Argument(name, description);
3693
+ var $Command = Command2;
3694
+ var $Option = Option;
3695
+ var $Argument = Argument;
3696
+ var $Help = Help;
3697
+ var $CommanderError = CommanderError;
3698
+ var $InvalidArgumentError = InvalidArgumentError;
3699
+ var $InvalidOptionArgumentError = InvalidArgumentError;
3700
+
3701
+ // ../../node_modules/commander/esm.mjs
3702
+ var {
3703
+ program,
3704
+ createCommand,
3705
+ createArgument,
3706
+ createOption,
3707
+ CommanderError: CommanderError2,
3708
+ InvalidArgumentError: InvalidArgumentError2,
3709
+ InvalidOptionArgumentError,
3710
+ Command,
3711
+ Argument: Argument2,
3712
+ Option: Option2,
3713
+ Help: Help2
3714
+ } = exports_commander;
3715
+
3716
+ // ../common/src/command-examples.ts
3717
+ var examplesByCommand = new WeakMap;
3718
+ Command.prototype.examples = function(examples) {
3719
+ examplesByCommand.set(this, examples);
3720
+ return this;
3721
+ };
3722
+ // ../common/src/preview.ts
3723
+ var previewSlot = singleton("PreviewBuild");
3724
+ function isPreviewBuild() {
3725
+ return previewSlot.get(false) ?? false;
3726
+ }
3727
+ Command.prototype.previewCommand = function(nameAndArgs, opts) {
3728
+ if (isPreviewBuild()) {
3729
+ return this.command(nameAndArgs, opts);
3730
+ }
3731
+ return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
3732
+ };
3003
3733
 
3004
3734
  // ../common/src/output-context.ts
3005
3735
  function createStorage() {
@@ -3034,8 +3764,8 @@ function getOutputSink() {
3034
3764
 
3035
3765
  // ../common/src/logger.ts
3036
3766
  var logFilePathSlot = singleton("logFilePath");
3037
- function setGlobalLogFilePath(path2) {
3038
- logFilePathSlot.set(path2);
3767
+ function setGlobalLogFilePath(path) {
3768
+ logFilePathSlot.set(path);
3039
3769
  }
3040
3770
  function getGlobalLogFilePath() {
3041
3771
  return logFilePathSlot.get("");
@@ -3103,14 +3833,14 @@ class SimpleLogger {
3103
3833
  return this.fileLoggingEnabled || !!getGlobalLogFilePath();
3104
3834
  }
3105
3835
  writeToFile(formatted) {
3106
- const path2 = this.logFilePath || getGlobalLogFilePath();
3107
- if (!path2)
3836
+ const path = this.logFilePath || getGlobalLogFilePath();
3837
+ if (!path)
3108
3838
  return;
3109
3839
  const timestamp = new Date().toISOString();
3110
3840
  this.pendingWrites = Promise.all([
3111
3841
  this.pendingWrites,
3112
3842
  this.pendingInit
3113
- ]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
3843
+ ]).then(() => getFileSystem().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
3114
3844
  }
3115
3845
  write(formatted) {
3116
3846
  if (this.isFileLoggingActive()) {
@@ -3160,17 +3890,17 @@ class SimpleLogger {
3160
3890
  setGlobalLogFilePath("");
3161
3891
  }
3162
3892
  }
3163
- setLogFile(path2) {
3164
- this.logFilePath = path2;
3165
- setGlobalLogFilePath(path2);
3166
- if (!path2)
3893
+ setLogFile(path) {
3894
+ this.logFilePath = path;
3895
+ setGlobalLogFilePath(path);
3896
+ if (!path)
3167
3897
  return;
3168
3898
  this.fileLoggingEnabled = true;
3169
- const fs2 = getFileSystem();
3899
+ const fs = getFileSystem();
3170
3900
  this.pendingInit = (async () => {
3171
3901
  const [error] = await catchError((async () => {
3172
- await fs2.mkdir(fs2.path.dirname(path2));
3173
- await fs2.writeFile(path2, "");
3902
+ await fs.mkdir(fs.path.dirname(path));
3903
+ await fs.writeFile(path, "");
3174
3904
  })());
3175
3905
  if (error)
3176
3906
  this.fileLoggingEnabled = false;
@@ -3218,18 +3948,111 @@ function getLogFilePath() {
3218
3948
  return logger.getLogFilePath();
3219
3949
  }
3220
3950
 
3951
+ // ../common/src/timings.ts
3952
+ var TIMINGS_ENV_VAR = "UIP_TIMINGS";
3953
+ function createStorage2() {
3954
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
3955
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
3956
+ return {
3957
+ getStore: () => {
3958
+ return;
3959
+ },
3960
+ run: (_store, fn) => fn()
3961
+ };
3962
+ }
3963
+ return new mod.AsyncLocalStorage;
3964
+ }
3965
+ var storageSlot = singleton("TimingStorage");
3966
+ var stateSlot = singleton("Timings");
3967
+ var rootStartedSlot = singleton("TimingsRootStarted");
3968
+ var longLivedHostSlot = singleton("TimingsLongLivedHost");
3969
+ var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
3970
+ function newState(baseline) {
3971
+ return { baseline, httpMs: 0, httpCalls: 0 };
3972
+ }
3973
+ function getState() {
3974
+ const scoped = storage.getStore();
3975
+ if (scoped) {
3976
+ return scoped;
3977
+ }
3978
+ const pinned = livePinnedState();
3979
+ if (pinned !== undefined) {
3980
+ return pinned;
3981
+ }
3982
+ return newState(processStartIsInvocationStart() ? 0 : performance.now());
3983
+ }
3984
+ function livePinnedState() {
3985
+ const pinned = stateSlot.get();
3986
+ return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
3987
+ }
3988
+ function processStartIsInvocationStart() {
3989
+ return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
3990
+ }
3991
+ function timingsEnabled() {
3992
+ if (typeof process === "undefined") {
3993
+ return false;
3994
+ }
3995
+ const value = process.env?.[TIMINGS_ENV_VAR];
3996
+ if (value === undefined) {
3997
+ return false;
3998
+ }
3999
+ const normalized = value.trim().toLowerCase();
4000
+ return normalized === "1" || normalized === "true";
4001
+ }
4002
+ function recordExitCode(exitCode) {
4003
+ if (!timingsEnabled()) {
4004
+ return;
4005
+ }
4006
+ getState().exitCode = exitCode;
4007
+ }
4008
+ function invocationStartedAt() {
4009
+ return new Date(performance.timeOrigin + getState().baseline);
4010
+ }
4011
+ function invocationElapsedMs() {
4012
+ return performance.now() - getState().baseline;
4013
+ }
4014
+ function markCommandStart() {
4015
+ if (!timingsEnabled()) {
4016
+ return;
4017
+ }
4018
+ getState().commandStart = performance.now();
4019
+ }
4020
+ function recordCommandDuration(durationMs) {
4021
+ if (!timingsEnabled()) {
4022
+ return;
4023
+ }
4024
+ getState().commandMs = durationMs;
4025
+ }
4026
+
4027
+ // ../common/src/exit-code.ts
4028
+ function setExitCode(code) {
4029
+ process.exitCode = code;
4030
+ recordExitCode(code);
4031
+ }
4032
+ var GENERIC_FAILURE_EXIT_CODE = 1;
4033
+ function recordCommandExit(code) {
4034
+ if (code === GENERIC_FAILURE_EXIT_CODE && getExitCode() !== 0) {
4035
+ return;
4036
+ }
4037
+ setExitCode(code);
4038
+ }
4039
+ function getExitCode() {
4040
+ const code = process.exitCode;
4041
+ return typeof code === "number" ? code : 0;
4042
+ }
4043
+
3221
4044
  // ../common/src/output-codecs.ts
3222
4045
  var yamlSlot = singleton("YamlCodec");
3223
4046
  var jmespathSlot = singleton("JmespathCodec");
3224
4047
  async function loadOutputCodecsAsync(needed) {
3225
4048
  const loads = [];
3226
4049
  if (needed.yaml && yamlSlot.get() === undefined) {
3227
- loads.push(import("./js-yaml-88tdqrtd.js").then((mod) => {
4050
+ loads.push(import("./js-yaml-a2bk27p6.js").then((mod) => {
3228
4051
  yamlSlot.set(mod);
3229
4052
  }));
3230
4053
  }
3231
4054
  if (needed.filter && jmespathSlot.get() === undefined) {
3232
- loads.push(import("./jmespath-231m3hyn.js").then((m)=>__toESM(m.default,1)).then((mod) => {
4055
+ loads.push(import("./jmespath-ab6tdc42.js").then((m)=>__toESM(m.default,1)).then((mod) => {
3233
4056
  jmespathSlot.set(mod);
3234
4057
  }));
3235
4058
  }
@@ -3254,155 +4077,6 @@ function getOutputFilter() {
3254
4077
  return filterSlot.get();
3255
4078
  }
3256
4079
 
3257
- // ../common/src/telemetry/telemetry-dimensions.ts
3258
- var BaseDimensions = {
3259
- ApplicationName: "ApplicationName",
3260
- ProductVersion: "ProductVersion",
3261
- InstallationId: "InstallationId",
3262
- CloudUserId: "CloudUserId",
3263
- CloudTenantId: "CloudTenantId",
3264
- CloudOrganizationId: "CloudOrganizationId",
3265
- IsInternalUser: "IsInternalUser",
3266
- Environment: "Environment",
3267
- BaseUrl: "BaseUrl",
3268
- Region: "Region",
3269
- Agent: "Agent",
3270
- AgentVersion: "AgentVersion",
3271
- AgentModel: "AgentModel",
3272
- ToolName: "ToolName",
3273
- ToolVersion: "ToolVersion",
3274
- ExecutionContext: "ExecutionContext",
3275
- CiProvider: "CiProvider",
3276
- SessionIdSource: "SessionIdSource",
3277
- SessionId: "SessionId"
3278
- };
3279
- var CommandDimensions = {
3280
- IsCommand: "IsCommand",
3281
- IsReexec: "IsReexec",
3282
- CommandName: "CommandName",
3283
- ExitCode: "ExitCode",
3284
- TerminalOutcome: "TerminalOutcome",
3285
- ErrorClass: "ErrorClass",
3286
- TerminalSignal: "TerminalSignal",
3287
- ErrorMessage: "ErrorMessage",
3288
- SkillName: "SkillName",
3289
- ProductArea: "ProductArea",
3290
- Mode: "Mode"
3291
- };
3292
- var ShipDimensions = {
3293
- ShipKind: "ShipKind",
3294
- Target: "Target",
3295
- ProjectType: "ProjectType",
3296
- ProjectTypes: "ProjectTypes",
3297
- ArtifactCorrelationKey: "ArtifactCorrelationKey",
3298
- PackageName: "PackageName",
3299
- PackageVersion: "PackageVersion",
3300
- PackageVersionKey: "PackageVersionKey",
3301
- DeploymentKey: "DeploymentKey",
3302
- SolutionId: "SolutionId",
3303
- FolderKey: "FolderKey",
3304
- FeedId: "FeedId"
3305
- };
3306
- var ErrorDimensions = {
3307
- Result: "Result",
3308
- ErrorCode: "ErrorCode",
3309
- Retry: "Retry",
3310
- ErrorMessage: "ErrorMessage",
3311
- HttpStatus: "HttpStatus",
3312
- UpstreamErrorCode: "UpstreamErrorCode"
3313
- };
3314
- var AuthDimensions = {
3315
- AuthenticationMethod: "AuthenticationMethod",
3316
- Success: "Success",
3317
- Reason: "Reason"
3318
- };
3319
- var SkillsDimensions = {
3320
- SchemaVersion: "SchemaVersion",
3321
- AgentType: "AgentType",
3322
- SkillsVersion: "SkillsVersion",
3323
- UipSubcommand: "UipSubcommand",
3324
- FileExtension: "FileExtension",
3325
- SubagentModel: "SubagentModel",
3326
- SubagentType: "SubagentType",
3327
- PermissionMode: "PermissionMode",
3328
- EffortLevel: "EffortLevel",
3329
- SessionSource: "SessionSource",
3330
- Outcome: "Outcome",
3331
- DurationMs: "DurationMs",
3332
- Source: "Source"
3333
- };
3334
- var PackagerDimensions = {
3335
- ProjectId: "ProjectId",
3336
- ProjectType: "ProjectType",
3337
- SolutionId: "SolutionId"
3338
- };
3339
- var ScopeDimensions = {
3340
- FolderId: "FolderId"
3341
- };
3342
- var ID_DIMENSIONS = new Set([
3343
- BaseDimensions.CloudUserId,
3344
- BaseDimensions.CloudTenantId,
3345
- BaseDimensions.CloudOrganizationId,
3346
- BaseDimensions.InstallationId,
3347
- ShipDimensions.ArtifactCorrelationKey,
3348
- ShipDimensions.PackageVersionKey,
3349
- ShipDimensions.DeploymentKey,
3350
- ShipDimensions.SolutionId,
3351
- ShipDimensions.FolderKey,
3352
- ShipDimensions.FeedId,
3353
- PackagerDimensions.ProjectId
3354
- ]);
3355
- var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
3356
- var RESERVED_DIMENSION_NAMES = new Set([
3357
- ...Object.values(BaseDimensions),
3358
- ...Object.values(CommandDimensions),
3359
- ...Object.values(ShipDimensions),
3360
- ...Object.values(ErrorDimensions),
3361
- ...Object.values(AuthDimensions),
3362
- ...Object.values(SkillsDimensions),
3363
- ...Object.values(PackagerDimensions),
3364
- ...Object.values(ScopeDimensions)
3365
- ]);
3366
- var CURATED_DIMENSIONS = new Set([
3367
- BaseDimensions.ApplicationName,
3368
- BaseDimensions.ProductVersion,
3369
- BaseDimensions.InstallationId,
3370
- BaseDimensions.CloudUserId,
3371
- BaseDimensions.CloudTenantId,
3372
- BaseDimensions.CloudOrganizationId,
3373
- BaseDimensions.IsInternalUser,
3374
- BaseDimensions.Environment,
3375
- BaseDimensions.BaseUrl,
3376
- BaseDimensions.Region,
3377
- BaseDimensions.Agent,
3378
- BaseDimensions.AgentVersion,
3379
- BaseDimensions.ToolVersion,
3380
- BaseDimensions.ExecutionContext,
3381
- BaseDimensions.CiProvider,
3382
- BaseDimensions.SessionIdSource,
3383
- BaseDimensions.SessionId,
3384
- ...Object.values(CommandDimensions),
3385
- ...Object.values(ShipDimensions)
3386
- ]);
3387
- function lowercaseIdDimensionValues(properties) {
3388
- let changed = false;
3389
- const result = {
3390
- ...properties
3391
- };
3392
- for (const key of Object.keys(result)) {
3393
- const value = result[key];
3394
- if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
3395
- continue;
3396
- }
3397
- const lowered = value.toLowerCase();
3398
- if (lowered !== value) {
3399
- result[key] = lowered;
3400
- changed = true;
3401
- }
3402
- }
3403
- return changed ? result : properties;
3404
- }
3405
-
3406
4080
  // ../common/src/telemetry/command-terminal.ts
3407
4081
  var recordedFailureSlot = singleton("CommandTelemetryFailure");
3408
4082
  var AUTH_ERROR_CODES = new Set([
@@ -3521,17 +4195,8 @@ function terminalSignalFor(input, outcome) {
3521
4195
  }
3522
4196
  return outcome === "cancelled" ? "SIGINT" : undefined;
3523
4197
  }
3524
- function classifyHttpStatus(status) {
3525
- if (status === 401 || status === 403) {
3526
- return "auth";
3527
- }
3528
- if (status === 400 || status === 409 || status === 422) {
3529
- return "validation";
3530
- }
3531
- if (status === 408) {
3532
- return "timeout";
3533
- }
3534
- return "network_http";
4198
+ function classifyFailingHttpStatus(status) {
4199
+ return classifyFromErrorCode(classifyHttpStatus(status)?.errorCode) ?? "network_http";
3535
4200
  }
3536
4201
  function classifyFromResult(result) {
3537
4202
  switch (result) {
@@ -3604,14 +4269,14 @@ function classifyFromError(error) {
3604
4269
  }
3605
4270
  return;
3606
4271
  }
3607
- function classifyError(input) {
4272
+ function classifyError2(input) {
3608
4273
  const recorded = input.recordedFailure;
3609
4274
  if (recorded?.errorClass) {
3610
4275
  return recorded.errorClass;
3611
4276
  }
3612
4277
  const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
3613
4278
  if (status !== undefined) {
3614
- return classifyHttpStatus(status);
4279
+ return classifyFailingHttpStatus(status);
3615
4280
  }
3616
4281
  return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
3617
4282
  }
@@ -3629,7 +4294,7 @@ function takeRecordedCommandFailureTelemetry() {
3629
4294
  function buildCommandTerminalTelemetryProperties(input) {
3630
4295
  const cancelled = isCancellationError(input.error, input.exitCode, input.pollSignal);
3631
4296
  const outcome = input.recordedFailure?.terminalOutcome ?? (input.exitCode === 0 ? "success" : cancelled ? "cancelled" : "failure");
3632
- const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError(input);
4297
+ const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError2(input);
3633
4298
  const terminalSignal = terminalSignalFor(input, outcome);
3634
4299
  return {
3635
4300
  [CommandDimensions.ExitCode]: input.exitCode,
@@ -3643,6 +4308,7 @@ function buildCommandTerminalTelemetryProperties(input) {
3643
4308
  var CommonTelemetryEvents = {
3644
4309
  Start: "Application.Start",
3645
4310
  Error: "Application.Error",
4311
+ ProjectActivity: "Cli.ProjectActivity",
3646
4312
  ShipSucceeded: "Cli.ShipSucceeded"
3647
4313
  };
3648
4314
 
@@ -4113,127 +4779,52 @@ class TelemetryService {
4113
4779
  throw error;
4114
4780
  }
4115
4781
  }
4116
- getActiveContext() {
4117
- return this.contextStorage.getContext();
4118
- }
4119
- leafCorrelation(explicit) {
4120
- const context = explicit ?? this.getActiveContext();
4121
- return {
4122
- operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
4123
- ...context !== undefined ? { parentId: context.id } : {}
4124
- };
4125
- }
4126
- spanFor(name, durationMs, success, properties, context) {
4127
- return {
4128
- name: redactSpanName(name),
4129
- durationMs,
4130
- success,
4131
- properties: this.enrichProperties(properties),
4132
- operationId: context.operationId,
4133
- ...context.parentId !== undefined ? { parentId: context.parentId } : {},
4134
- id: context.id,
4135
- ...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
4136
- };
4137
- }
4138
- enrichProperties(properties) {
4139
- const globalProperties = getGlobalTelemetryProperties();
4140
- const enriched = {
4141
- ...getExecutionContextTelemetryProperties(),
4142
- ...globalProperties,
4143
- ...this.defaultProperties,
4144
- ...redactProperties(properties ?? {}),
4145
- [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
4146
- [BaseDimensions.SessionId]: this.telemetryProvider.getSessionId?.() ?? getTelemetrySessionId()
4147
- };
4148
- return lowercaseIdDimensionValues(enriched);
4149
- }
4150
- generateId() {
4151
- const bytes = new Uint8Array(8);
4152
- let hex = "";
4153
- do {
4154
- crypto.getRandomValues(bytes);
4155
- hex = "";
4156
- for (const byte of bytes) {
4157
- hex += byte.toString(16).padStart(2, "0");
4158
- }
4159
- } while (/^0+$/.test(hex));
4160
- return hex;
4161
- }
4162
- }
4163
- // ../common/src/timings.ts
4164
- var TIMINGS_ENV_VAR = "UIP_TIMINGS";
4165
- function createStorage2() {
4166
- const [error, mod] = catchError(() => __require("node:async_hooks"));
4167
- if (error || typeof mod?.AsyncLocalStorage !== "function") {
4168
- return {
4169
- getStore: () => {
4170
- return;
4171
- },
4172
- run: (_store, fn) => fn()
4173
- };
4174
- }
4175
- return new mod.AsyncLocalStorage;
4176
- }
4177
- var storageSlot = singleton("TimingStorage");
4178
- var stateSlot = singleton("Timings");
4179
- var rootStartedSlot = singleton("TimingsRootStarted");
4180
- var longLivedHostSlot = singleton("TimingsLongLivedHost");
4181
- var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
4182
- function newState(baseline) {
4183
- return { baseline, httpMs: 0, httpCalls: 0 };
4184
- }
4185
- function getState() {
4186
- const scoped = storage.getStore();
4187
- if (scoped) {
4188
- return scoped;
4189
- }
4190
- const pinned = livePinnedState();
4191
- if (pinned !== undefined) {
4192
- return pinned;
4193
- }
4194
- return newState(processStartIsInvocationStart() ? 0 : performance.now());
4195
- }
4196
- function livePinnedState() {
4197
- const pinned = stateSlot.get();
4198
- return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
4199
- }
4200
- function processStartIsInvocationStart() {
4201
- return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
4202
- }
4203
- function timingsEnabled() {
4204
- if (typeof process === "undefined") {
4205
- return false;
4782
+ getActiveContext() {
4783
+ return this.contextStorage.getContext();
4206
4784
  }
4207
- const value = process.env?.[TIMINGS_ENV_VAR];
4208
- if (value === undefined) {
4209
- return false;
4785
+ leafCorrelation(explicit) {
4786
+ const context = explicit ?? this.getActiveContext();
4787
+ return {
4788
+ operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
4789
+ ...context !== undefined ? { parentId: context.id } : {}
4790
+ };
4210
4791
  }
4211
- const normalized = value.trim().toLowerCase();
4212
- return normalized === "1" || normalized === "true";
4213
- }
4214
- function recordExitCode(exitCode) {
4215
- if (!timingsEnabled()) {
4216
- return;
4792
+ spanFor(name, durationMs, success, properties, context) {
4793
+ return {
4794
+ name: redactSpanName(name),
4795
+ durationMs,
4796
+ success,
4797
+ properties: this.enrichProperties(properties),
4798
+ operationId: context.operationId,
4799
+ ...context.parentId !== undefined ? { parentId: context.parentId } : {},
4800
+ id: context.id,
4801
+ ...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
4802
+ };
4217
4803
  }
4218
- getState().exitCode = exitCode;
4219
- }
4220
- function invocationStartedAt() {
4221
- return new Date(performance.timeOrigin + getState().baseline);
4222
- }
4223
- function invocationElapsedMs() {
4224
- return performance.now() - getState().baseline;
4225
- }
4226
- function markCommandStart() {
4227
- if (!timingsEnabled()) {
4228
- return;
4804
+ enrichProperties(properties) {
4805
+ const globalProperties = getGlobalTelemetryProperties();
4806
+ const enriched = {
4807
+ ...getExecutionContextTelemetryProperties(),
4808
+ ...globalProperties,
4809
+ ...this.defaultProperties,
4810
+ ...redactProperties(properties ?? {}),
4811
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
4812
+ [BaseDimensions.SessionId]: this.telemetryProvider.getSessionId?.() ?? getTelemetrySessionId()
4813
+ };
4814
+ return lowercaseIdDimensionValues(enriched);
4229
4815
  }
4230
- getState().commandStart = performance.now();
4231
- }
4232
- function recordCommandDuration(durationMs) {
4233
- if (!timingsEnabled()) {
4234
- return;
4816
+ generateId() {
4817
+ const bytes = new Uint8Array(8);
4818
+ let hex = "";
4819
+ do {
4820
+ crypto.getRandomValues(bytes);
4821
+ hex = "";
4822
+ for (const byte of bytes) {
4823
+ hex += byte.toString(16).padStart(2, "0");
4824
+ }
4825
+ } while (/^0+$/.test(hex));
4826
+ return hex;
4235
4827
  }
4236
- getState().commandMs = durationMs;
4237
4828
  }
4238
4829
  // ../common/src/telemetry/proxy-http-agent.ts
4239
4830
  var slot = singleton("ProxyAuthHttpsAgent");
@@ -4241,6 +4832,15 @@ var slot = singleton("ProxyAuthHttpsAgent");
4241
4832
  // ../common/src/telemetry/node-appinsights-telemetry-provider.ts
4242
4833
  var providerSlot = singleton("TelemetryProvider");
4243
4834
 
4835
+ // ../common/src/telemetry/telemetry-config.ts
4836
+ function isTelemetryDisabled() {
4837
+ const value = process.env.UIPATH_TELEMETRY_DISABLED;
4838
+ return value === "1" || value === "true";
4839
+ }
4840
+ function isProjectTelemetryDisabled() {
4841
+ return isTelemetryDisabled() || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "1" || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "true";
4842
+ }
4843
+
4244
4844
  // ../common/src/telemetry/telemetry-spool.ts
4245
4845
  var sidecarEntrySlot = singleton("TelemetrySidecarEntry");
4246
4846
  var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
@@ -4276,7 +4876,6 @@ var telemetry = new Proxy({}, {
4276
4876
  return typeof value === "function" ? value.bind(instance) : value;
4277
4877
  }
4278
4878
  });
4279
-
4280
4879
  // ../common/src/formatter.ts
4281
4880
  var ANSI_STYLES = {
4282
4881
  red: "\x1B[31m",
@@ -4286,46 +4885,6 @@ var ANSI_RESET = "\x1B[0m";
4286
4885
  function styleLine(line, style) {
4287
4886
  return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
4288
4887
  }
4289
- var CLI_ERROR_CODES = [
4290
- "invalid_argument",
4291
- "authentication_required",
4292
- "permission_denied",
4293
- "local_permission_denied",
4294
- "not_found",
4295
- "rate_limited",
4296
- "network_error",
4297
- "timeout",
4298
- "server_error",
4299
- "method_not_allowed",
4300
- "not_supported",
4301
- "configuration_error",
4302
- "execution_failed",
4303
- "unknown_error"
4304
- ];
4305
- var RETRY_HINTS = [
4306
- "RetryWillNotFix",
4307
- "RetryLater",
4308
- "RetryAfter1Second",
4309
- "RetryAfter10Seconds",
4310
- "RetryAfter30Seconds",
4311
- "RetryAfter60Seconds"
4312
- ];
4313
- var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
4314
- var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
4315
- function isCliErrorCode(value) {
4316
- return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
4317
- }
4318
- function isRetryHint(value) {
4319
- return typeof value === "string" && RETRY_HINT_VALUES.has(value);
4320
- }
4321
- var RESULTS = {
4322
- Success: "Success",
4323
- Failure: "Failure",
4324
- ConfigError: "ConfigError",
4325
- AuthenticationError: "AuthenticationError",
4326
- ValidationError: "ValidationError",
4327
- TimeoutError: "TimeoutError"
4328
- };
4329
4888
  var EXIT_CODES = {
4330
4889
  Success: 0,
4331
4890
  Failure: 1,
@@ -4334,6 +4893,9 @@ var EXIT_CODES = {
4334
4893
  ValidationError: 3,
4335
4894
  TimeoutError: 4
4336
4895
  };
4896
+ function exitCodeForResult(result) {
4897
+ return EXIT_CODES[result] ?? EXIT_CODES.Failure;
4898
+ }
4337
4899
  function escapeNonAscii(jsonText) {
4338
4900
  return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
4339
4901
  const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
@@ -5009,8 +5571,8 @@ function carriesOnlyNulls(value) {
5009
5571
  }
5010
5572
  return false;
5011
5573
  }
5012
- function nameList(names, cap2 = 12) {
5013
- const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
5574
+ function nameList(names, cap = 12) {
5575
+ const shown = names.slice(0, cap).map((n) => `\`${n}\``);
5014
5576
  const rest = names.length - shown.length;
5015
5577
  return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
5016
5578
  }
@@ -5147,40 +5709,11 @@ function defaultErrorCodeForResult(result) {
5147
5709
  return "unknown_error";
5148
5710
  }
5149
5711
  }
5150
- function parseHttpStatusFromMessage2(message) {
5151
- const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
5152
- if (!match)
5153
- return;
5154
- const status = Number(match[1]);
5155
- return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
5156
- }
5157
- function defaultErrorCodeForHttpStatus(status) {
5158
- if (status === undefined)
5159
- return;
5160
- if (status === 400 || status === 409 || status === 422) {
5161
- return "invalid_argument";
5162
- }
5163
- if (status === 401)
5164
- return "authentication_required";
5165
- if (status === 403)
5166
- return "permission_denied";
5167
- if (status === 404)
5168
- return "not_found";
5169
- if (status === 405)
5170
- return "method_not_allowed";
5171
- if (status === 408)
5172
- return "timeout";
5173
- if (status === 429)
5174
- return "rate_limited";
5175
- if (status >= 500 && status < 600)
5176
- return "server_error";
5177
- return;
5178
- }
5179
5712
  var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
5180
5713
  function defaultErrorCodeForFailure(data) {
5181
5714
  if (data.Result === RESULTS.Failure) {
5182
- const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
5183
- const errorCode = defaultErrorCodeForHttpStatus(status);
5715
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
5716
+ const errorCode = classifyHttpStatus(status)?.errorCode;
5184
5717
  if (errorCode)
5185
5718
  return errorCode;
5186
5719
  if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
@@ -5189,17 +5722,6 @@ function defaultErrorCodeForFailure(data) {
5189
5722
  }
5190
5723
  return defaultErrorCodeForResult(data.Result);
5191
5724
  }
5192
- function defaultRetryForErrorCode(errorCode) {
5193
- switch (errorCode) {
5194
- case "network_error":
5195
- case "rate_limited":
5196
- case "server_error":
5197
- case "timeout":
5198
- return "RetryLater";
5199
- default:
5200
- return "RetryWillNotFix";
5201
- }
5202
- }
5203
5725
  var OutputFormatter;
5204
5726
  ((OutputFormatter) => {
5205
5727
  function success(data, options) {
@@ -5231,7 +5753,7 @@ var OutputFormatter;
5231
5753
  data.Log ??= getLogFilePath() || undefined;
5232
5754
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
5233
5755
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
5234
- const exitCode = EXIT_CODES[data.Result] ?? 1;
5756
+ const exitCode = exitCodeForResult(data.Result);
5235
5757
  setExitCode(exitCode);
5236
5758
  recordCommandFailureTelemetry({
5237
5759
  result: data.Result,
@@ -5325,39 +5847,228 @@ var OutputFormatter;
5325
5847
  }
5326
5848
  OutputFormatter.formatToString = formatToString;
5327
5849
  })(OutputFormatter ||= {});
5328
- // ../../node_modules/commander/esm.mjs
5329
- var import__ = __toESM(require_commander(), 1);
5330
- var {
5331
- program,
5332
- createCommand,
5333
- createArgument,
5334
- createOption,
5335
- CommanderError,
5336
- InvalidArgumentError,
5337
- InvalidOptionArgumentError,
5338
- Command,
5339
- Argument,
5340
- Option,
5341
- Help
5342
- } = import__.default;
5343
5850
 
5344
- // ../common/src/command-examples.ts
5345
- var examplesByCommand = new WeakMap;
5346
- Command.prototype.examples = function(examples) {
5347
- examplesByCommand.set(this, examples);
5348
- return this;
5349
- };
5350
- // ../common/src/preview.ts
5351
- var previewSlot = singleton("PreviewBuild");
5352
- function isPreviewBuild() {
5353
- return previewSlot.get(false) ?? false;
5851
+ // ../common/src/pass-through-tail.ts
5852
+ function maybeOption(arg) {
5853
+ return arg.length > 1 && arg[0] === "-";
5854
+ }
5855
+ function tokenizeTail(cmd, tail) {
5856
+ const find = (flag) => cmd.options.find((option) => option.long === flag || option.short === flag);
5857
+ const digitShort = cmd.options.some((option) => option.short !== undefined && /^-\d$/.test(option.short));
5858
+ const negativeNumber = (arg) => !digitShort && /^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg);
5859
+ const tokens = [];
5860
+ let firstUnknown = -1;
5861
+ let sentinel = -1;
5862
+ let variadic;
5863
+ let group;
5864
+ let groupIndex = 0;
5865
+ let i = 0;
5866
+ while (i < tail.length || group !== undefined) {
5867
+ const index = group === undefined ? i : groupIndex;
5868
+ const arg = group ?? tail[i++];
5869
+ group = undefined;
5870
+ if (arg === "--") {
5871
+ sentinel = index;
5872
+ tokens.push({ kind: "sentinel", index });
5873
+ for (let j = i;j < tail.length; j++) {
5874
+ tokens.push({
5875
+ kind: "operand",
5876
+ index: j,
5877
+ text: tail[j],
5878
+ literal: true
5879
+ });
5880
+ }
5881
+ break;
5882
+ }
5883
+ if (variadic && (!maybeOption(arg) || negativeNumber(arg))) {
5884
+ tokens.push({
5885
+ kind: "option",
5886
+ index,
5887
+ text: arg,
5888
+ option: variadic,
5889
+ value: arg
5890
+ });
5891
+ continue;
5892
+ }
5893
+ variadic = undefined;
5894
+ if (maybeOption(arg)) {
5895
+ const option = find(arg);
5896
+ if (option) {
5897
+ let value;
5898
+ if (option.required) {
5899
+ value = tail[i];
5900
+ if (value !== undefined)
5901
+ i++;
5902
+ } else if (option.optional) {
5903
+ const next = tail[i];
5904
+ if (next !== undefined && (!maybeOption(next) || negativeNumber(next))) {
5905
+ value = next;
5906
+ i++;
5907
+ }
5908
+ }
5909
+ tokens.push({
5910
+ kind: "option",
5911
+ index,
5912
+ text: arg,
5913
+ option,
5914
+ ...value === undefined ? {} : { value }
5915
+ });
5916
+ variadic = option.variadic ? option : undefined;
5917
+ continue;
5918
+ }
5919
+ }
5920
+ if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
5921
+ const option = find(`-${arg[1]}`);
5922
+ if (option) {
5923
+ if (option.required || option.optional) {
5924
+ tokens.push({
5925
+ kind: "option",
5926
+ index,
5927
+ text: arg,
5928
+ option,
5929
+ value: arg.slice(2)
5930
+ });
5931
+ } else {
5932
+ tokens.push({ kind: "option", index, text: arg, option });
5933
+ group = `-${arg.slice(2)}`;
5934
+ groupIndex = index;
5935
+ }
5936
+ continue;
5937
+ }
5938
+ }
5939
+ if (/^--[^=]+=/.test(arg)) {
5940
+ const equals = arg.indexOf("=");
5941
+ const option = find(arg.slice(0, equals));
5942
+ if (option && (option.required || option.optional)) {
5943
+ tokens.push({
5944
+ kind: "option",
5945
+ index,
5946
+ text: arg,
5947
+ option,
5948
+ value: arg.slice(equals + 1)
5949
+ });
5950
+ continue;
5951
+ }
5952
+ }
5953
+ if (maybeOption(arg) && !negativeNumber(arg)) {
5954
+ const equals = arg.startsWith("--") ? arg.indexOf("=") : -1;
5955
+ if (firstUnknown === -1)
5956
+ firstUnknown = index;
5957
+ tokens.push({
5958
+ kind: "unknown",
5959
+ index,
5960
+ text: arg,
5961
+ flag: equals > 0 ? arg.slice(0, equals) : arg,
5962
+ ...equals > 0 ? { inlineValue: arg.slice(equals + 1) } : {}
5963
+ });
5964
+ continue;
5965
+ }
5966
+ tokens.push({ kind: "operand", index, text: arg, literal: false });
5967
+ }
5968
+ return { tokens, firstUnknown, sentinel };
5354
5969
  }
5355
- Command.prototype.previewCommand = function(nameAndArgs, opts) {
5356
- if (isPreviewBuild()) {
5357
- return this.command(nameAndArgs, opts);
5970
+
5971
+ // ../common/src/project-telemetry.ts
5972
+ var RESOLVER = Symbol.for("@uipath/common/projectTelemetryResolver");
5973
+ var CAPTURE = Symbol.for("@uipath/common/projectTelemetryCapture");
5974
+ var CONTEXT_RESOLVER = Symbol.for("@uipath/common/projectContextTelemetryResolver");
5975
+ var RULES = Symbol.for("@uipath/common/projectTargetRules");
5976
+ function logSkipped(what, error) {
5977
+ logger.debug(`[project-telemetry] ${what} skipped: ${error instanceof Error ? error.message : String(error)}`);
5978
+ }
5979
+ function bounded(work, what) {
5980
+ return withinProjectIdentityBudget(work, () => logSkipped(what, `no answer within ${PROJECT_IDENTITY_LOOKUP_BUDGET_MS} ms`));
5981
+ }
5982
+ async function identityWithContext(command, identity) {
5983
+ const props = projectIdentityProperties(identity);
5984
+ if (!identity.projectDirectory || isProjectTelemetryDisabled())
5985
+ return props;
5986
+ for (let node = command;node; node = node.parent ?? undefined) {
5987
+ const resolver = node[CONTEXT_RESOLVER];
5988
+ if (typeof resolver !== "function")
5989
+ continue;
5990
+ try {
5991
+ return {
5992
+ ...await resolver(identity.projectDirectory),
5993
+ ...props
5994
+ };
5995
+ } catch (error) {
5996
+ logSkipped("solution context lookup", error);
5997
+ return props;
5998
+ }
5358
5999
  }
5359
- return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
5360
- };
6000
+ return props;
6001
+ }
6002
+ function getProjectTelemetryResolver(command) {
6003
+ for (let node = command;node; node = node.parent) {
6004
+ const resolver = node[RESOLVER];
6005
+ if (typeof resolver === "function")
6006
+ return resolver;
6007
+ }
6008
+ return;
6009
+ }
6010
+ function attachProjectTelemetryCapture(command, capture) {
6011
+ command[CAPTURE] = capture;
6012
+ }
6013
+ class ProjectTelemetrySession {
6014
+ resolver;
6015
+ command;
6016
+ target;
6017
+ props = {};
6018
+ explicit = false;
6019
+ input;
6020
+ constructor(resolver, command) {
6021
+ this.resolver = resolver;
6022
+ this.command = command;
6023
+ }
6024
+ async setTarget(path) {
6025
+ this.target = path;
6026
+ if (this.input) {
6027
+ await this.resolve({
6028
+ ...this.input,
6029
+ phase: "after",
6030
+ success: true
6031
+ });
6032
+ this.explicit = true;
6033
+ }
6034
+ }
6035
+ async setIdentity(identity) {
6036
+ try {
6037
+ const props = await bounded(identityWithContext(this.command, identity), "project identity capture");
6038
+ if (props !== undefined)
6039
+ this.setProperties(props);
6040
+ } catch (error) {
6041
+ logSkipped("project identity capture", error);
6042
+ }
6043
+ }
6044
+ setProperties(properties) {
6045
+ try {
6046
+ this.props = { ...properties };
6047
+ this.explicit = true;
6048
+ } catch (error) {
6049
+ logSkipped("project identity properties", error);
6050
+ }
6051
+ }
6052
+ properties() {
6053
+ return { ...this.props };
6054
+ }
6055
+ async resolve(input) {
6056
+ this.input = input;
6057
+ if (this.explicit)
6058
+ return;
6059
+ try {
6060
+ const props = await bounded(this.resolver({
6061
+ ...input,
6062
+ target: this.target
6063
+ }), `project identity (${input.phase})`);
6064
+ if (props !== undefined) {
6065
+ this.props = props;
6066
+ }
6067
+ } catch (error) {
6068
+ logSkipped(`project identity (${input.phase})`, error);
6069
+ }
6070
+ }
6071
+ }
5361
6072
 
5362
6073
  // ../common/src/telemetry/command-attribution.ts
5363
6074
  var LEGACY_SKILL_NAMESPACE = "uipath:";
@@ -5603,8 +6314,7 @@ var pollSignalSlot = singleton("PollSignal");
5603
6314
  var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
5604
6315
  var processContext = {
5605
6316
  exit: (code) => {
5606
- recordExitCode(code);
5607
- setExitCode(code);
6317
+ recordCommandExit(code);
5608
6318
  },
5609
6319
  get pollSignal() {
5610
6320
  return pollSignalSlot.get();
@@ -5629,6 +6339,8 @@ function recordableArgValue(value, choices) {
5629
6339
  function extractCommandParams(cmd) {
5630
6340
  const params = {};
5631
6341
  forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
6342
+ if (name === undefined)
6343
+ return;
5632
6344
  const recordable = recordableArgValue(value, choices);
5633
6345
  params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
5634
6346
  });
@@ -5644,7 +6356,8 @@ function isDefaultedPositional(cmd, index) {
5644
6356
  function forEachSuppliedArgument(cmd, visit) {
5645
6357
  const registered = cmd.registeredArguments ?? [];
5646
6358
  const processed = cmd.processedArgs ?? [];
5647
- for (let i = 0;i < registered.length; i++) {
6359
+ const bound = boundPositionalCount(cmd);
6360
+ for (let i = 0;i < bound; i++) {
5648
6361
  const name = registered[i].name();
5649
6362
  if (name && processed[i] !== undefined) {
5650
6363
  visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
@@ -5659,6 +6372,71 @@ function forEachSuppliedArgument(cmd, visit) {
5659
6372
  visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
5660
6373
  }
5661
6374
  }
6375
+ forEachPassThroughToken(cmd, bound, (name, value) => {
6376
+ visit(name, value, name === undefined ? undefined : choicesByAttribute.get(name), false);
6377
+ });
6378
+ }
6379
+ function boundPositionalCount(cmd) {
6380
+ const registered = cmd.registeredArguments ?? [];
6381
+ if (registered.some((argument) => argument.variadic)) {
6382
+ return registered.length;
6383
+ }
6384
+ if ((cmd.args ?? []).length <= registered.length) {
6385
+ return registered.length;
6386
+ }
6387
+ const firstFlag = tokenizeTail(cmd, (cmd.args ?? []).slice(1)).tokens.find((token) => token.kind !== "operand")?.index ?? -1;
6388
+ return firstFlag === -1 ? registered.length : Math.min(registered.length, firstFlag + 1);
6389
+ }
6390
+ function forEachPassThroughToken(cmd, bound, visit) {
6391
+ const registered = cmd.registeredArguments ?? [];
6392
+ const fillsPositionals = !registered.some((argument) => argument.variadic);
6393
+ const { tokens, firstUnknown } = tokenizeTail(cmd, (cmd.args ?? []).slice(bound));
6394
+ const repeated = new Map;
6395
+ let nextPositional = bound;
6396
+ for (const token of tokens) {
6397
+ const pastUnknown = firstUnknown !== -1 && token.index > firstUnknown;
6398
+ if (token.kind === "sentinel")
6399
+ continue;
6400
+ if (token.kind === "operand") {
6401
+ const claimable = !pastUnknown && fillsPositionals && nextPositional < registered.length;
6402
+ const name = claimable ? registered[nextPositional++].name() : undefined;
6403
+ visit(name || undefined, token.text);
6404
+ continue;
6405
+ }
6406
+ if (token.kind === "unknown") {
6407
+ const bare = token.flag.replace(/^-+/, "");
6408
+ const key = bare.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
6409
+ const keyable = token.flag.startsWith("--") || token.flag.length === 2;
6410
+ if (!pastUnknown && keyable && /^[a-z][a-z0-9-]*$/i.test(bare) && key) {
6411
+ visit(key, token.inlineValue ?? true);
6412
+ } else {
6413
+ visit(undefined, token.text);
6414
+ if (token.inlineValue !== undefined) {
6415
+ visit(undefined, token.inlineValue);
6416
+ } else if (!token.flag.startsWith("--") && token.flag.length > 2) {
6417
+ visit(undefined, token.flag.slice(2));
6418
+ }
6419
+ }
6420
+ continue;
6421
+ }
6422
+ if (pastUnknown) {
6423
+ visit(undefined, token.text);
6424
+ if (token.value !== undefined)
6425
+ visit(undefined, token.value);
6426
+ continue;
6427
+ }
6428
+ const option = token.option;
6429
+ const name = option.attributeName();
6430
+ const value = option.negate ? false : option.required || option.optional ? token.value ?? true : true;
6431
+ const previous = repeated.get(name);
6432
+ if (previous) {
6433
+ previous.push(value);
6434
+ visit(name, previous);
6435
+ } else {
6436
+ repeated.set(name, [value]);
6437
+ visit(name, value);
6438
+ }
6439
+ }
5662
6440
  }
5663
6441
  function withheldArgumentValues(cmd) {
5664
6442
  const values = [];
@@ -5720,6 +6498,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5720
6498
  const telemetryName = commandTelemetryName(commandParts);
5721
6499
  const commandPath = commandInvocationPath(commandParts);
5722
6500
  const props = typeof properties === "function" ? properties(...args) : properties;
6501
+ const projectResolver = getProjectTelemetryResolver(command);
6502
+ const projectSession = projectResolver && !isProjectTelemetryDisabled() ? new ProjectTelemetrySession(projectResolver, command) : undefined;
5723
6503
  markCommandStart();
5724
6504
  const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
5725
6505
  try {
@@ -5732,6 +6512,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5732
6512
  if (violation) {
5733
6513
  return Promise.reject(violation);
5734
6514
  }
6515
+ if (projectSession) {
6516
+ return projectSession.resolve({ command, args, phase: "before" }).then(() => {
6517
+ attachProjectTelemetryCapture(command, projectSession);
6518
+ return fn(...args);
6519
+ });
6520
+ }
5735
6521
  return fn(...args);
5736
6522
  }));
5737
6523
  if (error) {
@@ -5740,22 +6526,26 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5740
6526
  const typed = error;
5741
6527
  const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
5742
6528
  const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
5743
- const finalResult = customResult ?? RESULTS.Failure;
6529
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
6530
+ const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
6531
+ const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
5744
6532
  const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
5745
6533
  const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
5746
6534
  const typedRetry = typed.retry ?? typed.Retry;
5747
6535
  const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
5748
6536
  const typedContext = typed.context ?? typed.Context;
5749
6537
  const customContext = isErrorContext(typedContext) ? typedContext : undefined;
5750
- const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
5751
6538
  fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
6539
+ const errorCode = customErrorCode ?? classified?.errorCode;
6540
+ const retry = customRetry ?? classified?.retry;
6541
+ const errorContext = customContext ?? classified?.context;
5752
6542
  OutputFormatter.error({
5753
6543
  Result: finalResult,
5754
- ...customErrorCode ? { ErrorCode: customErrorCode } : {},
6544
+ ...errorCode ? { ErrorCode: errorCode } : {},
5755
6545
  Message: errorMessage,
5756
6546
  Instructions: customInstructions ?? commandHelpHint(commandPath),
5757
- ...customRetry ? { Retry: customRetry } : {},
5758
- ...customContext ? { Context: customContext } : {}
6547
+ ...retry ? { Retry: retry } : {},
6548
+ ...errorContext ? { Context: errorContext } : {}
5759
6549
  });
5760
6550
  context.exit(fallbackExitCode);
5761
6551
  }
@@ -5764,6 +6554,14 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5764
6554
  const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
5765
6555
  const recordedFailure = takeRecordedCommandFailureTelemetry();
5766
6556
  const success = !error && exitCode === 0;
6557
+ if (projectSession) {
6558
+ await projectSession.resolve({
6559
+ command,
6560
+ args,
6561
+ phase: "after",
6562
+ success
6563
+ });
6564
+ }
5767
6565
  const terminalTelemetry = buildCommandTerminalTelemetryProperties({
5768
6566
  error,
5769
6567
  exitCode,
@@ -5781,6 +6579,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5781
6579
  }
5782
6580
  const baseProperties = redactProperties({
5783
6581
  ...commandParams,
6582
+ ...projectSession?.properties(),
5784
6583
  ...props,
5785
6584
  ...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
5786
6585
  ...buildAgentSessionTelemetry(process.env),
@@ -5791,6 +6590,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5791
6590
  });
5792
6591
  emitInvocationRequest(telemetryName, success, baseProperties);
5793
6592
  } finally {
6593
+ if (projectSession)
6594
+ attachProjectTelemetryCapture(command, undefined);
5794
6595
  releaseSuppliedArgumentValues(supplied);
5795
6596
  }
5796
6597
  });
@@ -6269,9 +7070,9 @@ function getProfileStorage() {
6269
7070
  if (isAuthProfileStorage(existing)) {
6270
7071
  return existing;
6271
7072
  }
6272
- const storage2 = createProfileStorage();
6273
- globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage2;
6274
- return storage2;
7073
+ const storage = createProfileStorage();
7074
+ globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
7075
+ return storage;
6275
7076
  }
6276
7077
  var profileStorage = getProfileStorage();
6277
7078
 
@@ -6302,8 +7103,8 @@ function resolveAuthProfileFilePath(profile) {
6302
7103
  if (normalized === undefined) {
6303
7104
  throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
6304
7105
  }
6305
- const fs2 = getFileSystem();
6306
- return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
7106
+ const fs = getFileSystem();
7107
+ return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
6307
7108
  }
6308
7109
  function getActiveAuthProfileFilePath() {
6309
7110
  const profile = getActiveAuthProfile();
@@ -6476,6 +7277,8 @@ var ENV_AUTH_VARS = {
6476
7277
  };
6477
7278
 
6478
7279
  class EnvAuthConfigError extends Error {
7280
+ errorCode = "configuration_error";
7281
+ retry = "RetryWillNotFix";
6479
7282
  constructor(message) {
6480
7283
  super(message);
6481
7284
  this.name = "EnvAuthConfigError";
@@ -6514,11 +7317,11 @@ var readAuthFromEnv = () => {
6514
7317
  if (!rawUrl) {
6515
7318
  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}).`);
6516
7319
  }
6517
- const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
7320
+ const baseUrl = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
6518
7321
  return {
6519
7322
  loginStatus: "Logged in",
6520
7323
  accessToken,
6521
- baseUrl: baseUrl2,
7324
+ baseUrl,
6522
7325
  organizationName,
6523
7326
  organizationId,
6524
7327
  tenantName,
@@ -6559,8 +7362,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
6559
7362
  async function refreshTokenFingerprint(refreshToken) {
6560
7363
  const bytes = new TextEncoder().encode(refreshToken);
6561
7364
  if (globalThis.crypto?.subtle) {
6562
- const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
6563
- return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
7365
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
7366
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
6564
7367
  }
6565
7368
  const { createHash } = await import("node:crypto");
6566
7369
  return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
@@ -6569,9 +7372,9 @@ function breakerPathFor(authPath) {
6569
7372
  return `${authPath}${BREAKER_SUFFIX}`;
6570
7373
  }
6571
7374
  async function loadRefreshBreaker(authPath) {
6572
- const fs2 = getFileSystem();
7375
+ const fs = getFileSystem();
6573
7376
  try {
6574
- const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
7377
+ const content = await fs.readFile(breakerPathFor(authPath), "utf-8");
6575
7378
  if (!content)
6576
7379
  return {};
6577
7380
  const parsed = JSON.parse(content);
@@ -6582,20 +7385,20 @@ async function loadRefreshBreaker(authPath) {
6582
7385
  }
6583
7386
  async function saveRefreshBreaker(authPath, state) {
6584
7387
  try {
6585
- const fs2 = getFileSystem();
6586
- const path2 = breakerPathFor(authPath);
6587
- await fs2.mkdir(fs2.path.dirname(path2));
6588
- const tempPath = `${path2}.tmp`;
6589
- await fs2.writeFile(tempPath, JSON.stringify(state));
6590
- await fs2.rename(tempPath, path2);
7388
+ const fs = getFileSystem();
7389
+ const path = breakerPathFor(authPath);
7390
+ await fs.mkdir(fs.path.dirname(path));
7391
+ const tempPath = `${path}.tmp`;
7392
+ await fs.writeFile(tempPath, JSON.stringify(state));
7393
+ await fs.rename(tempPath, path);
6591
7394
  } catch {}
6592
7395
  }
6593
7396
  async function clearRefreshBreaker(authPath) {
6594
- const fs2 = getFileSystem();
6595
- const path2 = breakerPathFor(authPath);
7397
+ const fs = getFileSystem();
7398
+ const path = breakerPathFor(authPath);
6596
7399
  try {
6597
- if (await fs2.exists(path2)) {
6598
- await fs2.rm(path2);
7400
+ if (await fs.exists(path)) {
7401
+ await fs.rm(path);
6599
7402
  }
6600
7403
  } catch {}
6601
7404
  }
@@ -6616,13 +7419,13 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
6616
7419
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
6617
7420
  var PIPE_NAME_MAX_LENGTH = 103;
6618
7421
  var getRobotIpcPipeNames = async () => {
6619
- const fs2 = getFileSystem();
6620
- const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
7422
+ const fs = getFileSystem();
7423
+ const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
6621
7424
  if (!username) {
6622
7425
  throw new Error("Unable to determine current username");
6623
7426
  }
6624
- const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
6625
- return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
7427
+ const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
7428
+ return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
6626
7429
  };
6627
7430
  var defaultIsRobotIpcAvailable = async () => {
6628
7431
  if (process.platform === "win32") {
@@ -6632,20 +7435,20 @@ var defaultIsRobotIpcAvailable = async () => {
6632
7435
  if (pipeNamesError || !pipeNames) {
6633
7436
  return false;
6634
7437
  }
6635
- const fs2 = getFileSystem();
7438
+ const fs = getFileSystem();
6636
7439
  for (const pipeName of pipeNames) {
6637
- const [existsError, exists] = await catchError2(fs2.exists(pipeName));
7440
+ const [existsError, exists] = await catchError2(fs.exists(pipeName));
6638
7441
  if (!existsError && exists === true) {
6639
7442
  return true;
6640
7443
  }
6641
7444
  }
6642
7445
  return false;
6643
7446
  };
6644
- var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
7447
+ var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
6645
7448
  const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
6646
7449
  promise.then((value) => {
6647
7450
  clearTimeout(timer);
6648
- resolve2(value);
7451
+ resolve(value);
6649
7452
  }, (error) => {
6650
7453
  clearTimeout(timer);
6651
7454
  reject(error);
@@ -6818,9 +7621,12 @@ var refreshAccessToken = async ({
6818
7621
  body: tokenParams
6819
7622
  });
6820
7623
  const tokenData = await tokenResponse.json();
6821
- if (!tokenResponse.ok) {
7624
+ if (tokenResponse.status === 400 || tokenResponse.status === 401) {
6822
7625
  throw new TokenRefreshOAuthError;
6823
7626
  }
7627
+ if (!tokenResponse.ok) {
7628
+ throw new Error(`Token refresh failed: HTTP ${tokenResponse.status}`);
7629
+ }
6824
7630
  const newAccessToken = tokenData.access_token;
6825
7631
  const newRefreshToken = tokenData.refresh_token;
6826
7632
  if (typeof newAccessToken !== "string" || typeof newRefreshToken !== "string") {
@@ -6852,9 +7658,9 @@ var errorCode = (err) => {
6852
7658
  }
6853
7659
  return "EUNKNOWN";
6854
7660
  };
6855
- var probeAsync = async (fs2, candidate) => {
7661
+ var probeAsync = async (fs, candidate) => {
6856
7662
  try {
6857
- const stats = await fs2.stat(candidate);
7663
+ const stats = await fs.stat(candidate);
6858
7664
  if (stats === null) {
6859
7665
  return { exists: false };
6860
7666
  }
@@ -6881,36 +7687,36 @@ var probeAsync = async (fs2, candidate) => {
6881
7687
  }
6882
7688
  };
6883
7689
  var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
6884
- const fs2 = getFileSystem();
6885
- if (fs2.path.isAbsolute(envFilePath)) {
6886
- const probe2 = await probeAsync(fs2, envFilePath);
6887
- return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
7690
+ const fs = getFileSystem();
7691
+ if (fs.path.isAbsolute(envFilePath)) {
7692
+ const probe = await probeAsync(fs, envFilePath);
7693
+ return probe.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
6888
7694
  exists: false,
6889
7695
  absolutePath: envFilePath,
6890
7696
  source: "absolute",
6891
- ...probe2.unusable ? { unusable: probe2.unusable } : {}
7697
+ ...probe.unusable ? { unusable: probe.unusable } : {}
6892
7698
  };
6893
7699
  }
6894
- const cwd = opts?.cwd ?? fs2.env.cwd();
7700
+ const cwd = opts?.cwd ?? fs.env.cwd();
6895
7701
  let searchDir = cwd;
6896
7702
  while (true) {
6897
- const candidate = fs2.path.join(searchDir, envFilePath);
6898
- const probe2 = await probeAsync(fs2, candidate);
6899
- if (probe2.exists) {
7703
+ const candidate = fs.path.join(searchDir, envFilePath);
7704
+ const probe = await probeAsync(fs, candidate);
7705
+ if (probe.exists) {
6900
7706
  return {
6901
7707
  exists: true,
6902
7708
  absolutePath: candidate,
6903
7709
  source: searchDir === cwd ? "cwd" : "ancestor"
6904
7710
  };
6905
7711
  }
6906
- const parentDir = fs2.path.dirname(searchDir);
7712
+ const parentDir = fs.path.dirname(searchDir);
6907
7713
  if (parentDir === searchDir) {
6908
7714
  break;
6909
7715
  }
6910
7716
  searchDir = parentDir;
6911
7717
  }
6912
- const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
6913
- const probe = await probeAsync(fs2, homePath);
7718
+ const homePath = fs.path.join(fs.env.homedir(), envFilePath);
7719
+ const probe = await probeAsync(fs, homePath);
6914
7720
  if (probe.exists) {
6915
7721
  return { exists: true, absolutePath: homePath, source: "home" };
6916
7722
  }
@@ -6953,12 +7759,12 @@ var parseEnvContent = (content) => {
6953
7759
  return env;
6954
7760
  };
6955
7761
  var loadEnvFileAsync = async ({ envPath }) => {
6956
- const fs2 = getFileSystem();
6957
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
6958
- if (!await fs2.exists(absolutePath)) {
7762
+ const fs = getFileSystem();
7763
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
7764
+ if (!await fs.exists(absolutePath)) {
6959
7765
  throw new Error(`Environment file not found: ${envPath}`);
6960
7766
  }
6961
- const content = await fs2.readFile(absolutePath, "utf-8");
7767
+ const content = await fs.readFile(absolutePath, "utf-8");
6962
7768
  if (content === null) {
6963
7769
  throw new Error(`Environment file not found: ${envPath}`);
6964
7770
  }
@@ -6969,10 +7775,10 @@ var saveEnvFileAsync = async ({
6969
7775
  data,
6970
7776
  merge = true
6971
7777
  }) => {
6972
- const fs2 = getFileSystem();
6973
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
7778
+ const fs = getFileSystem();
7779
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
6974
7780
  let existingData = {};
6975
- if (merge && await fs2.exists(absolutePath)) {
7781
+ if (merge && await fs.exists(absolutePath)) {
6976
7782
  try {
6977
7783
  existingData = await loadEnvFileAsync({ envPath: absolutePath });
6978
7784
  } catch {}
@@ -6990,11 +7796,11 @@ var saveEnvFileAsync = async ({
6990
7796
  const content = `${lines.join(`
6991
7797
  `)}
6992
7798
  `;
6993
- const dir = fs2.path.dirname(absolutePath);
6994
- await fs2.mkdir(dir);
7799
+ const dir = fs.path.dirname(absolutePath);
7800
+ await fs.mkdir(dir);
6995
7801
  const tempPath = `${absolutePath}.tmp`;
6996
- await fs2.writeFile(tempPath, content);
6997
- await fs2.rename(tempPath, absolutePath);
7802
+ await fs.writeFile(tempPath, content);
7803
+ await fs.rename(tempPath, absolutePath);
6998
7804
  };
6999
7805
 
7000
7806
  // ../auth/src/loginStatus.ts
@@ -7118,11 +7924,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
7118
7924
  return { credentials };
7119
7925
  }
7120
7926
  async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
7121
- const fs2 = getFs();
7122
- const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
7927
+ const fs = getFs();
7928
+ const globalPath = fs.path.join(fs.env.homedir(), envFilePath);
7123
7929
  if (absolutePath === globalPath)
7124
7930
  return;
7125
- if (!await fs2.exists(globalPath))
7931
+ if (!await fs.exists(globalPath))
7126
7932
  return;
7127
7933
  try {
7128
7934
  const globalCreds = await loadEnvFile({ envPath: globalPath });
@@ -7539,26 +8345,38 @@ function errorMessage(error) {
7539
8345
  }
7540
8346
 
7541
8347
  // ../auth/src/authContext.ts
8348
+ class AuthContextUnavailableError extends Error {
8349
+ instructionContext;
8350
+ sessionHint;
8351
+ errorCode = "authentication_required";
8352
+ retry = "RetryWillNotFix";
8353
+ constructor(message, instructionContext = "auth", sessionHint) {
8354
+ super(message);
8355
+ this.instructionContext = instructionContext;
8356
+ this.sessionHint = sessionHint;
8357
+ this.name = "AuthContextUnavailableError";
8358
+ }
8359
+ }
7542
8360
  var getAuthContext = async (options = {}) => {
7543
8361
  const status = await getLoginStatusAsync({
7544
8362
  ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
7545
8363
  envFilePath: options.envFilePath
7546
8364
  });
7547
8365
  if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
7548
- throw new Error(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.");
8366
+ throw new AuthContextUnavailableError(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.", "auth", status.hint);
7549
8367
  }
7550
- const tenantName = options.tenant ?? status.tenantName;
8368
+ const tenantName = options.tenant || status.tenantName;
7551
8369
  if (options.requireOrganizationId && !status.organizationId) {
7552
- throw new Error("Organization ID not available. Ensure you are logged in with an organization context.");
8370
+ throw new AuthContextUnavailableError("Organization ID not available. Ensure you are logged in with an organization context.", "identity");
7553
8371
  }
7554
8372
  if (options.requireOrganizationName && !status.organizationName) {
7555
- throw new Error("Organization name not available. Ensure you are logged in with an organization context.");
8373
+ throw new AuthContextUnavailableError("Organization name not available. Ensure you are logged in with an organization context.", "identity");
7556
8374
  }
7557
8375
  if (options.requireTenantId && !status.tenantId) {
7558
- throw new Error("Tenant ID not available. Ensure UIPATH_TENANT_ID is set.");
8376
+ throw new AuthContextUnavailableError(`Tenant ID not available. Ensure UIPATH_TENANT_ID is set.${status.hint ? ` ${status.hint}` : ""}`, "identity", status.hint);
7559
8377
  }
7560
- if (options.requireTenantName && tenantName === undefined) {
7561
- 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.");
8378
+ if (options.requireTenantName && !tenantName) {
8379
+ 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");
7562
8380
  }
7563
8381
  return {
7564
8382
  baseUrl: status.baseUrl,
@@ -7594,11 +8412,11 @@ async function createPmConfig(tenantOverride) {
7594
8412
  authToken: ctx.accessToken
7595
8413
  };
7596
8414
  }
7597
- function buildPmUrl(config, path2) {
7598
- return `${config.baseUrl}/${config.organizationName}/${config.tenantName}/processmining_/api/${PM_API_VERSION}${path2}`;
8415
+ function buildPmUrl(config, path) {
8416
+ return `${config.baseUrl}/${encodeURIComponent(config.organizationName)}/${encodeURIComponent(config.tenantName)}/processmining_/api/${PM_API_VERSION}${path}`;
7599
8417
  }
7600
- function buildPmtUrl(config, path2) {
7601
- return `${config.baseUrl}/${config.organizationName}/${config.tenantName}/processmining_/api/pmt/${PMT_API_VERSION}${path2}`;
8418
+ function buildPmtUrl(config, path) {
8419
+ return `${config.baseUrl}/${encodeURIComponent(config.organizationName)}/${encodeURIComponent(config.tenantName)}/processmining_/api/pmt/${PMT_API_VERSION}${path}`;
7602
8420
  }
7603
8421
  function buildHeaders(config) {
7604
8422
  return {
@@ -7637,8 +8455,8 @@ function parseJsonBody(response, text) {
7637
8455
  throw unexpectedBodyError(response, "JSON", text);
7638
8456
  return parsed;
7639
8457
  }
7640
- async function pmRequest(config, method, path2, body) {
7641
- const response = await fetch(buildPmUrl(config, path2), {
8458
+ async function pmRequest(config, method, path, body) {
8459
+ const response = await fetch(buildPmUrl(config, path), {
7642
8460
  method,
7643
8461
  headers: buildHeaders(config),
7644
8462
  body: body === undefined ? undefined : JSON.stringify(body)
@@ -7647,20 +8465,20 @@ async function pmRequest(config, method, path2, body) {
7647
8465
  throw await toApiError(response);
7648
8466
  return parseJsonBody(response, await response.text());
7649
8467
  }
7650
- async function pmGet(config, path2) {
7651
- const result = await pmRequest(config, "GET", path2);
8468
+ async function pmGet(config, path) {
8469
+ const result = await pmRequest(config, "GET", path);
7652
8470
  if (result === null)
7653
8471
  throw new Error("API returned an empty response body");
7654
8472
  return result;
7655
8473
  }
7656
- async function pmPost(config, path2, body) {
7657
- return pmRequest(config, "POST", path2, body);
8474
+ async function pmPost(config, path, body) {
8475
+ return pmRequest(config, "POST", path, body);
7658
8476
  }
7659
- async function pmDelete(config, path2, body) {
7660
- return pmRequest(config, "DELETE", path2, body);
8477
+ async function pmDelete(config, path, body) {
8478
+ return pmRequest(config, "DELETE", path, body);
7661
8479
  }
7662
- async function getWithEtag(config, path2) {
7663
- const response = await fetch(buildPmUrl(config, path2), {
8480
+ async function getWithEtag(config, path) {
8481
+ const response = await fetch(buildPmUrl(config, path), {
7664
8482
  method: "GET",
7665
8483
  headers: { Authorization: `Bearer ${config.authToken}` }
7666
8484
  });
@@ -7672,22 +8490,22 @@ async function getWithEtag(config, path2) {
7672
8490
  etag: response.headers.get("etag")
7673
8491
  };
7674
8492
  }
7675
- async function pmGetRaw(config, path2) {
7676
- const { response, text, etag } = await getWithEtag(config, path2);
8493
+ async function pmGetRaw(config, path) {
8494
+ const { response, text, etag } = await getWithEtag(config, path);
7677
8495
  parseJsonBody(response, text);
7678
8496
  return { content: text, etag };
7679
8497
  }
7680
8498
  var FILE_CONTENT_TYPE = "application/octet-stream";
7681
- async function pmGetFile(config, path2) {
7682
- const { response, text, etag } = await getWithEtag(config, path2);
8499
+ async function pmGetFile(config, path) {
8500
+ const { response, text, etag } = await getWithEtag(config, path);
7683
8501
  const contentType = response.headers.get("content-type") ?? "";
7684
8502
  if (contentType.split(";")[0].trim().toLowerCase() !== FILE_CONTENT_TYPE) {
7685
8503
  throw unexpectedBodyError(response, `a file (${FILE_CONTENT_TYPE})`, text);
7686
8504
  }
7687
8505
  return { content: text, etag };
7688
8506
  }
7689
- async function pmPutJson(config, path2, body, etag) {
7690
- const response = await fetch(buildPmUrl(config, path2), {
8507
+ async function pmPutJson(config, path, body, etag) {
8508
+ const response = await fetch(buildPmUrl(config, path), {
7691
8509
  method: "PUT",
7692
8510
  headers: {
7693
8511
  Authorization: `Bearer ${config.authToken}`,
@@ -7741,9 +8559,9 @@ async function getAppToken(config, appId, forceRefresh = false) {
7741
8559
  }
7742
8560
  return token;
7743
8561
  }
7744
- async function pmtFetch(config, appId, path2, forceRefresh) {
8562
+ async function pmtFetch(config, appId, path, forceRefresh) {
7745
8563
  const token = await getAppToken(config, appId, forceRefresh);
7746
- return fetch(buildPmtUrl(config, path2), {
8564
+ return fetch(buildPmtUrl(config, path), {
7747
8565
  method: "GET",
7748
8566
  headers: {
7749
8567
  Authorization: `Bearer ${token}`,
@@ -7751,10 +8569,10 @@ async function pmtFetch(config, appId, path2, forceRefresh) {
7751
8569
  }
7752
8570
  });
7753
8571
  }
7754
- async function pmtGet(config, appId, path2) {
7755
- let response = await pmtFetch(config, appId, path2, false);
8572
+ async function pmtGet(config, appId, path) {
8573
+ let response = await pmtFetch(config, appId, path, false);
7756
8574
  if (response.status === 401) {
7757
- response = await pmtFetch(config, appId, path2, true);
8575
+ response = await pmtFetch(config, appId, path, true);
7758
8576
  }
7759
8577
  if (!response.ok)
7760
8578
  throw await toApiError(response);
@@ -7763,14 +8581,14 @@ async function pmtGet(config, appId, path2) {
7763
8581
  throw new Error("API returned an empty response body");
7764
8582
  return result;
7765
8583
  }
7766
- async function pmPutRaw(config, path2, content, etag) {
7767
- return putRaw(config, path2, content, { "If-Match": etag });
8584
+ async function pmPutRaw(config, path, content, etag) {
8585
+ return putRaw(config, path, content, { "If-Match": etag });
7768
8586
  }
7769
- async function pmCreateRaw(config, path2, content) {
7770
- return putRaw(config, path2, content);
8587
+ async function pmCreateRaw(config, path, content) {
8588
+ return putRaw(config, path, content);
7771
8589
  }
7772
- async function putRawResponse(config, path2, content, extraHeaders) {
7773
- const response = await fetch(buildPmUrl(config, path2), {
8590
+ async function putRawResponse(config, path, content, extraHeaders) {
8591
+ const response = await fetch(buildPmUrl(config, path), {
7774
8592
  method: "PUT",
7775
8593
  headers: {
7776
8594
  Authorization: `Bearer ${config.authToken}`,
@@ -7786,12 +8604,12 @@ async function putRawResponse(config, path2, content, extraHeaders) {
7786
8604
  body: parseJsonBody(response, await response.text())
7787
8605
  };
7788
8606
  }
7789
- async function putRaw(config, path2, content, extraHeaders) {
7790
- const { response } = await putRawResponse(config, path2, content, extraHeaders);
8607
+ async function putRaw(config, path, content, extraHeaders) {
8608
+ const { response } = await putRawResponse(config, path, content, extraHeaders);
7791
8609
  return response.headers.get("etag");
7792
8610
  }
7793
- async function pmPutBinaryJson(config, path2, content) {
7794
- const { body } = await putRawResponse(config, path2, content);
8611
+ async function pmPutBinaryJson(config, path, content) {
8612
+ const { body } = await putRawResponse(config, path, content);
7795
8613
  return body;
7796
8614
  }
7797
8615
 
@@ -7823,7 +8641,7 @@ function field(obj, name) {
7823
8641
  return obj[name] ?? obj[pascal];
7824
8642
  }
7825
8643
  function unwrapData(payload) {
7826
- if (payload !== null && typeof payload === "object" && !Array.isArray(payload)) {
8644
+ if (!Array.isArray(payload)) {
7827
8645
  const inner = field(payload, "data");
7828
8646
  if (inner !== undefined)
7829
8647
  return inner;
@@ -7865,7 +8683,7 @@ var TERMINAL_STATUSES2 = new Set([
7865
8683
  "CANCELLED",
7866
8684
  "CANCELED"
7867
8685
  ]);
7868
- var sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
8686
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
7869
8687
  var isTerminal = (status) => status !== undefined && status !== "" && TERMINAL_STATUSES2.has(status.toUpperCase());
7870
8688
  var DEFAULT_TIMEOUT_SECONDS = 1800;
7871
8689
  var DEFAULT_POLL_INTERVAL_SECONDS = 5;
@@ -8027,8 +8845,8 @@ var APP_TYPES_LIST_EXAMPLES = [
8027
8845
  }
8028
8846
  }
8029
8847
  ];
8030
- function registerAppTypesCommand(program2) {
8031
- const appTypesCmd = program2.command("app-types").description("Discover process app templates (app types)");
8848
+ function registerAppTypesCommand(program) {
8849
+ const appTypesCmd = program.command("app-types").description("Discover process app templates (app types)");
8032
8850
  appTypesCmd.command("list").description("List available app templates at their latest version").examples(APP_TYPES_LIST_EXAMPLES).trackedAction(processContext, async () => {
8033
8851
  const config = await loadConfigOrExit();
8034
8852
  if (!config)
@@ -8130,13 +8948,13 @@ function findDashboard(dashboards, selector) {
8130
8948
  const known = dashboards.map((entry) => `${entry.id} (${entry.name})`).join(", ");
8131
8949
  throw new Error(`No dashboard matched '${selector}'. Known dashboards: ${known || "none"}.`);
8132
8950
  }
8133
- async function readJsonFile(path2) {
8134
- const content = await getFileSystem().readFile(path2, "utf-8");
8951
+ async function readJsonFile(path) {
8952
+ const content = await getFileSystem().readFile(path, "utf-8");
8135
8953
  if (content === null)
8136
- throw new Error(`Local file not found: ${path2}`);
8954
+ throw new Error(`Local file not found: ${path}`);
8137
8955
  const [parseErr, parsed] = catchError(() => JSON.parse(String(content)));
8138
8956
  if (parseErr) {
8139
- throw new Error(`${path2} is not valid JSON: ${parseErr.message}`);
8957
+ throw new Error(`${path} is not valid JSON: ${parseErr.message}`);
8140
8958
  }
8141
8959
  return parsed;
8142
8960
  }
@@ -8182,7 +9000,7 @@ async function writeDashboards(config, appId, options) {
8182
9000
  }
8183
9001
  function registerModelDashboardCommands(modelCmd) {
8184
9002
  const dashboardsCmd = modelCmd.command("dashboards").description("List and edit the app's dashboards — the 'view' section of the " + "model, one dashboard at a time");
8185
- dashboardsCmd.command("list <app-id>").description("List the dashboards of a process app").addOption(new Option("--stage <stage>", "App stage to read from").choices(STAGES).default("dev")).examples(DASHBOARDS_LIST_EXAMPLES).trackedAction(processContext, async (appId, options) => {
9003
+ dashboardsCmd.command("list <app-id>").description("List the dashboards of a process app").addOption(new Option2("--stage <stage>", "App stage to read from").choices(STAGES).default("dev")).examples(DASHBOARDS_LIST_EXAMPLES).trackedAction(processContext, async (appId, options) => {
8186
9004
  const config = await loadConfigOrExit();
8187
9005
  if (!config)
8188
9006
  return;
@@ -8204,7 +9022,7 @@ function registerModelDashboardCommands(modelCmd) {
8204
9022
  }))
8205
9023
  });
8206
9024
  });
8207
- dashboardsCmd.command("get <app-id>").description("Get the dashboards of a process app, with the ETag to pass back " + "to 'update'").addOption(new Option("--stage <stage>", "App stage").choices(STAGES).default("dev")).option("--dashboard <id-or-name>", "Return only this dashboard instead of the whole view section").option("--destination <local-file>", "Write the JSON to this local file instead of the output envelope").examples(DASHBOARDS_GET_EXAMPLES).trackedAction(processContext, async (appId, options) => {
9025
+ dashboardsCmd.command("get <app-id>").description("Get the dashboards of a process app, with the ETag to pass back " + "to 'update'").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES).default("dev")).option("--dashboard <id-or-name>", "Return only this dashboard instead of the whole view section").option("--destination <local-file>", "Write the JSON to this local file instead of the output envelope").examples(DASHBOARDS_GET_EXAMPLES).trackedAction(processContext, async (appId, options) => {
8208
9026
  const config = await loadConfigOrExit();
8209
9027
  if (!config)
8210
9028
  return;
@@ -8260,7 +9078,7 @@ function registerModelDashboardCommands(modelCmd) {
8260
9078
  });
8261
9079
  });
8262
9080
  const metricsCmd = modelCmd.command("metrics").description("List the app's metrics — what a chart can reference");
8263
- metricsCmd.command("list <app-id>").description("List the metrics a chart can reference, from the app's data model. " + "Add or replace one with 'apps model dashboards update --metrics', " + "which writes it in the same request as the chart that uses it.").addOption(new Option("--stage <stage>", "App stage to read from").choices(STAGES).default("dev")).trackedAction(processContext, async (appId, options) => {
9081
+ metricsCmd.command("list <app-id>").description("List the metrics a chart can reference, from the app's data model. " + "Add or replace one with 'apps model dashboards update --metrics', " + "which writes it in the same request as the chart that uses it.").addOption(new Option2("--stage <stage>", "App stage to read from").choices(STAGES).default("dev")).trackedAction(processContext, async (appId, options) => {
8264
9082
  const config = await loadConfigOrExit();
8265
9083
  if (!config)
8266
9084
  return;
@@ -8391,9 +9209,9 @@ var APPS_GET_EXAMPLES = [
8391
9209
  }
8392
9210
  }
8393
9211
  ];
8394
- function registerAppsCommand(program2) {
8395
- const appsCmd = program2.command("apps").description("Manage Process Mining process apps");
8396
- appsCmd.command("list").description("List process apps").addOption(new Option("--stage <stage>", "App stage to list").choices(STAGES2).default("dev")).examples(APPS_LIST_EXAMPLES).trackedAction(processContext, async (options) => {
9212
+ function registerAppsCommand(program) {
9213
+ const appsCmd = program.command("apps").description("Manage Process Mining process apps");
9214
+ appsCmd.command("list").description("List process apps").addOption(new Option2("--stage <stage>", "App stage to list").choices(STAGES2).default("dev")).examples(APPS_LIST_EXAMPLES).trackedAction(processContext, async (options) => {
8397
9215
  const config = await loadConfigOrExit();
8398
9216
  if (!config)
8399
9217
  return;
@@ -8408,7 +9226,7 @@ function registerAppsCommand(program2) {
8408
9226
  Data: unwrapData(result)
8409
9227
  });
8410
9228
  });
8411
- appsCmd.command("get <app-id>").description("Get one process app: its status, last ingestion and build state").addOption(new Option("--stage <stage>", "App stage to read").choices(STAGES2).default("dev")).examples(APPS_GET_EXAMPLES).trackedAction(processContext, async (appId, options) => {
9229
+ appsCmd.command("get <app-id>").description("Get one process app: its status, last ingestion and build state").addOption(new Option2("--stage <stage>", "App stage to read").choices(STAGES2).default("dev")).examples(APPS_GET_EXAMPLES).trackedAction(processContext, async (appId, options) => {
8412
9230
  const config = await loadConfigOrExit();
8413
9231
  if (!config)
8414
9232
  return;
@@ -8423,7 +9241,7 @@ function registerAppsCommand(program2) {
8423
9241
  Data: unwrapData(result)
8424
9242
  });
8425
9243
  });
8426
- appsCmd.command("create <name>").description("Create a process app from an app template").requiredOption("--type <app-type-key>", "App template key (uip pm app-types list), e.g. 'uipath.custom'").option("--type-version <version>", "App template version; defaults to the latest available").addOption(new Option("--miner <miner>", "Process miner").choices(MINERS).default("directly-follows")).option("--description <text>", "App description").option("--data-mapping <json-file>", "Path to a JSON file with the input data mapping (tables/fields)").examples(APPS_CREATE_EXAMPLES).trackedAction(processContext, async (name, options) => {
9244
+ appsCmd.command("create <name>").description("Create a process app from an app template").requiredOption("--type <app-type-key>", "App template key (uip pm app-types list), e.g. 'uipath.custom'").option("--type-version <version>", "App template version; defaults to the latest available").addOption(new Option2("--miner <miner>", "Process miner").choices(MINERS).default("directly-follows")).option("--description <text>", "App description").option("--data-mapping <json-file>", "Path to a JSON file with the input data mapping (tables/fields)").examples(APPS_CREATE_EXAMPLES).trackedAction(processContext, async (name, options) => {
8427
9245
  const config = await loadConfigOrExit();
8428
9246
  if (!config)
8429
9247
  return;
@@ -8516,13 +9334,13 @@ function registerAppsCommand(program2) {
8516
9334
  });
8517
9335
  });
8518
9336
  const dataModelCmd = appsCmd.command("data-model").description("Inspect and edit the app's structural data model — the table graph: " + "which tables exist, how they join to Cases (primary/foreign keys), " + "and which source column fills each process-mining role. For fields, " + "data kinds, calculated fields, metrics and dashboards use 'apps model'.");
8519
- dataModelCmd.command("get <app-id>").description("Get the app's structural data model (tables with their " + "primary/foreign keys and column roles — the shape `add-table` " + "edits). Returns the model's ETag for reference; `add-table` " + "takes no --etag because it re-reads and merges its own change.").addOption(new Option("--stage <stage>", "App stage").choices(STAGES2).default("dev")).option("--destination <local-file>", "Write the model JSON to this file instead of the output envelope").trackedAction(processContext, async (appId, options) => {
9337
+ dataModelCmd.command("get <app-id>").description("Get the app's structural data model (tables with their " + "primary/foreign keys and column roles — the shape `add-table` " + "edits). Returns the model's ETag for reference; `add-table` " + "takes no --etag because it re-reads and merges its own change.").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES2).default("dev")).option("--destination <local-file>", "Write the model JSON to this file instead of the output envelope").trackedAction(processContext, async (appId, options) => {
8520
9338
  const config = await loadConfigOrExit();
8521
9339
  if (!config)
8522
9340
  return;
8523
9341
  await getModelAndMaybeWrite(config, `/apps/${appId}/${options.stage}/dataModel`, appId, "PmAppsDataModelGet", options.destination);
8524
9342
  });
8525
- dataModelCmd.command("add-table <app-id>").description("Register a custom dbt model as a queryable data-model table so it " + "becomes queryable (the add-table pattern). Process Mining is " + "case-centric: a queryable table must be the Case root or link to " + "Cases, so give the table a foreign key to Cases (a nullable " + "Case_ID column is enough to loosely link a standalone analytical " + "table). Re-ingest afterwards to materialize it.").requiredOption("--file <json-file>", "JSON with the table(s) to add — a single data-model table, an array, " + "or a { tables } object. Each: { name, primaryKey, foreignKeys: " + '[{ table: "Cases", column: "Case_ID" }] } (type defaults to "Object")').addOption(new Option("--stage <stage>", "App stage").choices(STAGES2).default("dev")).examples(APPS_DATA_MODEL_ADD_TABLE_EXAMPLES).trackedAction(processContext, async (appId, options) => {
9343
+ dataModelCmd.command("add-table <app-id>").description("Register a custom dbt model as a queryable data-model table so it " + "becomes queryable (the add-table pattern). Process Mining is " + "case-centric: a queryable table must be the Case root or link to " + "Cases, so give the table a foreign key to Cases (a nullable " + "Case_ID column is enough to loosely link a standalone analytical " + "table). Re-ingest afterwards to materialize it.").requiredOption("--file <json-file>", "JSON with the table(s) to add — a single data-model table, an array, " + "or a { tables } object. Each: { name, primaryKey, foreignKeys: " + '[{ table: "Cases", column: "Case_ID" }] } (type defaults to "Object")').addOption(new Option2("--stage <stage>", "App stage").choices(STAGES2).default("dev")).examples(APPS_DATA_MODEL_ADD_TABLE_EXAMPLES).trackedAction(processContext, async (appId, options) => {
8526
9344
  const config = await loadConfigOrExit();
8527
9345
  if (!config)
8528
9346
  return;
@@ -8543,7 +9361,7 @@ function registerAppsCommand(program2) {
8543
9361
  });
8544
9362
  });
8545
9363
  const modelCmd = appsCmd.command("model").description("Inspect and edit the app's model — fields and their data kinds, " + "calculated fields, metrics, and dashboards. Use the 'fields', " + "'dashboards' and 'metrics' subcommands for common edits, or " + "get/update for the whole model. (For the table graph / joins, " + "use 'apps data-model'.)");
8546
- modelCmd.command("get <app-id>").description("Get the app's model (fields with their data kinds, calculated " + "fields, metrics and the dashboards view) — the shape `update` " + "takes. Returns the model's ETag, which `model update` requires " + "as --etag: it is what proves the edit was based on this version.").addOption(new Option("--stage <stage>", "App stage").choices(STAGES2).default("dev")).option("--destination <local-file>", "Write the model JSON to this file instead of the output envelope").trackedAction(processContext, async (appId, options) => {
9364
+ modelCmd.command("get <app-id>").description("Get the app's model (fields with their data kinds, calculated " + "fields, metrics and the dashboards view) — the shape `update` " + "takes. Returns the model's ETag, which `model update` requires " + "as --etag: it is what proves the edit was based on this version.").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES2).default("dev")).option("--destination <local-file>", "Write the model JSON to this file instead of the output envelope").trackedAction(processContext, async (appId, options) => {
8547
9365
  const config = await loadConfigOrExit();
8548
9366
  if (!config)
8549
9367
  return;
@@ -8569,7 +9387,7 @@ function registerAppsCommand(program2) {
8569
9387
  });
8570
9388
  });
8571
9389
  const fieldsCmd = modelCmd.command("fields").description("List and edit the app's fields (both mapped columns and calculated " + "fields) — including changing a field's data kind");
8572
- fieldsCmd.command("list <app-id>").description("List every field across the app's tables with its data kind and " + "whether it is a mapped column or a calculated field").addOption(new Option("--stage <stage>", "App stage").choices(STAGES2).default("dev")).trackedAction(processContext, async (appId, options) => {
9390
+ fieldsCmd.command("list <app-id>").description("List every field across the app's tables with its data kind and " + "whether it is a mapped column or a calculated field").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES2).default("dev")).trackedAction(processContext, async (appId, options) => {
8573
9391
  const config = await loadConfigOrExit();
8574
9392
  if (!config)
8575
9393
  return;
@@ -8584,7 +9402,7 @@ function registerAppsCommand(program2) {
8584
9402
  Data: flattenModelFields(JSON.parse(file.content))
8585
9403
  });
8586
9404
  });
8587
- fieldsCmd.command("set <app-id> <field-id>").description("Create or edit a field (ETag-safe). Change its data kind " + "(--kind, e.g. numeric→duration), rename it (--display-name), or " + "make/edit a calculated field (--expression). Creating a field needs --table.").addOption(new Option("--kind <kind>", "Data kind for the field").choices(DATA_KINDS)).option("--display-name <text>", "Display name shown in the UI").option("--expression <json>", "Calculated-field expression as a JSON node (inline, or @file.json). " + "Providing it turns the field into a calculated field.").option("--table <table-id>", "Target table id — required only when creating a new field").trackedAction(processContext, async (appId, fieldId, options) => {
9405
+ fieldsCmd.command("set <app-id> <field-id>").description("Create or edit a field (ETag-safe). Change its data kind " + "(--kind, e.g. numeric→duration), rename it (--display-name), or " + "make/edit a calculated field (--expression). Creating a field needs --table.").addOption(new Option2("--kind <kind>", "Data kind for the field").choices(DATA_KINDS)).option("--display-name <text>", "Display name shown in the UI").option("--expression <json>", "Calculated-field expression as a JSON node (inline, or @file.json). " + "Providing it turns the field into a calculated field.").option("--table <table-id>", "Target table id — required only when creating a new field").trackedAction(processContext, async (appId, fieldId, options) => {
8588
9406
  const config = await loadConfigOrExit();
8589
9407
  if (!config)
8590
9408
  return;
@@ -8645,7 +9463,7 @@ function registerAppsCommand(program2) {
8645
9463
  });
8646
9464
  registerModelDashboardCommands(modelCmd);
8647
9465
  const dataMappingCmd = appsCmd.command("data-mapping").description("Read and replace the app's input data mapping (which source " + "table/column feeds which target field)");
8648
- dataMappingCmd.command("get <app-id>").description("Get the app's input data mapping — the same shape " + "`apps create --data-mapping` takes, so it can be edited and " + "pushed back with `data-mapping update`. Returns the mapping's " + "ETag, which that update requires as --etag: it is what proves " + "the edit was based on this version.").addOption(new Option("--stage <stage>", "App stage").choices(STAGES2).default("dev")).option("--destination <local-file>", "Write the mapping JSON to this file instead of the output envelope").examples(APPS_DATA_MAPPING_GET_EXAMPLES).trackedAction(processContext, async (appId, options) => {
9466
+ dataMappingCmd.command("get <app-id>").description("Get the app's input data mapping — the same shape " + "`apps create --data-mapping` takes, so it can be edited and " + "pushed back with `data-mapping update`. Returns the mapping's " + "ETag, which that update requires as --etag: it is what proves " + "the edit was based on this version.").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES2).default("dev")).option("--destination <local-file>", "Write the mapping JSON to this file instead of the output envelope").examples(APPS_DATA_MAPPING_GET_EXAMPLES).trackedAction(processContext, async (appId, options) => {
8649
9467
  const config = await loadConfigOrExit();
8650
9468
  if (!config)
8651
9469
  return;
@@ -8671,7 +9489,7 @@ function registerAppsCommand(program2) {
8671
9489
  }
8672
9490
  });
8673
9491
  });
8674
- dataMappingCmd.command("update <app-id>").description("Replace the app's input data mapping from a local JSON file " + "(ETag-safe) — fix a wrong mapping in place instead of " + "recreating the app. Pass the --etag that `data-mapping get` " + "returned for the version you edited. Applies on the next ingestion.").requiredOption("--file <json-file>", "Local JSON file with the full input data mapping " + '({ "Tables": [ … ] }) — replaces the stored mapping outright').requiredOption("--etag <etag>", "ETag of the mapping this edit is based on, as returned by " + "'uip pm apps data-mapping get'").addOption(new Option("--stage <stage>", "App stage (only 'dev' is writable)").choices(["dev"]).default("dev")).examples(APPS_DATA_MAPPING_UPDATE_EXAMPLES).trackedAction(processContext, async (appId, options) => {
9492
+ dataMappingCmd.command("update <app-id>").description("Replace the app's input data mapping from a local JSON file " + "(ETag-safe) — fix a wrong mapping in place instead of " + "recreating the app. Pass the --etag that `data-mapping get` " + "returned for the version you edited. Applies on the next ingestion.").requiredOption("--file <json-file>", "Local JSON file with the full input data mapping " + '({ "Tables": [ … ] }) — replaces the stored mapping outright').requiredOption("--etag <etag>", "ETag of the mapping this edit is based on, as returned by " + "'uip pm apps data-mapping get'").addOption(new Option2("--stage <stage>", "App stage (only 'dev' is writable)").choices(["dev"]).default("dev")).examples(APPS_DATA_MAPPING_UPDATE_EXAMPLES).trackedAction(processContext, async (appId, options) => {
8675
9493
  const config = await loadConfigOrExit();
8676
9494
  if (!config)
8677
9495
  return;
@@ -8709,8 +9527,8 @@ async function createApp(config, name, options) {
8709
9527
  }
8710
9528
  let dataMapping;
8711
9529
  if (options.dataMapping !== undefined) {
8712
- const fs2 = getFileSystem();
8713
- const raw = await fs2.readFile(options.dataMapping, "utf-8");
9530
+ const fs = getFileSystem();
9531
+ const raw = await fs.readFile(options.dataMapping, "utf-8");
8714
9532
  if (raw === null) {
8715
9533
  throw new Error(`Data mapping file not found: ${options.dataMapping}`);
8716
9534
  }
@@ -8779,8 +9597,8 @@ async function addModelTables(config, appId, options) {
8779
9597
  throw new Error(`Table file not found: ${options.file}`);
8780
9598
  }
8781
9599
  const extra = JSON.parse(String(raw));
8782
- const path2 = `/apps/${appId}/${options.stage}/dataModel`;
8783
- const current = await pmGetRaw(config, path2);
9600
+ const path = `/apps/${appId}/${options.stage}/dataModel`;
9601
+ const current = await pmGetRaw(config, path);
8784
9602
  if (!current.etag) {
8785
9603
  throw new Error(`The data model of app ${appId} was returned without an ETag, so the update cannot be guarded against concurrent edits.`);
8786
9604
  }
@@ -8789,12 +9607,12 @@ async function addModelTables(config, appId, options) {
8789
9607
  if (added.length === 0) {
8790
9608
  throw new Error(`No tables found in ${options.file}: expected a data-model table { name, primaryKey, foreignKeys }, an array of them, or a { tables } object.`);
8791
9609
  }
8792
- await pmPutJson(config, path2, dataModel, current.etag);
9610
+ await pmPutJson(config, path, dataModel, current.etag);
8793
9611
  await pmPost(config, `/apps/${appId}/${options.stage}/applyCurrentDatamodel`, {});
8794
9612
  return added;
8795
9613
  }
8796
- async function getModelAndMaybeWrite(config, path2, appId, code, destination) {
8797
- const [err, file] = await catchError(pmGetRaw(config, path2));
9614
+ async function getModelAndMaybeWrite(config, path, appId, code, destination) {
9615
+ const [err, file] = await catchError(pmGetRaw(config, path));
8798
9616
  if (err) {
8799
9617
  fail(err.message, "Check the app id (uip pm apps list).");
8800
9618
  return;
@@ -8926,14 +9744,14 @@ function removeModelField(model, fieldId) {
8926
9744
  throw new Error(`Field '${fieldId}' not found (see 'uip pm apps model fields list').`);
8927
9745
  }
8928
9746
  async function editSemanticModel(config, appId, mutate) {
8929
- const path2 = `/apps/${appId}/dev/model`;
8930
- const current = await pmGetRaw(config, path2);
9747
+ const path = `/apps/${appId}/dev/model`;
9748
+ const current = await pmGetRaw(config, path);
8931
9749
  if (!current.etag) {
8932
9750
  throw new Error(`The model of app ${appId} was returned without an ETag, so the edit cannot be guarded against concurrent changes.`);
8933
9751
  }
8934
9752
  const model = JSON.parse(current.content);
8935
9753
  const result = mutate(model);
8936
- const put = await pmPutJson(config, path2, model, current.etag);
9754
+ const put = await pmPutJson(config, path, model, current.etag);
8937
9755
  return { result, versions: put?.versions ?? [] };
8938
9756
  }
8939
9757
  async function updateSemanticModel(config, appId, options) {
@@ -9105,8 +9923,8 @@ var DEVIATIONS_EXAMPLES = [
9105
9923
  }
9106
9924
  }
9107
9925
  ];
9108
- function registerConformanceCommand(program2) {
9109
- const cmd = program2.command("conformance").description("A process app's conformance: the reference model it is measured against, the rate, per-activity and per-transition status, and the deviations");
9926
+ function registerConformanceCommand(program) {
9927
+ const cmd = program.command("conformance").description("A process app's conformance: the reference model it is measured against, the rate, per-activity and per-transition status, and the deviations");
9110
9928
  register(cmd, {
9111
9929
  name: "rate",
9112
9930
  summary: "Share of cases that follow the reference model",
@@ -9178,7 +9996,7 @@ function registerUploadModel(group) {
9178
9996
  });
9179
9997
  }
9180
9998
  function register(group, spec) {
9181
- group.command(`${spec.name} <app-id>`).description(spec.summary).option("--process-id <id>", "Process to report on; only needed for a multi-process app").addOption(new Option("--stage <stage>", "App stage").choices(STAGES3).default("dev")).examples(spec.examples).trackedAction(processContext, async (appId, options) => {
9999
+ group.command(`${spec.name} <app-id>`).description(spec.summary).option("--process-id <id>", "Process to report on; only needed for a multi-process app").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES3).default("dev")).examples(spec.examples).trackedAction(processContext, async (appId, options) => {
9182
10000
  const config = await loadConfigOrExit();
9183
10001
  if (!config)
9184
10002
  return;
@@ -9442,9 +10260,9 @@ var DEVIATIONS_DELETE_EXAMPLES = [
9442
10260
  }
9443
10261
  }
9444
10262
  ];
9445
- function registerDeviationsCommand(program2) {
9446
- const devCmd = program2.command("deviations").description("Manage the deviations accepted on a process app: list, accept, delete");
9447
- devCmd.command("list <app-id>").description("List the accepted deviations and whether the last ingestion has them applied").addOption(processIdOption()).addOption(new Option("--stage <stage>", "App stage").choices(STAGES4).default("dev")).examples(DEVIATIONS_LIST_EXAMPLES).trackedAction(processContext, async (appId, options) => {
10263
+ function registerDeviationsCommand(program) {
10264
+ const devCmd = program.command("deviations").description("Manage the deviations accepted on a process app: list, accept, delete");
10265
+ devCmd.command("list <app-id>").description("List the accepted deviations and whether the last ingestion has them applied").addOption(processIdOption()).addOption(new Option2("--stage <stage>", "App stage").choices(STAGES4).default("dev")).examples(DEVIATIONS_LIST_EXAMPLES).trackedAction(processContext, async (appId, options) => {
9448
10266
  const config = await loadConfigOrExit();
9449
10267
  if (!config)
9450
10268
  return;
@@ -9520,7 +10338,7 @@ function registerDeviationsCommand(program2) {
9520
10338
  });
9521
10339
  }
9522
10340
  function processIdOption() {
9523
- return new Option("--process-id <id>", "Process id (from 'uip pm query info'); only matters for a multi-process app").default(DEFAULT_PROCESS_ID);
10341
+ return new Option2("--process-id <id>", "Process id (from 'uip pm query info'); only matters for a multi-process app").default(DEFAULT_PROCESS_ID);
9524
10342
  }
9525
10343
  function deviationsPath(appId, options) {
9526
10344
  const stage = options.stage ?? "dev";
@@ -9570,9 +10388,9 @@ var FILES_UPLOAD_EXAMPLES = [
9570
10388
  }
9571
10389
  }
9572
10390
  ];
9573
- function registerFilesCommand(program2) {
9574
- const filesCmd = program2.command("files").description("Upload data files to a process app");
9575
- filesCmd.command("upload <app-id> <file-path>").description("Upload a data file to a process app via chunked blob upload").addOption(new Option("--stage <stage>", "App stage to upload to").choices(STAGES5).default("dev")).option("--input-table <name>", "Target input table the file belongs to (e.g. 'Event_log')").examples(FILES_UPLOAD_EXAMPLES).trackedAction(processContext, async (appId, filePath, options) => {
10391
+ function registerFilesCommand(program) {
10392
+ const filesCmd = program.command("files").description("Upload data files to a process app");
10393
+ filesCmd.command("upload <app-id> <file-path>").description("Upload a data file to a process app via chunked blob upload").addOption(new Option2("--stage <stage>", "App stage to upload to").choices(STAGES5).default("dev")).option("--input-table <name>", "Target input table the file belongs to (e.g. 'Event_log')").examples(FILES_UPLOAD_EXAMPLES).trackedAction(processContext, async (appId, filePath, options) => {
9576
10394
  const config = await loadConfigOrExit();
9577
10395
  if (!config)
9578
10396
  return;
@@ -9589,13 +10407,13 @@ function registerFilesCommand(program2) {
9589
10407
  });
9590
10408
  }
9591
10409
  async function uploadFile(config, appId, filePath, options) {
9592
- const fs2 = getFileSystem();
9593
- const bytes = await fs2.readFile(filePath);
10410
+ const fs = getFileSystem();
10411
+ const bytes = await fs.readFile(filePath);
9594
10412
  if (bytes === null) {
9595
10413
  throw new Error(`File not found: ${filePath}`);
9596
10414
  }
9597
10415
  const size = bytes.length;
9598
- const filename = fs2.path.basename(filePath);
10416
+ const filename = fs.path.basename(filePath);
9599
10417
  const startResponse = await pmPost(config, `/upload/${appId}/${options.stage}`, { filename, size, inputTable: options.inputTable });
9600
10418
  if (startResponse === null) {
9601
10419
  throw new Error("Start-upload returned an empty response.");
@@ -9707,9 +10525,9 @@ var INGESTIONS_LOGS_EXAMPLES = [
9707
10525
  }
9708
10526
  }
9709
10527
  ];
9710
- function registerIngestionsCommand(program2) {
9711
- const ingestionsCmd = program2.command("ingestions").description("Trigger and inspect data ingestions of a process app");
9712
- ingestionsCmd.command("create <app-id>").description("Trigger an ingestion of the uploaded data files, or of the app " + "template's built-in demo sample data (--sample-data)").addOption(new Option("--stage <stage>", "App stage to ingest into").choices(STAGES6).default("dev")).addOption(new Option("--file-format <format>", "Data file format").choices(FILE_FORMATS).default("csv")).option("--field-delimiter <char>", "Field delimiter in the data files", ",").option("--quote-character <char>", "Quote character enclosing fields", '"').addOption(new Option("--encoding <encoding>", "File encoding").choices(ENCODINGS).default("utf-8")).addOption(new Option("--sample-data", "Ingest the demo sample data UiPath ships with the app template " + "instead of uploaded files (no 'files upload' needed). It is " + "not your data — never use it in an app meant to analyze real " + "data. Only for " + "templates whose 'app-types list' entry has " + "SampleDataAvailable: true").conflicts([
10528
+ function registerIngestionsCommand(program) {
10529
+ const ingestionsCmd = program.command("ingestions").description("Trigger and inspect data ingestions of a process app");
10530
+ ingestionsCmd.command("create <app-id>").description("Trigger an ingestion of the uploaded data files, or of the app " + "template's built-in demo sample data (--sample-data)").addOption(new Option2("--stage <stage>", "App stage to ingest into").choices(STAGES6).default("dev")).addOption(new Option2("--file-format <format>", "Data file format").choices(FILE_FORMATS).default("csv")).option("--field-delimiter <char>", "Field delimiter in the data files", ",").option("--quote-character <char>", "Quote character enclosing fields", '"').addOption(new Option2("--encoding <encoding>", "File encoding").choices(ENCODINGS).default("utf-8")).addOption(new Option2("--sample-data", "Ingest the demo sample data UiPath ships with the app template " + "instead of uploaded files (no 'files upload' needed). It is " + "not your data — never use it in an app meant to analyze real " + "data. Only for " + "templates whose 'app-types list' entry has " + "SampleDataAvailable: true").conflicts([
9713
10531
  "fileFormat",
9714
10532
  "fieldDelimiter",
9715
10533
  "quoteCharacter",
@@ -9763,7 +10581,7 @@ function registerIngestionsCommand(program2) {
9763
10581
  }
9764
10582
  });
9765
10583
  });
9766
- ingestionsCmd.command("cancel <app-id> <ingestion-id>").description("Cancel an ingestion that is still running").addOption(new Option("--stage <stage>", "App stage the ingestion runs on").choices(STAGES6).default("dev")).examples(INGESTIONS_CANCEL_EXAMPLES).trackedAction(processContext, async (appId, ingestionId, options) => {
10584
+ ingestionsCmd.command("cancel <app-id> <ingestion-id>").description("Cancel an ingestion that is still running").addOption(new Option2("--stage <stage>", "App stage the ingestion runs on").choices(STAGES6).default("dev")).examples(INGESTIONS_CANCEL_EXAMPLES).trackedAction(processContext, async (appId, ingestionId, options) => {
9767
10585
  const config = await loadConfigOrExit();
9768
10586
  if (!config)
9769
10587
  return;
@@ -9782,7 +10600,7 @@ function registerIngestionsCommand(program2) {
9782
10600
  }
9783
10601
  });
9784
10602
  });
9785
- ingestionsCmd.command("logs <app-id> <ingestion-id>").description("Get the logs of an ingestion run").addOption(new Option("--stage <stage>", "App stage the ingestion ran on").choices(STAGES6).default("dev")).option("--limit <number>", "Max log entries to fetch (page size)", "100").option("--offset <number>", "Number of log entries to skip before the page", "0").examples(INGESTIONS_LOGS_EXAMPLES).trackedAction(processContext, async (appId, ingestionId, options) => {
10603
+ ingestionsCmd.command("logs <app-id> <ingestion-id>").description("Get the logs of an ingestion run").addOption(new Option2("--stage <stage>", "App stage the ingestion ran on").choices(STAGES6).default("dev")).option("--limit <number>", "Max log entries to fetch (page size)", "100").option("--offset <number>", "Number of log entries to skip before the page", "0").examples(INGESTIONS_LOGS_EXAMPLES).trackedAction(processContext, async (appId, ingestionId, options) => {
9786
10604
  const config = await loadConfigOrExit();
9787
10605
  if (!config)
9788
10606
  return;
@@ -9891,8 +10709,8 @@ var AGGREGATIONS = new Map([
9891
10709
  ["percentage", "PERCENTAGE"],
9892
10710
  ["sum", "SUM"]
9893
10711
  ]);
9894
- function registerQueryCommand(program2) {
9895
- const queryCmd = program2.command("query").description("Query a process app: aggregate data, details, RCA, insights, " + "percentiles, layout and query metadata");
10712
+ function registerQueryCommand(program) {
10713
+ const queryCmd = program.command("query").description("Query a process app: aggregate data, details, RCA, insights, " + "percentiles, layout and query metadata");
9896
10714
  registerBodyQuery(queryCmd, {
9897
10715
  name: "run",
9898
10716
  subpath: "",
@@ -9924,7 +10742,7 @@ function registerQueryCommand(program2) {
9924
10742
  summary: "Run process insights (body needs 'processId' and 1..10 'metrics')",
9925
10743
  withLimit: true
9926
10744
  });
9927
- queryCmd.command("info <app-id>").description("Get query metadata: the fields, metrics and processes available to build query bodies").addOption(new Option("--stage <stage>", "App stage").choices(STAGES7).default("dev")).examples(QUERY_INFO_EXAMPLES).trackedAction(processContext, async (appId, options) => {
10745
+ queryCmd.command("info <app-id>").description("Get query metadata: the fields, metrics and processes available to build query bodies").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES7).default("dev")).examples(QUERY_INFO_EXAMPLES).trackedAction(processContext, async (appId, options) => {
9928
10746
  const config = await loadConfigOrExit();
9929
10747
  if (!config)
9930
10748
  return;
@@ -9939,7 +10757,7 @@ function registerQueryCommand(program2) {
9939
10757
  Data: result
9940
10758
  });
9941
10759
  });
9942
- queryCmd.command("layout <app-id>").description("Get the persisted global graph layout of a process app").addOption(new Option("--type <type>", "Layout to read: the process 'graph' or the 'process-model'").choices(LAYOUT_TYPES).default("graph")).addOption(new Option("--stage <stage>", "App stage").choices(STAGES7).default("dev")).trackedAction(processContext, async (appId, options) => {
10760
+ queryCmd.command("layout <app-id>").description("Get the persisted global graph layout of a process app").addOption(new Option2("--type <type>", "Layout to read: the process 'graph' or the 'process-model'").choices(LAYOUT_TYPES).default("graph")).addOption(new Option2("--stage <stage>", "App stage").choices(STAGES7).default("dev")).trackedAction(processContext, async (appId, options) => {
9943
10761
  const config = await loadConfigOrExit();
9944
10762
  if (!config)
9945
10763
  return;
@@ -9955,7 +10773,7 @@ function registerQueryCommand(program2) {
9955
10773
  Data: result
9956
10774
  });
9957
10775
  });
9958
- queryCmd.command("percentile <app-id>").description("Compute percentiles of a numeric field").requiredOption("--field <field-id>", "Field id to compute percentiles over (uip pm query info)").requiredOption("--values <list>", "Comma-separated percentile points in 0..1, e.g. '0.5,0.9,0.95'").option("--filters <json-file>", "Path to a JSON file with a filter spec (array of AND-ed filter groups)").option("--filters-json <json>", "Inline JSON filter spec").addOption(new Option("--stage <stage>", "App stage").choices(STAGES7).default("dev")).examples(QUERY_PERCENTILE_EXAMPLES).trackedAction(processContext, async (appId, options) => {
10776
+ queryCmd.command("percentile <app-id>").description("Compute percentiles of a numeric field").requiredOption("--field <field-id>", "Field id to compute percentiles over (uip pm query info)").requiredOption("--values <list>", "Comma-separated percentile points in 0..1, e.g. '0.5,0.9,0.95'").option("--filters <json-file>", "Path to a JSON file with a filter spec (array of AND-ed filter groups)").option("--filters-json <json>", "Inline JSON filter spec").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES7).default("dev")).examples(QUERY_PERCENTILE_EXAMPLES).trackedAction(processContext, async (appId, options) => {
9959
10777
  const config = await loadConfigOrExit();
9960
10778
  if (!config)
9961
10779
  return;
@@ -9972,12 +10790,12 @@ function registerQueryCommand(program2) {
9972
10790
  OutputFormatter.success({
9973
10791
  Result: "Success",
9974
10792
  Code: "PmQueryPercentile",
9975
- Data: result
10793
+ Data: emptyBodyAsData(result)
9976
10794
  });
9977
10795
  });
9978
10796
  }
9979
10797
  function registerBodyQuery(queryCmd, spec) {
9980
- const cmd = queryCmd.command(`${spec.name} <app-id>`).description(spec.summary).option("--body <json-file>", "Path to a JSON file with the request body").option("--body-json <json>", "Inline JSON request body").addOption(new Option("--stage <stage>", "App stage").choices(STAGES7).default("dev"));
10798
+ const cmd = queryCmd.command(`${spec.name} <app-id>`).description(spec.summary).option("--body <json-file>", "Path to a JSON file with the request body").option("--body-json <json>", "Inline JSON request body").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES7).default("dev"));
9981
10799
  if (spec.withLimit) {
9982
10800
  cmd.option("--limit <n>", "Max rows to return (server clamps to 1..1000)");
9983
10801
  }
@@ -10006,7 +10824,7 @@ function registerBodyQuery(queryCmd, spec) {
10006
10824
  OutputFormatter.success({
10007
10825
  Result: "Success",
10008
10826
  Code: spec.code,
10009
- Data: reshape ? reshapeAggregate(result, reshape.groupCols, reshape.groupIds, reshape.metrics) : result
10827
+ Data: emptyBodyAsData(reshape ? reshapeAggregate(result, reshape.groupCols, reshape.groupIds, reshape.metrics) : result)
10010
10828
  });
10011
10829
  });
10012
10830
  }
@@ -10040,13 +10858,13 @@ async function buildAggregateBody(config, appId, options) {
10040
10858
  if (!config)
10041
10859
  return null;
10042
10860
  const info = await pmGet(config, `/query/${appId}/${options.stage}/info`);
10043
- const resolve2 = buildFieldResolver(info);
10861
+ const resolve = buildFieldResolver(info);
10044
10862
  const groupCols = (options.groupBy ?? "").split(",").map((s) => s.trim()).filter((s) => s.length > 0);
10045
- const groupIds = groupCols.map(resolve2);
10863
+ const groupIds = groupCols.map(resolve);
10046
10864
  const metrics = (options.metric ?? []).map(parseMetricSpec);
10047
10865
  const aggregates = metrics.map((m) => ({
10048
10866
  id: m.alias,
10049
- argument: resolve2(m.column),
10867
+ argument: resolve(m.column),
10050
10868
  aggregation: m.fn
10051
10869
  }));
10052
10870
  if (groupIds.length === 0 && aggregates.length === 0) {
@@ -10098,6 +10916,9 @@ function buildFieldResolver(info) {
10098
10916
  throw new Error(`Unknown field '${name}'. List available fields with 'uip pm query info'.`);
10099
10917
  };
10100
10918
  }
10919
+ function emptyBodyAsData(result) {
10920
+ return result;
10921
+ }
10101
10922
  function reshapeAggregate(result, groupCols, groupIds, metrics) {
10102
10923
  if (result === null || typeof result !== "object")
10103
10924
  return result;
@@ -10105,14 +10926,14 @@ function reshapeAggregate(result, groupCols, groupIds, metrics) {
10105
10926
  const keyMap = new Map;
10106
10927
  for (const k of Object.keys(data))
10107
10928
  keyMap.set(sanitizeKey(k), k);
10108
- const cell2 = (id) => {
10929
+ const cell = (id) => {
10109
10930
  const k = keyMap.get(sanitizeKey(id));
10110
10931
  return k ? data[k] : undefined;
10111
10932
  };
10112
10933
  const valuesOf = (c) => field(c ?? {}, "values") ?? [];
10113
10934
  const ungroupedOf = (c) => field(c ?? {}, "ungrouped") ?? null;
10114
- const groupCells = groupIds.map((id) => cell2(id));
10115
- const metricCells = metrics.map((m) => cell2(m.alias));
10935
+ const groupCells = groupIds.map((id) => cell(id));
10936
+ const metricCells = metrics.map((m) => cell(m.alias));
10116
10937
  if (groupCols.length === 0) {
10117
10938
  const totals = {};
10118
10939
  metrics.forEach((m, i) => {
@@ -10137,15 +10958,15 @@ function reshapeAggregate(result, groupCols, groupIds, metrics) {
10137
10958
  return rows;
10138
10959
  }
10139
10960
  async function buildPercentileBody(options) {
10140
- const values2 = options.values.split(",").map((s) => s.trim()).filter((s) => s.length > 0).map(Number);
10141
- if (values2.length === 0 || values2.some((v) => !Number.isFinite(v))) {
10961
+ const values = options.values.split(",").map((s) => s.trim()).filter((s) => s.length > 0).map(Number);
10962
+ if (values.length === 0 || values.some((v) => !Number.isFinite(v))) {
10142
10963
  throw new Error(`Invalid --values '${options.values}': expected comma-separated numbers.`);
10143
10964
  }
10144
10965
  let filters = [];
10145
10966
  if (options.filters !== undefined || options.filtersJson !== undefined) {
10146
10967
  filters = await resolveJsonBody(options.filters, options.filtersJson, "filters");
10147
10968
  }
10148
- return { field: options.field, values: values2, filters };
10969
+ return { field: options.field, values, filters };
10149
10970
  }
10150
10971
 
10151
10972
  // src/commands/simulations.ts
@@ -10174,9 +10995,9 @@ var SIMULATIONS_LIST_EXAMPLES = [
10174
10995
  }
10175
10996
  }
10176
10997
  ];
10177
- function registerSimulationsCommand(program2) {
10178
- const simulationsCmd = program2.command("simulations").description("Read the process simulations (what-if scenarios) saved on a process app");
10179
- simulationsCmd.command("list <app-id>").description("List the simulations saved on a process app stage").addOption(new Option("--stage <stage>", "App stage").choices(STAGES8).default("dev")).examples(SIMULATIONS_LIST_EXAMPLES).trackedAction(processContext, async (appId, options) => {
10998
+ function registerSimulationsCommand(program) {
10999
+ const simulationsCmd = program.command("simulations").description("Read the process simulations (what-if scenarios) saved on a process app");
11000
+ simulationsCmd.command("list <app-id>").description("List the simulations saved on a process app stage").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES8).default("dev")).examples(SIMULATIONS_LIST_EXAMPLES).trackedAction(processContext, async (appId, options) => {
10180
11001
  const config = await loadConfigOrExit();
10181
11002
  if (!config)
10182
11003
  return;
@@ -10248,9 +11069,9 @@ var TRANSFORMATIONS_APPLY_EXAMPLES = [
10248
11069
  }
10249
11070
  }
10250
11071
  ];
10251
- function registerTransformationsCommand(program2) {
10252
- const transformationsCmd = program2.command("transformations").description("Work with the dbt SQL transformations of a process app");
10253
- transformationsCmd.command("list <app-id>").description("List the transformation files of a process app").addOption(new Option("--stage <stage>", "App stage to read from").choices(STAGES9).default("dev")).trackedAction(processContext, async (appId, options) => {
11072
+ function registerTransformationsCommand(program) {
11073
+ const transformationsCmd = program.command("transformations").description("Work with the dbt SQL transformations of a process app");
11074
+ transformationsCmd.command("list <app-id>").description("List the transformation files of a process app").addOption(new Option2("--stage <stage>", "App stage to read from").choices(STAGES9).default("dev")).trackedAction(processContext, async (appId, options) => {
10254
11075
  const config = await loadConfigOrExit();
10255
11076
  if (!config)
10256
11077
  return;
@@ -10265,11 +11086,11 @@ function registerTransformationsCommand(program2) {
10265
11086
  Data: result
10266
11087
  });
10267
11088
  });
10268
- transformationsCmd.command("get <app-id> <path>").description("Get the content of a transformation file, plus its ETag — which " + "`update` requires as --etag: it is what proves the edit was " + "based on this version").addOption(new Option("--stage <stage>", "App stage").choices(STAGES9).default("dev")).option("--destination <local-file>", "Write content to this local file instead of the output envelope").trackedAction(processContext, async (appId, path2, options) => {
11089
+ transformationsCmd.command("get <app-id> <path>").description("Get the content of a transformation file, plus its ETag — which " + "`update` requires as --etag: it is what proves the edit was " + "based on this version").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES9).default("dev")).option("--destination <local-file>", "Write content to this local file instead of the output envelope").trackedAction(processContext, async (appId, path, options) => {
10269
11090
  const config = await loadConfigOrExit();
10270
11091
  if (!config)
10271
11092
  return;
10272
- const [err, file] = await catchError(pmGetFile(config, `/apps/${appId}/${options.stage}/transformation/tree/${path2}`));
11093
+ const [err, file] = await catchError(pmGetFile(config, `/apps/${appId}/${options.stage}/transformation/tree/${path}`));
10273
11094
  if (err) {
10274
11095
  fail(err.message, "Check the file path (uip pm transformations list).");
10275
11096
  return;
@@ -10285,28 +11106,28 @@ function registerTransformationsCommand(program2) {
10285
11106
  Result: "Success",
10286
11107
  Code: "PmTransformationsGet",
10287
11108
  Data: {
10288
- Path: path2,
11109
+ Path: path,
10289
11110
  ETag: file.etag,
10290
11111
  ...options.destination !== undefined ? { Destination: options.destination } : { Content: file.content }
10291
11112
  }
10292
11113
  });
10293
11114
  });
10294
- transformationsCmd.command("update <app-id> <path>").description("Update a transformation file from a local file (ETag-safe) — pass " + "the --etag that `get` returned for the version you edited, so a " + "concurrent change is refused instead of overwritten").requiredOption("--file <local-file>", "Local file with the new content").requiredOption("--etag <etag>", "ETag of the file this edit is based on, as returned by " + "'uip pm transformations get'").addOption(new Option("--stage <stage>", "App stage").choices(STAGES9).default("dev")).examples(TRANSFORMATIONS_UPDATE_EXAMPLES).trackedAction(processContext, async (appId, path2, options) => {
11115
+ transformationsCmd.command("update <app-id> <path>").description("Update a transformation file from a local file (ETag-safe) — pass " + "the --etag that `get` returned for the version you edited, so a " + "concurrent change is refused instead of overwritten").requiredOption("--file <local-file>", "Local file with the new content").requiredOption("--etag <etag>", "ETag of the file this edit is based on, as returned by " + "'uip pm transformations get'").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES9).default("dev")).examples(TRANSFORMATIONS_UPDATE_EXAMPLES).trackedAction(processContext, async (appId, path, options) => {
10295
11116
  const config = await loadConfigOrExit();
10296
11117
  if (!config)
10297
11118
  return;
10298
- const [err, etag] = await catchError(updateFile(config, appId, path2, options));
11119
+ const [err, etag] = await catchError(updateFile(config, appId, path, options));
10299
11120
  if (err) {
10300
- fail(err.message, isConflictError(err) ? conflictInstructions(`uip pm transformations get ${appId} ${path2} --destination <file>`) : "Check the file path, and that --etag is the ETag " + `'uip pm transformations get ${appId} ${path2}' returns.`);
11121
+ fail(err.message, isConflictError(err) ? conflictInstructions(`uip pm transformations get ${appId} ${path} --destination <file>`) : "Check the file path, and that --etag is the ETag " + `'uip pm transformations get ${appId} ${path}' returns.`);
10301
11122
  return;
10302
11123
  }
10303
11124
  OutputFormatter.success({
10304
11125
  Result: "Success",
10305
11126
  Code: "PmTransformationsUpdate",
10306
- Data: { Path: path2, ETag: etag }
11127
+ Data: { Path: path, ETag: etag }
10307
11128
  });
10308
11129
  });
10309
- transformationsCmd.command("create <app-id> <path>").description("Create a new transformation file from a local file " + "(use 'update' to modify an existing one)").requiredOption("--file <local-file>", "Local file with the new content").addOption(new Option("--stage <stage>", "App stage").choices(STAGES9).default("dev")).examples(TRANSFORMATIONS_CREATE_EXAMPLES).trackedAction(processContext, async (appId, path2, options) => {
11130
+ transformationsCmd.command("create <app-id> <path>").description("Create a new transformation file from a local file " + "(use 'update' to modify an existing one)").requiredOption("--file <local-file>", "Local file with the new content").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES9).default("dev")).examples(TRANSFORMATIONS_CREATE_EXAMPLES).trackedAction(processContext, async (appId, path, options) => {
10310
11131
  const config = await loadConfigOrExit();
10311
11132
  if (!config)
10312
11133
  return;
@@ -10315,7 +11136,7 @@ function registerTransformationsCommand(program2) {
10315
11136
  fail(`Local file not found: ${options.file}`, "Check the --file path.");
10316
11137
  return;
10317
11138
  }
10318
- const [err, etag] = await catchError(pmCreateRaw(config, `/apps/${appId}/${options.stage}/transformation/tree/${path2}?type=File`, String(content)));
11139
+ const [err, etag] = await catchError(pmCreateRaw(config, `/apps/${appId}/${options.stage}/transformation/tree/${path}?type=File`, String(content)));
10319
11140
  if (err) {
10320
11141
  fail(err.message, "Check the app id and that the path does not already exist (use 'update' to modify an existing file).");
10321
11142
  return;
@@ -10323,10 +11144,10 @@ function registerTransformationsCommand(program2) {
10323
11144
  OutputFormatter.success({
10324
11145
  Result: "Success",
10325
11146
  Code: "PmTransformationsCreate",
10326
- Data: { Path: path2, ETag: etag }
11147
+ Data: { Path: path, ETag: etag }
10327
11148
  });
10328
11149
  });
10329
- transformationsCmd.command("run <app-id>").description("Run the dbt transformations on the dev stage").addOption(new Option("--stage <stage>", "App stage (only 'dev' supported)").choices(["dev"]).default("dev")).option("--model <model-path>", "Run only this model (e.g. 'models/Cases.sql') and its dependents").option("--wait", "Block until the build reaches a terminal state; exit non-zero on failure (auto-prints the dbt error)").option("--timeout <seconds>", "Max seconds to wait when --wait is set", "1800").option("--poll-interval <seconds>", "Seconds between status polls when --wait is set", "5").examples(TRANSFORMATIONS_RUN_EXAMPLES).trackedAction(processContext, async (appId, options) => {
11150
+ transformationsCmd.command("run <app-id>").description("Run the dbt transformations on the dev stage").addOption(new Option2("--stage <stage>", "App stage (only 'dev' supported)").choices(["dev"]).default("dev")).option("--model <model-path>", "Run only this model (e.g. 'models/Cases.sql') and its dependents").option("--wait", "Block until the build reaches a terminal state; exit non-zero on failure (auto-prints the dbt error)").option("--timeout <seconds>", "Max seconds to wait when --wait is set", "1800").option("--poll-interval <seconds>", "Seconds between status polls when --wait is set", "5").examples(TRANSFORMATIONS_RUN_EXAMPLES).trackedAction(processContext, async (appId, options) => {
10330
11151
  const config = await loadConfigOrExit();
10331
11152
  if (!config)
10332
11153
  return;
@@ -10372,7 +11193,7 @@ function registerTransformationsCommand(program2) {
10372
11193
  Data: { AppId: appId, Status: "Cancelling" }
10373
11194
  });
10374
11195
  });
10375
- transformationsCmd.command("apply <app-id>").description("Re-run the full data transformation on already-ingested data " + "(unlike 'run', which builds only changed dev models)").addOption(new Option("--stage <stage>", "App stage").choices(STAGES9).default("dev")).option("--wait", "Block until the transform reaches a terminal state; exit non-zero on failure (auto-prints the dbt error)").option("--timeout <seconds>", "Max seconds to wait when --wait is set", "1800").option("--poll-interval <seconds>", "Seconds between status polls when --wait is set", "5").examples(TRANSFORMATIONS_APPLY_EXAMPLES).trackedAction(processContext, async (appId, options) => {
11196
+ transformationsCmd.command("apply <app-id>").description("Re-run the full data transformation on already-ingested data " + "(unlike 'run', which builds only changed dev models)").addOption(new Option2("--stage <stage>", "App stage").choices(STAGES9).default("dev")).option("--wait", "Block until the transform reaches a terminal state; exit non-zero on failure (auto-prints the dbt error)").option("--timeout <seconds>", "Max seconds to wait when --wait is set", "1800").option("--poll-interval <seconds>", "Seconds between status polls when --wait is set", "5").examples(TRANSFORMATIONS_APPLY_EXAMPLES).trackedAction(processContext, async (appId, options) => {
10376
11197
  const config = await loadConfigOrExit();
10377
11198
  if (!config)
10378
11199
  return;
@@ -10434,33 +11255,33 @@ function registerTransformationsCommand(program2) {
10434
11255
  });
10435
11256
  });
10436
11257
  }
10437
- async function updateFile(config, appId, path2, options) {
11258
+ async function updateFile(config, appId, path, options) {
10438
11259
  const content = await getFileSystem().readFile(options.file, "utf-8");
10439
11260
  if (content === null) {
10440
11261
  throw new Error(`Local file not found: ${options.file}`);
10441
11262
  }
10442
- return pmPutRaw(config, `/apps/${appId}/${options.stage}/transformation/tree/${path2}?type=File`, String(content), options.etag);
11263
+ return pmPutRaw(config, `/apps/${appId}/${options.stage}/transformation/tree/${path}?type=File`, String(content), options.etag);
10443
11264
  }
10444
11265
 
10445
11266
  // src/tool.ts
10446
- var metadata = {
11267
+ var metadata2 = {
10447
11268
  name: "pm-tool",
10448
11269
  version: package_default.version,
10449
11270
  description: "Process Mining — process apps, transformations, and data ingestion.",
10450
11271
  commandPrefix: "pm"
10451
11272
  };
10452
- var registerCommands = async (program2) => {
10453
- registerAppsCommand(program2);
10454
- registerAppTypesCommand(program2);
10455
- registerConformanceCommand(program2);
10456
- registerDeviationsCommand(program2);
10457
- registerFilesCommand(program2);
10458
- registerIngestionsCommand(program2);
10459
- registerQueryCommand(program2);
10460
- registerSimulationsCommand(program2);
10461
- registerTransformationsCommand(program2);
11273
+ var registerCommands2 = async (program) => {
11274
+ registerAppsCommand(program);
11275
+ registerAppTypesCommand(program);
11276
+ registerConformanceCommand(program);
11277
+ registerDeviationsCommand(program);
11278
+ registerFilesCommand(program);
11279
+ registerIngestionsCommand(program);
11280
+ registerQueryCommand(program);
11281
+ registerSimulationsCommand(program);
11282
+ registerTransformationsCommand(program);
10462
11283
  };
10463
11284
 
10464
- export { Command, metadata, registerCommands };
11285
+ export { Command, metadata2, registerCommands2 };
10465
11286
 
10466
- //# debugId=95758F27C7D60D5264756E2164756E21
11287
+ //# debugId=4E7F7C50A256199064756E2164756E21