@uipath/coder-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"];
@@ -2077,28 +2078,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2077
2078
  exports.useColor = useColor;
2078
2079
  });
2079
2080
 
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
-
2100
2081
  // ../filesystem/src/node.ts
2101
- import { randomUUID } from "node:crypto";
2082
+ import { createHash, randomUUID } from "node:crypto";
2102
2083
  import { existsSync } from "node:fs";
2103
2084
  import * as fs from "node:fs/promises";
2104
2085
  import * as os from "node:os";
@@ -2109,6 +2090,9 @@ var LOCK_MAX_WAIT_MS = 20000;
2109
2090
  var LOCK_MAX_HOLD_MS = 60000;
2110
2091
  var LOCK_RETRY_MIN_MS = 100;
2111
2092
  var LOCK_RETRY_JITTER_MS = 200;
2093
+ var HASH_CHUNK_BYTES = 256 * 1024;
2094
+ var hashBuffers = [];
2095
+ var HASH_BUFFERS_KEPT = 64;
2112
2096
 
2113
2097
  class NodeFileSystem {
2114
2098
  path = {
@@ -2127,7 +2111,7 @@ class NodeFileSystem {
2127
2111
  };
2128
2112
  utils = {
2129
2113
  open: async (url) => {
2130
- const { default: open } = await import("./index-sby22td6.js");
2114
+ const { default: open } = await import("./index-nzr4mx5p.js");
2131
2115
  await open(url);
2132
2116
  }
2133
2117
  };
@@ -2166,6 +2150,15 @@ class NodeFileSystem {
2166
2150
  throw error;
2167
2151
  }
2168
2152
  }
2153
+ async readdirEntries(dirPath) {
2154
+ try {
2155
+ return await fs.readdir(dirPath, { withFileTypes: true });
2156
+ } catch (error) {
2157
+ if (this.isEnoent(error))
2158
+ return [];
2159
+ throw error;
2160
+ }
2161
+ }
2169
2162
  async stat(filePath) {
2170
2163
  try {
2171
2164
  const stats = await fs.stat(filePath);
@@ -2173,7 +2166,8 @@ class NodeFileSystem {
2173
2166
  isFile: () => stats.isFile(),
2174
2167
  isDirectory: () => stats.isDirectory(),
2175
2168
  size: stats.size,
2176
- mtimeMs: stats.mtimeMs
2169
+ mtimeMs: stats.mtimeMs,
2170
+ ctimeMs: stats.ctimeMs
2177
2171
  };
2178
2172
  } catch (error) {
2179
2173
  if (this.isEnoent(error))
@@ -2287,6 +2281,42 @@ class NodeFileSystem {
2287
2281
  throw error;
2288
2282
  }
2289
2283
  }
2284
+ async hashFile(filePath) {
2285
+ let handle;
2286
+ try {
2287
+ handle = await fs.open(filePath, "r");
2288
+ } catch (error) {
2289
+ if (this.isEnoent(error))
2290
+ return null;
2291
+ throw error;
2292
+ }
2293
+ const buffer = hashBuffers.pop() ?? Buffer.allocUnsafe(HASH_CHUNK_BYTES);
2294
+ try {
2295
+ const opened = await handle.stat();
2296
+ const stats = {
2297
+ isFile: () => opened.isFile(),
2298
+ isDirectory: () => opened.isDirectory(),
2299
+ size: opened.size,
2300
+ mtimeMs: opened.mtimeMs,
2301
+ ctimeMs: opened.ctimeMs
2302
+ };
2303
+ const hash = createHash("sha256");
2304
+ let size = 0;
2305
+ for (;; ) {
2306
+ const { bytesRead } = await handle.read(buffer, 0, buffer.byteLength, null);
2307
+ if (bytesRead === 0)
2308
+ break;
2309
+ hash.update(buffer.subarray(0, bytesRead));
2310
+ size += bytesRead;
2311
+ }
2312
+ return { sha256: hash.digest("hex"), size, stats };
2313
+ } finally {
2314
+ if (hashBuffers.length < HASH_BUFFERS_KEPT) {
2315
+ hashBuffers.push(buffer);
2316
+ }
2317
+ await handle.close();
2318
+ }
2319
+ }
2290
2320
  async realpath(filePath) {
2291
2321
  try {
2292
2322
  return await fs.realpath(filePath);
@@ -2337,6 +2367,208 @@ class NodeFileSystem {
2337
2367
  var fsInstance = new NodeFileSystem;
2338
2368
  var getFileSystem = () => fsInstance;
2339
2369
 
2370
+ // ../common/src/telemetry/telemetry-dimensions.ts
2371
+ var BaseDimensions = {
2372
+ ApplicationName: "ApplicationName",
2373
+ ProductVersion: "ProductVersion",
2374
+ InstallationId: "InstallationId",
2375
+ CloudUserId: "CloudUserId",
2376
+ CloudTenantId: "CloudTenantId",
2377
+ CloudOrganizationId: "CloudOrganizationId",
2378
+ IsInternalUser: "IsInternalUser",
2379
+ Environment: "Environment",
2380
+ BaseUrl: "BaseUrl",
2381
+ Region: "Region",
2382
+ Agent: "Agent",
2383
+ AgentVersion: "AgentVersion",
2384
+ AgentModel: "AgentModel",
2385
+ ToolName: "ToolName",
2386
+ ToolVersion: "ToolVersion",
2387
+ ExecutionContext: "ExecutionContext",
2388
+ CiProvider: "CiProvider",
2389
+ SessionIdSource: "SessionIdSource",
2390
+ SessionId: "SessionId"
2391
+ };
2392
+ var CommandDimensions = {
2393
+ IsCommand: "IsCommand",
2394
+ IsReexec: "IsReexec",
2395
+ CommandName: "CommandName",
2396
+ ExitCode: "ExitCode",
2397
+ TerminalOutcome: "TerminalOutcome",
2398
+ ErrorClass: "ErrorClass",
2399
+ TerminalSignal: "TerminalSignal",
2400
+ ErrorMessage: "ErrorMessage",
2401
+ SkillName: "SkillName",
2402
+ ProductArea: "ProductArea",
2403
+ Mode: "Mode"
2404
+ };
2405
+ var ProjectDimensions = {
2406
+ ProjectKey: "ProjectKey",
2407
+ ProjectType: "ProjectType",
2408
+ ProjectIdentityStatus: "ProjectIdentityStatus",
2409
+ SolutionKey: "SolutionKey",
2410
+ SolutionProjectKey: "SolutionProjectKey",
2411
+ SolutionIdentityStatus: "SolutionIdentityStatus",
2412
+ PreviousSolutionKey: "PreviousSolutionKey"
2413
+ };
2414
+ var GUID_KEY_DIMENSIONS = new Set([
2415
+ ProjectDimensions.ProjectKey,
2416
+ ProjectDimensions.SolutionKey,
2417
+ ProjectDimensions.SolutionProjectKey,
2418
+ ProjectDimensions.PreviousSolutionKey
2419
+ ]);
2420
+ var ShipDimensions = {
2421
+ ShipKind: "ShipKind",
2422
+ Target: "Target",
2423
+ ProjectType: "ProjectType",
2424
+ ProjectTypes: "ProjectTypes",
2425
+ ArtifactCorrelationKey: "ArtifactCorrelationKey",
2426
+ PackageName: "PackageName",
2427
+ PackageVersion: "PackageVersion",
2428
+ PackageVersionKey: "PackageVersionKey",
2429
+ DeploymentKey: "DeploymentKey",
2430
+ SolutionId: "SolutionId",
2431
+ FolderKey: "FolderKey",
2432
+ FeedId: "FeedId"
2433
+ };
2434
+ var ErrorDimensions = {
2435
+ Result: "Result",
2436
+ ErrorCode: "ErrorCode",
2437
+ Retry: "Retry",
2438
+ ErrorMessage: "ErrorMessage",
2439
+ HttpStatus: "HttpStatus",
2440
+ UpstreamErrorCode: "UpstreamErrorCode"
2441
+ };
2442
+ var AuthDimensions = {
2443
+ AuthenticationMethod: "AuthenticationMethod",
2444
+ Success: "Success",
2445
+ Reason: "Reason"
2446
+ };
2447
+ var SkillsDimensions = {
2448
+ SchemaVersion: "SchemaVersion",
2449
+ AgentType: "AgentType",
2450
+ SkillsVersion: "SkillsVersion",
2451
+ UipSubcommand: "UipSubcommand",
2452
+ FileExtension: "FileExtension",
2453
+ SubagentModel: "SubagentModel",
2454
+ SubagentType: "SubagentType",
2455
+ PermissionMode: "PermissionMode",
2456
+ EffortLevel: "EffortLevel",
2457
+ SessionSource: "SessionSource",
2458
+ Outcome: "Outcome",
2459
+ DurationMs: "DurationMs",
2460
+ Source: "Source"
2461
+ };
2462
+ var PackagerDimensions = {
2463
+ ProjectId: "ProjectId",
2464
+ ProjectType: "ProjectType",
2465
+ SolutionId: "SolutionId"
2466
+ };
2467
+ var ScopeDimensions = {
2468
+ FolderId: "FolderId"
2469
+ };
2470
+ var ID_DIMENSIONS = new Set([
2471
+ BaseDimensions.CloudUserId,
2472
+ BaseDimensions.CloudTenantId,
2473
+ BaseDimensions.CloudOrganizationId,
2474
+ BaseDimensions.InstallationId,
2475
+ ShipDimensions.ArtifactCorrelationKey,
2476
+ ShipDimensions.PackageVersionKey,
2477
+ ShipDimensions.DeploymentKey,
2478
+ ShipDimensions.SolutionId,
2479
+ ShipDimensions.FolderKey,
2480
+ ShipDimensions.FeedId,
2481
+ PackagerDimensions.ProjectId
2482
+ ]);
2483
+ var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
2484
+ var RESERVED_DIMENSION_NAMES = new Set([
2485
+ ...Object.values(BaseDimensions),
2486
+ ...Object.values(CommandDimensions),
2487
+ ...Object.values(ShipDimensions),
2488
+ ...Object.values(ProjectDimensions),
2489
+ ...Object.values(ErrorDimensions),
2490
+ ...Object.values(AuthDimensions),
2491
+ ...Object.values(SkillsDimensions),
2492
+ ...Object.values(PackagerDimensions),
2493
+ ...Object.values(ScopeDimensions)
2494
+ ]);
2495
+ var CURATED_DIMENSIONS = new Set([
2496
+ BaseDimensions.ApplicationName,
2497
+ BaseDimensions.ProductVersion,
2498
+ BaseDimensions.InstallationId,
2499
+ BaseDimensions.CloudUserId,
2500
+ BaseDimensions.CloudTenantId,
2501
+ BaseDimensions.CloudOrganizationId,
2502
+ BaseDimensions.IsInternalUser,
2503
+ BaseDimensions.Environment,
2504
+ BaseDimensions.BaseUrl,
2505
+ BaseDimensions.Region,
2506
+ BaseDimensions.Agent,
2507
+ BaseDimensions.AgentVersion,
2508
+ BaseDimensions.ToolVersion,
2509
+ BaseDimensions.ExecutionContext,
2510
+ BaseDimensions.CiProvider,
2511
+ BaseDimensions.SessionIdSource,
2512
+ BaseDimensions.SessionId,
2513
+ ...Object.values(CommandDimensions),
2514
+ ...Object.values(ShipDimensions),
2515
+ ...Object.values(ProjectDimensions)
2516
+ ]);
2517
+ function lowercaseIdDimensionValues(properties) {
2518
+ let changed = false;
2519
+ const result = {
2520
+ ...properties
2521
+ };
2522
+ for (const key of Object.keys(result)) {
2523
+ const value = result[key];
2524
+ if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
2525
+ continue;
2526
+ }
2527
+ const lowered = value.toLowerCase();
2528
+ if (lowered !== value) {
2529
+ result[key] = lowered;
2530
+ changed = true;
2531
+ }
2532
+ }
2533
+ return changed ? result : properties;
2534
+ }
2535
+
2536
+ // ../common/src/telemetry/project-identity.ts
2537
+ function projectKey(id) {
2538
+ if (typeof id !== "string")
2539
+ return;
2540
+ const key = id.trim().toLowerCase().replaceAll("-", "");
2541
+ return /^[0-9a-f]{32}$/.test(key) ? key : undefined;
2542
+ }
2543
+ function projectIdentityProperties(identity) {
2544
+ const key = identity.id ? projectKey(identity.id) : undefined;
2545
+ return {
2546
+ [ProjectDimensions.ProjectIdentityStatus]: identity.status === "resolved" && !key ? "invalid" : identity.status,
2547
+ [ProjectDimensions.ProjectType]: identity.projectType,
2548
+ ...identity.status === "resolved" && key ? {
2549
+ [ProjectDimensions.ProjectKey]: key
2550
+ } : {}
2551
+ };
2552
+ }
2553
+ var PROJECT_IDENTITY_LOOKUP_BUDGET_MS = 1000;
2554
+ async function withinProjectIdentityBudget(work, onTimeout) {
2555
+ work.catch(() => {
2556
+ return;
2557
+ });
2558
+ let timer;
2559
+ const expired = new Promise((resolve) => {
2560
+ timer = setTimeout(() => {
2561
+ onTimeout?.();
2562
+ resolve(undefined);
2563
+ }, PROJECT_IDENTITY_LOOKUP_BUDGET_MS);
2564
+ });
2565
+ try {
2566
+ return await Promise.race([work, expired]);
2567
+ } finally {
2568
+ clearTimeout(timer);
2569
+ }
2570
+ }
2571
+
2340
2572
  // ../common/src/telemetry/pseudonymize.ts
2341
2573
  var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2342
2574
  var PSEUDONYM_HEX_LENGTH = 32;
@@ -2705,8 +2937,8 @@ function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
2705
2937
  return `${redactUrl(core)}${trailing}`;
2706
2938
  });
2707
2939
  out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
2708
- out = out.replace(UNC_PATH_PATTERN, (_match, before, path2) => {
2709
- const [core, trailing] = peelTrailingPunctuation(path2);
2940
+ out = out.replace(UNC_PATH_PATTERN, (_match, before, path) => {
2941
+ const [core, trailing] = peelTrailingPunctuation(path);
2710
2942
  return `${before}unc#${pseudonymize(core)}${trailing}`;
2711
2943
  });
2712
2944
  out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
@@ -2800,6 +3032,8 @@ function redactProperty(name, value) {
2800
3032
  if (isSensitiveName(name)) {
2801
3033
  return REDACTED;
2802
3034
  }
3035
+ if (GUID_KEY_DIMENSIONS.has(name))
3036
+ return projectKey(value);
2803
3037
  if (typeof value === "boolean" || typeof value === "number") {
2804
3038
  return value;
2805
3039
  }
@@ -2874,6 +3108,63 @@ function settlePromiseLike(thenable) {
2874
3108
  return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
2875
3109
  }
2876
3110
 
3111
+ // ../common/src/error-codes.ts
3112
+ var CLI_ERROR_CODES = [
3113
+ "invalid_argument",
3114
+ "authentication_required",
3115
+ "permission_denied",
3116
+ "local_permission_denied",
3117
+ "not_found",
3118
+ "rate_limited",
3119
+ "network_error",
3120
+ "timeout",
3121
+ "server_error",
3122
+ "method_not_allowed",
3123
+ "not_supported",
3124
+ "configuration_error",
3125
+ "execution_failed",
3126
+ "unknown_error"
3127
+ ];
3128
+ var RETRY_HINTS = [
3129
+ "RetryWillNotFix",
3130
+ "RetryLater",
3131
+ "RetryAfter1Second",
3132
+ "RetryAfter10Seconds",
3133
+ "RetryAfter30Seconds",
3134
+ "RetryAfter60Seconds"
3135
+ ];
3136
+ var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
3137
+ var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
3138
+ function isCliErrorCode(value) {
3139
+ return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
3140
+ }
3141
+ function isRetryHint(value) {
3142
+ return typeof value === "string" && RETRY_HINT_VALUES.has(value);
3143
+ }
3144
+ function carriedErrorCode(error) {
3145
+ if (!error || typeof error !== "object")
3146
+ return;
3147
+ const code = error.errorCode;
3148
+ return isCliErrorCode(code) ? code : undefined;
3149
+ }
3150
+ function carriedRetry(error) {
3151
+ if (!error || typeof error !== "object")
3152
+ return;
3153
+ const retry = error.retry;
3154
+ return isRetryHint(retry) ? retry : undefined;
3155
+ }
3156
+ function defaultRetryForErrorCode(errorCode) {
3157
+ switch (errorCode) {
3158
+ case "network_error":
3159
+ case "rate_limited":
3160
+ case "server_error":
3161
+ case "timeout":
3162
+ return "RetryLater";
3163
+ default:
3164
+ return "RetryWillNotFix";
3165
+ }
3166
+ }
3167
+
2877
3168
  // ../common/src/error-graph.ts
2878
3169
  function* walkErrorGraph(error) {
2879
3170
  const queue = [error];
@@ -2918,17 +3209,58 @@ function findHttpStatusInGraph(error) {
2918
3209
  return;
2919
3210
  }
2920
3211
 
2921
- // ../common/src/local-permission-codes.ts
2922
- var LOCAL_PERMISSION_ERROR_CODES = new Set([
2923
- "EACCES",
2924
- "EPERM",
2925
- "EROFS"
2926
- ]);
2927
-
2928
- // ../common/src/error-handler.ts
2929
- var NETWORK_ERROR_CODES = new Set([
2930
- "ECONNREFUSED",
2931
- "ECONNRESET",
3212
+ // ../common/src/http-status.ts
3213
+ function classifyHttpStatus(status) {
3214
+ if (status === undefined)
3215
+ return;
3216
+ if (status === 400 || status === 409 || status === 413 || status === 422) {
3217
+ return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
3218
+ }
3219
+ if (status === 401) {
3220
+ return {
3221
+ errorCode: "authentication_required",
3222
+ retry: "RetryWillNotFix"
3223
+ };
3224
+ }
3225
+ if (status === 403) {
3226
+ return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
3227
+ }
3228
+ if (status === 404) {
3229
+ return { errorCode: "not_found", retry: "RetryWillNotFix" };
3230
+ }
3231
+ if (status === 405) {
3232
+ return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
3233
+ }
3234
+ if (status === 408) {
3235
+ return { errorCode: "timeout", retry: "RetryLater" };
3236
+ }
3237
+ if (status === 429) {
3238
+ return { errorCode: "rate_limited", retry: "RetryLater" };
3239
+ }
3240
+ if (status >= 500 && status < 600) {
3241
+ return { errorCode: "server_error", retry: "RetryLater" };
3242
+ }
3243
+ return;
3244
+ }
3245
+
3246
+ // ../common/src/local-permission-codes.ts
3247
+ var LOCAL_PERMISSION_ERROR_CODES = new Set([
3248
+ "EACCES",
3249
+ "EPERM",
3250
+ "EROFS"
3251
+ ]);
3252
+
3253
+ // ../common/src/error-handler.ts
3254
+ 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.";
3255
+ 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.";
3256
+ var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
3257
+ 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.";
3258
+ 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.";
3259
+ 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.";
3260
+ var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
3261
+ var NETWORK_ERROR_CODES = new Set([
3262
+ "ECONNREFUSED",
3263
+ "ECONNRESET",
2932
3264
  "ENOTFOUND",
2933
3265
  "EAI_AGAIN",
2934
3266
  "ETIMEDOUT",
@@ -2950,10 +3282,415 @@ var TLS_ERROR_CODES = new Set([
2950
3282
  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.";
2951
3283
  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.";
2952
3284
  var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
2953
- // ../common/src/exit-code.ts
2954
- function setExitCode(code) {
2955
- process.exitCode = code;
3285
+ function localPermissionInstructions(code, path) {
3286
+ const target = path !== undefined ? `'${path}'` : "a local file or resource";
3287
+ if (code === "EROFS") {
3288
+ 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.";
3289
+ }
3290
+ const onWindows = typeof process !== "undefined" && process.platform === "win32";
3291
+ 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.";
3292
+ 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}`;
3293
+ }
3294
+ function describeConnectivityError(error) {
3295
+ for (const cur of walkErrorGraph(error)) {
3296
+ const code = typeof cur.code === "string" ? cur.code : undefined;
3297
+ const message = typeof cur.message === "string" ? cur.message : undefined;
3298
+ if (code && TLS_ERROR_CODES.has(code)) {
3299
+ return {
3300
+ code,
3301
+ kind: "tls",
3302
+ message: message ?? code,
3303
+ instructions: TLS_INSTRUCTIONS
3304
+ };
3305
+ }
3306
+ if (code && NETWORK_ERROR_CODES.has(code)) {
3307
+ return {
3308
+ code,
3309
+ kind: "network",
3310
+ message: message ?? code,
3311
+ instructions: NETWORK_INSTRUCTIONS
3312
+ };
3313
+ }
3314
+ }
3315
+ return;
3316
+ }
3317
+ function describePermissionError(error) {
3318
+ for (const cur of walkErrorGraph(error)) {
3319
+ const message = typeof cur.message === "string" ? cur.message : undefined;
3320
+ const code = matchLocalPermissionCode(cur.code, message);
3321
+ if (!code)
3322
+ continue;
3323
+ const path = localPermissionPath(cur.path, message);
3324
+ return {
3325
+ code,
3326
+ message: message ?? code,
3327
+ ...path !== undefined ? { path } : {},
3328
+ instructions: localPermissionInstructions(code, path)
3329
+ };
3330
+ }
3331
+ return;
2956
3332
  }
3333
+ function matchLocalPermissionCode(code, message) {
3334
+ if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
3335
+ return code;
3336
+ }
3337
+ const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
3338
+ return match ? match[1] : undefined;
3339
+ }
3340
+ function localPermissionPath(path, message) {
3341
+ if (typeof path === "string")
3342
+ return path;
3343
+ return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
3344
+ }
3345
+ function readHeader(response, name) {
3346
+ const headers = response?.headers;
3347
+ if (!headers || typeof headers !== "object")
3348
+ return;
3349
+ if (typeof headers.get === "function") {
3350
+ const value = headers.get(name);
3351
+ if (value)
3352
+ return value;
3353
+ }
3354
+ const plain = headers;
3355
+ const key = Object.keys(plain).find((k) => k.toLowerCase() === name.toLowerCase());
3356
+ const value = key === undefined ? undefined : plain[key];
3357
+ return typeof value === "string" && value !== "" ? value : undefined;
3358
+ }
3359
+ function isHtmlDocument(body) {
3360
+ return /^\s*(<!doctype html|<html\b)/i.test(body);
3361
+ }
3362
+ function retryHintForRetryAfter(seconds) {
3363
+ if (seconds <= 1) {
3364
+ return "RetryAfter1Second";
3365
+ }
3366
+ if (seconds <= 10) {
3367
+ return "RetryAfter10Seconds";
3368
+ }
3369
+ if (seconds <= 30) {
3370
+ return "RetryAfter30Seconds";
3371
+ }
3372
+ return "RetryAfter60Seconds";
3373
+ }
3374
+ function classifyError(status, error) {
3375
+ const byStatus = classifyHttpStatus(status);
3376
+ if (byStatus)
3377
+ return byStatus;
3378
+ if (status === undefined && describePermissionError(error)) {
3379
+ return {
3380
+ errorCode: "local_permission_denied",
3381
+ retry: "RetryWillNotFix"
3382
+ };
3383
+ }
3384
+ const connectivity = describeConnectivityError(error);
3385
+ if (connectivity) {
3386
+ return {
3387
+ errorCode: "network_error",
3388
+ retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
3389
+ };
3390
+ }
3391
+ return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
3392
+ }
3393
+ function withCarriedClass(inferred, error) {
3394
+ const errorCode = carriedErrorCode(error);
3395
+ const retry = carriedRetry(error);
3396
+ if (errorCode === undefined || errorCode === inferred.errorCode) {
3397
+ return {
3398
+ errorCode: inferred.errorCode,
3399
+ retry: retry ?? inferred.retry
3400
+ };
3401
+ }
3402
+ return { errorCode, retry: retry ?? defaultRetryForErrorCode(errorCode) };
3403
+ }
3404
+ function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
3405
+ if (extractedMessage) {
3406
+ return `HTTP ${status}: ${extractedMessage}`;
3407
+ }
3408
+ return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
3409
+ }
3410
+ async function extractErrorDetails(error, options) {
3411
+ const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
3412
+ const response = err.response;
3413
+ const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
3414
+ const explicitStatus = err.status ?? response?.status;
3415
+ const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
3416
+ const status = explicitStatus ?? inferredStatus;
3417
+ const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
3418
+ let rawBody;
3419
+ let extractedMessage;
3420
+ let parsedBody;
3421
+ const textFn = response?.text?.bind(response);
3422
+ if (textFn) {
3423
+ const [bodyError, body] = await catchError((async () => textFn())());
3424
+ if (!bodyError && body) {
3425
+ rawBody = body;
3426
+ const [parseError, parsed] = catchError(() => JSON.parse(body));
3427
+ if (!parseError && parsed && typeof parsed === "object") {
3428
+ parsedBody = parsed;
3429
+ if (parsedBody.errors && typeof parsedBody.errors === "object") {
3430
+ for (const field of Object.values(parsedBody.errors)) {
3431
+ if (Array.isArray(field) && field.length > 0) {
3432
+ const first = field[0];
3433
+ if (first && typeof first.message === "string") {
3434
+ extractedMessage = first.message;
3435
+ break;
3436
+ }
3437
+ }
3438
+ }
3439
+ }
3440
+ if (!extractedMessage) {
3441
+ extractedMessage = typeof parsedBody.message === "string" ? parsedBody.message : typeof parsedBody.errorMessage === "string" ? parsedBody.errorMessage : typeof parsedBody.title === "string" ? parsedBody.title : undefined;
3442
+ }
3443
+ if (!extractedMessage) {
3444
+ extractedMessage = body;
3445
+ }
3446
+ if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
3447
+ extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
3448
+ }
3449
+ } else {
3450
+ extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
3451
+ }
3452
+ }
3453
+ }
3454
+ let message;
3455
+ let result = "Failure";
3456
+ const classificationStatus = status ?? findHttpStatusInGraph(error);
3457
+ const classification = classifyError(classificationStatus, error);
3458
+ let retry = classification.retry;
3459
+ const htmlForbidden = status === 403 && rawBody !== undefined && isHtmlDocument(rawBody);
3460
+ const rayId = htmlForbidden ? readHeader(response, "cf-ray") : undefined;
3461
+ const cloudflareBlock = htmlForbidden && (rayId !== undefined || /\bcloudflare\b/i.test(readHeader(response, "server") ?? ""));
3462
+ if (status === 401) {
3463
+ message = DEFAULT_401;
3464
+ result = "AuthenticationError";
3465
+ } else if (cloudflareBlock) {
3466
+ message = rayId ? `${CLOUDFLARE_BLOCK_403} Cloudflare Ray ID: ${rayId}.` : CLOUDFLARE_BLOCK_403;
3467
+ } else if (status === 403) {
3468
+ message = options?.forbiddenMessage ?? DEFAULT_403;
3469
+ result = "AuthenticationError";
3470
+ } else if (status === 405) {
3471
+ message = DEFAULT_405;
3472
+ } else if (status === 413) {
3473
+ message = DEFAULT_413;
3474
+ } else if (status === 400 || status === 422) {
3475
+ message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
3476
+ result = "ValidationError";
3477
+ } else if (status === 429) {
3478
+ message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
3479
+ } else if (extractedMessage) {
3480
+ if (isSuccessfulResponse && rawMessage !== "Unknown error") {
3481
+ message = rawMessage;
3482
+ } else {
3483
+ message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
3484
+ }
3485
+ } else if (status) {
3486
+ if (inferredStatus !== undefined) {
3487
+ message = rawMessage;
3488
+ } else if (rawMessage === "Unknown error" && response) {
3489
+ const statusText = response.statusText;
3490
+ message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
3491
+ } else {
3492
+ message = `HTTP ${status}: ${rawMessage}`;
3493
+ }
3494
+ } else {
3495
+ message = rawMessage;
3496
+ }
3497
+ if (status === undefined) {
3498
+ const connectivity = describeConnectivityError(error);
3499
+ if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
3500
+ message = `${message}: ${connectivity.message}`;
3501
+ }
3502
+ }
3503
+ const permission = status === undefined ? describePermissionError(error) : undefined;
3504
+ if (permission) {
3505
+ if (permission.message !== message && !message.includes(permission.message)) {
3506
+ message = `${message}: ${permission.message}`;
3507
+ }
3508
+ if (!message.includes(permission.instructions)) {
3509
+ const punctuated = message.endsWith(".") ? message : `${message}.`;
3510
+ message = `${punctuated} ${permission.instructions}`;
3511
+ }
3512
+ }
3513
+ let details = rawMessage;
3514
+ if (htmlForbidden) {
3515
+ details = cloudflareBlock ? CLOUDFLARE_BLOCK_403_INSTRUCTIONS : HTML_RESPONSE_MESSAGE;
3516
+ } else if (rawBody) {
3517
+ if (parsedBody) {
3518
+ const extra = {};
3519
+ if (parsedBody.errorCode)
3520
+ extra.errorCode = parsedBody.errorCode;
3521
+ if (parsedBody.detail)
3522
+ extra.detail = parsedBody.detail;
3523
+ if (parsedBody.details)
3524
+ extra.details = parsedBody.details;
3525
+ if (parsedBody.errors != null)
3526
+ extra.errors = parsedBody.errors;
3527
+ if (parsedBody.data && typeof parsedBody.data === "object" && Object.keys(parsedBody.data).length > 0) {
3528
+ extra.data = parsedBody.data;
3529
+ }
3530
+ details = Object.keys(extra).length > 0 ? JSON.stringify(extra) : rawBody;
3531
+ } else {
3532
+ details = rawBody;
3533
+ }
3534
+ } else if (typeof err.message === "string") {
3535
+ details = err.message;
3536
+ } else {
3537
+ details = describeThrownValue(error);
3538
+ }
3539
+ const context = {};
3540
+ if (classificationStatus) {
3541
+ context.httpStatus = classificationStatus;
3542
+ }
3543
+ if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
3544
+ context.errorCode = parsedBody.errorCode;
3545
+ } else if (parsedBody?.code && typeof parsedBody.code === "string") {
3546
+ context.errorCode = parsedBody.code;
3547
+ }
3548
+ if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
3549
+ context.requestId = parsedBody.requestId;
3550
+ } else if (cloudflareBlock && rayId) {
3551
+ context.requestId = rayId;
3552
+ }
3553
+ if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
3554
+ context.traceId = parsedBody.traceId;
3555
+ }
3556
+ if (permission?.path !== undefined) {
3557
+ context.path = permission.path;
3558
+ }
3559
+ if (status === 429) {
3560
+ const retryAfterValue = readHeader(response, "retry-after");
3561
+ if (retryAfterValue) {
3562
+ const seconds = Number(retryAfterValue);
3563
+ if (!Number.isNaN(seconds)) {
3564
+ context.retryAfter = seconds;
3565
+ retry = retryHintForRetryAfter(seconds);
3566
+ }
3567
+ }
3568
+ }
3569
+ const hasContext = Object.keys(context).length > 0;
3570
+ let parsedErrors;
3571
+ if (parsedBody?.errors && typeof parsedBody.errors === "object") {
3572
+ const errors = {};
3573
+ for (const [field, raw] of Object.entries(parsedBody.errors)) {
3574
+ if (Array.isArray(raw)) {
3575
+ const messages = raw.map((entry) => {
3576
+ if (typeof entry === "string")
3577
+ return entry;
3578
+ if (entry && typeof entry === "object" && typeof entry.message === "string") {
3579
+ return entry.message;
3580
+ }
3581
+ return String(entry);
3582
+ }).filter(Boolean);
3583
+ if (messages.length > 0)
3584
+ errors[field] = messages;
3585
+ } else if (typeof raw === "string") {
3586
+ errors[field] = [raw];
3587
+ }
3588
+ }
3589
+ if (Object.keys(errors).length > 0)
3590
+ parsedErrors = errors;
3591
+ }
3592
+ return {
3593
+ result,
3594
+ ...withCarriedClass({ errorCode: classification.errorCode, retry }, error),
3595
+ message,
3596
+ details,
3597
+ ...hasContext ? { context } : {},
3598
+ ...parsedErrors ? { parsedErrors } : {}
3599
+ };
3600
+ }
3601
+ // ../common/src/result-types.ts
3602
+ var RESULTS = {
3603
+ Success: "Success",
3604
+ Failure: "Failure",
3605
+ ConfigError: "ConfigError",
3606
+ AuthenticationError: "AuthenticationError",
3607
+ ValidationError: "ValidationError",
3608
+ TimeoutError: "TimeoutError"
3609
+ };
3610
+ // ../../node_modules/commander/index.js
3611
+ var exports_commander = {};
3612
+ __exportCjs(exports_commander, {
3613
+ program: () => $program,
3614
+ createCommand: () => $createCommand,
3615
+ createOption: () => $createOption,
3616
+ createArgument: () => $createArgument,
3617
+ Command: () => $Command,
3618
+ Option: () => $Option,
3619
+ Argument: () => $Argument,
3620
+ Help: () => $Help,
3621
+ CommanderError: () => $CommanderError,
3622
+ InvalidArgumentError: () => $InvalidArgumentError,
3623
+ InvalidOptionArgumentError: () => $InvalidOptionArgumentError
3624
+ }, {
3625
+ program: (value) => $program = value,
3626
+ createCommand: (value) => $createCommand = value,
3627
+ createOption: (value) => $createOption = value,
3628
+ createArgument: (value) => $createArgument = value,
3629
+ Command: (value) => $Command = value,
3630
+ Option: (value) => $Option = value,
3631
+ Argument: (value) => $Argument = value,
3632
+ Help: (value) => $Help = value,
3633
+ CommanderError: (value) => $CommanderError = value,
3634
+ InvalidArgumentError: (value) => $InvalidArgumentError = value,
3635
+ InvalidOptionArgumentError: (value) => $InvalidOptionArgumentError = value
3636
+ });
3637
+ var { Argument } = require_argument();
3638
+ var { Command: Command2 } = require_command();
3639
+ var { CommanderError, InvalidArgumentError } = require_error();
3640
+ var { Help } = require_help();
3641
+ var { Option } = require_option();
3642
+ var $program = new Command2;
3643
+ var $createCommand = (name) => new Command2(name);
3644
+ var $createOption = (flags, description) => new Option(flags, description);
3645
+ var $createArgument = (name, description) => new Argument(name, description);
3646
+ var $Command = Command2;
3647
+ var $Option = Option;
3648
+ var $Argument = Argument;
3649
+ var $Help = Help;
3650
+ var $CommanderError = CommanderError;
3651
+ var $InvalidArgumentError = InvalidArgumentError;
3652
+ var $InvalidOptionArgumentError = InvalidArgumentError;
3653
+
3654
+ // ../../node_modules/commander/esm.mjs
3655
+ var {
3656
+ program,
3657
+ createCommand,
3658
+ createArgument,
3659
+ createOption,
3660
+ CommanderError: CommanderError2,
3661
+ InvalidArgumentError: InvalidArgumentError2,
3662
+ InvalidOptionArgumentError,
3663
+ Command,
3664
+ Argument: Argument2,
3665
+ Option: Option2,
3666
+ Help: Help2
3667
+ } = exports_commander;
3668
+
3669
+ // ../common/src/command-examples.ts
3670
+ var examplesByCommand = new WeakMap;
3671
+ Command.prototype.examples = function(examples) {
3672
+ examplesByCommand.set(this, examples);
3673
+ return this;
3674
+ };
3675
+ // ../common/src/preview.ts
3676
+ var previewSlot = singleton("PreviewBuild");
3677
+ function setPreviewBuild(isPreview) {
3678
+ previewSlot.set(isPreview);
3679
+ }
3680
+ function isPreviewBuild() {
3681
+ return previewSlot.get(false) ?? false;
3682
+ }
3683
+ function previewOnly(register) {
3684
+ if (isPreviewBuild()) {
3685
+ register();
3686
+ }
3687
+ }
3688
+ Command.prototype.previewCommand = function(nameAndArgs, opts) {
3689
+ if (isPreviewBuild()) {
3690
+ return this.command(nameAndArgs, opts);
3691
+ }
3692
+ return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
3693
+ };
2957
3694
 
2958
3695
  // ../common/src/output-context.ts
2959
3696
  function createStorage() {
@@ -2988,8 +3725,8 @@ function getOutputSink() {
2988
3725
 
2989
3726
  // ../common/src/logger.ts
2990
3727
  var logFilePathSlot = singleton("logFilePath");
2991
- function setGlobalLogFilePath(path2) {
2992
- logFilePathSlot.set(path2);
3728
+ function setGlobalLogFilePath(path) {
3729
+ logFilePathSlot.set(path);
2993
3730
  }
2994
3731
  function getGlobalLogFilePath() {
2995
3732
  return logFilePathSlot.get("");
@@ -3057,14 +3794,14 @@ class SimpleLogger {
3057
3794
  return this.fileLoggingEnabled || !!getGlobalLogFilePath();
3058
3795
  }
3059
3796
  writeToFile(formatted) {
3060
- const path2 = this.logFilePath || getGlobalLogFilePath();
3061
- if (!path2)
3797
+ const path = this.logFilePath || getGlobalLogFilePath();
3798
+ if (!path)
3062
3799
  return;
3063
3800
  const timestamp = new Date().toISOString();
3064
3801
  this.pendingWrites = Promise.all([
3065
3802
  this.pendingWrites,
3066
3803
  this.pendingInit
3067
- ]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
3804
+ ]).then(() => getFileSystem().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
3068
3805
  }
3069
3806
  write(formatted) {
3070
3807
  if (this.isFileLoggingActive()) {
@@ -3114,17 +3851,17 @@ class SimpleLogger {
3114
3851
  setGlobalLogFilePath("");
3115
3852
  }
3116
3853
  }
3117
- setLogFile(path2) {
3118
- this.logFilePath = path2;
3119
- setGlobalLogFilePath(path2);
3120
- if (!path2)
3854
+ setLogFile(path) {
3855
+ this.logFilePath = path;
3856
+ setGlobalLogFilePath(path);
3857
+ if (!path)
3121
3858
  return;
3122
3859
  this.fileLoggingEnabled = true;
3123
- const fs2 = getFileSystem();
3860
+ const fs = getFileSystem();
3124
3861
  this.pendingInit = (async () => {
3125
3862
  const [error] = await catchError((async () => {
3126
- await fs2.mkdir(fs2.path.dirname(path2));
3127
- await fs2.writeFile(path2, "");
3863
+ await fs.mkdir(fs.path.dirname(path));
3864
+ await fs.writeFile(path, "");
3128
3865
  })());
3129
3866
  if (error)
3130
3867
  this.fileLoggingEnabled = false;
@@ -3172,18 +3909,111 @@ function getLogFilePath() {
3172
3909
  return logger.getLogFilePath();
3173
3910
  }
3174
3911
 
3912
+ // ../common/src/timings.ts
3913
+ var TIMINGS_ENV_VAR = "UIP_TIMINGS";
3914
+ function createStorage2() {
3915
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
3916
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
3917
+ return {
3918
+ getStore: () => {
3919
+ return;
3920
+ },
3921
+ run: (_store, fn) => fn()
3922
+ };
3923
+ }
3924
+ return new mod.AsyncLocalStorage;
3925
+ }
3926
+ var storageSlot = singleton("TimingStorage");
3927
+ var stateSlot = singleton("Timings");
3928
+ var rootStartedSlot = singleton("TimingsRootStarted");
3929
+ var longLivedHostSlot = singleton("TimingsLongLivedHost");
3930
+ var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
3931
+ function newState(baseline) {
3932
+ return { baseline, httpMs: 0, httpCalls: 0 };
3933
+ }
3934
+ function getState() {
3935
+ const scoped = storage.getStore();
3936
+ if (scoped) {
3937
+ return scoped;
3938
+ }
3939
+ const pinned = livePinnedState();
3940
+ if (pinned !== undefined) {
3941
+ return pinned;
3942
+ }
3943
+ return newState(processStartIsInvocationStart() ? 0 : performance.now());
3944
+ }
3945
+ function livePinnedState() {
3946
+ const pinned = stateSlot.get();
3947
+ return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
3948
+ }
3949
+ function processStartIsInvocationStart() {
3950
+ return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
3951
+ }
3952
+ function timingsEnabled() {
3953
+ if (typeof process === "undefined") {
3954
+ return false;
3955
+ }
3956
+ const value = process.env?.[TIMINGS_ENV_VAR];
3957
+ if (value === undefined) {
3958
+ return false;
3959
+ }
3960
+ const normalized = value.trim().toLowerCase();
3961
+ return normalized === "1" || normalized === "true";
3962
+ }
3963
+ function recordExitCode(exitCode) {
3964
+ if (!timingsEnabled()) {
3965
+ return;
3966
+ }
3967
+ getState().exitCode = exitCode;
3968
+ }
3969
+ function invocationStartedAt() {
3970
+ return new Date(performance.timeOrigin + getState().baseline);
3971
+ }
3972
+ function invocationElapsedMs() {
3973
+ return performance.now() - getState().baseline;
3974
+ }
3975
+ function markCommandStart() {
3976
+ if (!timingsEnabled()) {
3977
+ return;
3978
+ }
3979
+ getState().commandStart = performance.now();
3980
+ }
3981
+ function recordCommandDuration(durationMs) {
3982
+ if (!timingsEnabled()) {
3983
+ return;
3984
+ }
3985
+ getState().commandMs = durationMs;
3986
+ }
3987
+
3988
+ // ../common/src/exit-code.ts
3989
+ function setExitCode(code) {
3990
+ process.exitCode = code;
3991
+ recordExitCode(code);
3992
+ }
3993
+ var GENERIC_FAILURE_EXIT_CODE = 1;
3994
+ function recordCommandExit(code) {
3995
+ if (code === GENERIC_FAILURE_EXIT_CODE && getExitCode() !== 0) {
3996
+ return;
3997
+ }
3998
+ setExitCode(code);
3999
+ }
4000
+ function getExitCode() {
4001
+ const code = process.exitCode;
4002
+ return typeof code === "number" ? code : 0;
4003
+ }
4004
+
3175
4005
  // ../common/src/output-codecs.ts
3176
4006
  var yamlSlot = singleton("YamlCodec");
3177
4007
  var jmespathSlot = singleton("JmespathCodec");
3178
4008
  async function loadOutputCodecsAsync(needed) {
3179
4009
  const loads = [];
3180
4010
  if (needed.yaml && yamlSlot.get() === undefined) {
3181
- loads.push(import("./js-yaml-88tdqrtd.js").then((mod) => {
4011
+ loads.push(import("./js-yaml-a2bk27p6.js").then((mod) => {
3182
4012
  yamlSlot.set(mod);
3183
4013
  }));
3184
4014
  }
3185
4015
  if (needed.filter && jmespathSlot.get() === undefined) {
3186
- loads.push(import("./jmespath-231m3hyn.js").then((m)=>__toESM(m.default,1)).then((mod) => {
4016
+ loads.push(import("./jmespath-ab6tdc42.js").then((m)=>__toESM(m.default,1)).then((mod) => {
3187
4017
  jmespathSlot.set(mod);
3188
4018
  }));
3189
4019
  }
@@ -3208,155 +4038,6 @@ function getOutputFilter() {
3208
4038
  return filterSlot.get();
3209
4039
  }
3210
4040
 
3211
- // ../common/src/telemetry/telemetry-dimensions.ts
3212
- var BaseDimensions = {
3213
- ApplicationName: "ApplicationName",
3214
- ProductVersion: "ProductVersion",
3215
- InstallationId: "InstallationId",
3216
- CloudUserId: "CloudUserId",
3217
- CloudTenantId: "CloudTenantId",
3218
- CloudOrganizationId: "CloudOrganizationId",
3219
- IsInternalUser: "IsInternalUser",
3220
- Environment: "Environment",
3221
- BaseUrl: "BaseUrl",
3222
- Region: "Region",
3223
- Agent: "Agent",
3224
- AgentVersion: "AgentVersion",
3225
- AgentModel: "AgentModel",
3226
- ToolName: "ToolName",
3227
- ToolVersion: "ToolVersion",
3228
- ExecutionContext: "ExecutionContext",
3229
- CiProvider: "CiProvider",
3230
- SessionIdSource: "SessionIdSource",
3231
- SessionId: "SessionId"
3232
- };
3233
- var CommandDimensions = {
3234
- IsCommand: "IsCommand",
3235
- IsReexec: "IsReexec",
3236
- CommandName: "CommandName",
3237
- ExitCode: "ExitCode",
3238
- TerminalOutcome: "TerminalOutcome",
3239
- ErrorClass: "ErrorClass",
3240
- TerminalSignal: "TerminalSignal",
3241
- ErrorMessage: "ErrorMessage",
3242
- SkillName: "SkillName",
3243
- ProductArea: "ProductArea",
3244
- Mode: "Mode"
3245
- };
3246
- var ShipDimensions = {
3247
- ShipKind: "ShipKind",
3248
- Target: "Target",
3249
- ProjectType: "ProjectType",
3250
- ProjectTypes: "ProjectTypes",
3251
- ArtifactCorrelationKey: "ArtifactCorrelationKey",
3252
- PackageName: "PackageName",
3253
- PackageVersion: "PackageVersion",
3254
- PackageVersionKey: "PackageVersionKey",
3255
- DeploymentKey: "DeploymentKey",
3256
- SolutionId: "SolutionId",
3257
- FolderKey: "FolderKey",
3258
- FeedId: "FeedId"
3259
- };
3260
- var ErrorDimensions = {
3261
- Result: "Result",
3262
- ErrorCode: "ErrorCode",
3263
- Retry: "Retry",
3264
- ErrorMessage: "ErrorMessage",
3265
- HttpStatus: "HttpStatus",
3266
- UpstreamErrorCode: "UpstreamErrorCode"
3267
- };
3268
- var AuthDimensions = {
3269
- AuthenticationMethod: "AuthenticationMethod",
3270
- Success: "Success",
3271
- Reason: "Reason"
3272
- };
3273
- var SkillsDimensions = {
3274
- SchemaVersion: "SchemaVersion",
3275
- AgentType: "AgentType",
3276
- SkillsVersion: "SkillsVersion",
3277
- UipSubcommand: "UipSubcommand",
3278
- FileExtension: "FileExtension",
3279
- SubagentModel: "SubagentModel",
3280
- SubagentType: "SubagentType",
3281
- PermissionMode: "PermissionMode",
3282
- EffortLevel: "EffortLevel",
3283
- SessionSource: "SessionSource",
3284
- Outcome: "Outcome",
3285
- DurationMs: "DurationMs",
3286
- Source: "Source"
3287
- };
3288
- var PackagerDimensions = {
3289
- ProjectId: "ProjectId",
3290
- ProjectType: "ProjectType",
3291
- SolutionId: "SolutionId"
3292
- };
3293
- var ScopeDimensions = {
3294
- FolderId: "FolderId"
3295
- };
3296
- var ID_DIMENSIONS = new Set([
3297
- BaseDimensions.CloudUserId,
3298
- BaseDimensions.CloudTenantId,
3299
- BaseDimensions.CloudOrganizationId,
3300
- BaseDimensions.InstallationId,
3301
- ShipDimensions.ArtifactCorrelationKey,
3302
- ShipDimensions.PackageVersionKey,
3303
- ShipDimensions.DeploymentKey,
3304
- ShipDimensions.SolutionId,
3305
- ShipDimensions.FolderKey,
3306
- ShipDimensions.FeedId,
3307
- PackagerDimensions.ProjectId
3308
- ]);
3309
- var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
3310
- var RESERVED_DIMENSION_NAMES = new Set([
3311
- ...Object.values(BaseDimensions),
3312
- ...Object.values(CommandDimensions),
3313
- ...Object.values(ShipDimensions),
3314
- ...Object.values(ErrorDimensions),
3315
- ...Object.values(AuthDimensions),
3316
- ...Object.values(SkillsDimensions),
3317
- ...Object.values(PackagerDimensions),
3318
- ...Object.values(ScopeDimensions)
3319
- ]);
3320
- var CURATED_DIMENSIONS = new Set([
3321
- BaseDimensions.ApplicationName,
3322
- BaseDimensions.ProductVersion,
3323
- BaseDimensions.InstallationId,
3324
- BaseDimensions.CloudUserId,
3325
- BaseDimensions.CloudTenantId,
3326
- BaseDimensions.CloudOrganizationId,
3327
- BaseDimensions.IsInternalUser,
3328
- BaseDimensions.Environment,
3329
- BaseDimensions.BaseUrl,
3330
- BaseDimensions.Region,
3331
- BaseDimensions.Agent,
3332
- BaseDimensions.AgentVersion,
3333
- BaseDimensions.ToolVersion,
3334
- BaseDimensions.ExecutionContext,
3335
- BaseDimensions.CiProvider,
3336
- BaseDimensions.SessionIdSource,
3337
- BaseDimensions.SessionId,
3338
- ...Object.values(CommandDimensions),
3339
- ...Object.values(ShipDimensions)
3340
- ]);
3341
- function lowercaseIdDimensionValues(properties) {
3342
- let changed = false;
3343
- const result = {
3344
- ...properties
3345
- };
3346
- for (const key of Object.keys(result)) {
3347
- const value = result[key];
3348
- if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
3349
- continue;
3350
- }
3351
- const lowered = value.toLowerCase();
3352
- if (lowered !== value) {
3353
- result[key] = lowered;
3354
- changed = true;
3355
- }
3356
- }
3357
- return changed ? result : properties;
3358
- }
3359
-
3360
4041
  // ../common/src/telemetry/command-terminal.ts
3361
4042
  var recordedFailureSlot = singleton("CommandTelemetryFailure");
3362
4043
  var AUTH_ERROR_CODES = new Set([
@@ -3475,17 +4156,8 @@ function terminalSignalFor(input, outcome) {
3475
4156
  }
3476
4157
  return outcome === "cancelled" ? "SIGINT" : undefined;
3477
4158
  }
3478
- function classifyHttpStatus(status) {
3479
- if (status === 401 || status === 403) {
3480
- return "auth";
3481
- }
3482
- if (status === 400 || status === 409 || status === 422) {
3483
- return "validation";
3484
- }
3485
- if (status === 408) {
3486
- return "timeout";
3487
- }
3488
- return "network_http";
4159
+ function classifyFailingHttpStatus(status) {
4160
+ return classifyFromErrorCode(classifyHttpStatus(status)?.errorCode) ?? "network_http";
3489
4161
  }
3490
4162
  function classifyFromResult(result) {
3491
4163
  switch (result) {
@@ -3558,14 +4230,14 @@ function classifyFromError(error) {
3558
4230
  }
3559
4231
  return;
3560
4232
  }
3561
- function classifyError(input) {
4233
+ function classifyError2(input) {
3562
4234
  const recorded = input.recordedFailure;
3563
4235
  if (recorded?.errorClass) {
3564
4236
  return recorded.errorClass;
3565
4237
  }
3566
4238
  const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
3567
4239
  if (status !== undefined) {
3568
- return classifyHttpStatus(status);
4240
+ return classifyFailingHttpStatus(status);
3569
4241
  }
3570
4242
  return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
3571
4243
  }
@@ -3583,7 +4255,7 @@ function takeRecordedCommandFailureTelemetry() {
3583
4255
  function buildCommandTerminalTelemetryProperties(input) {
3584
4256
  const cancelled = isCancellationError(input.error, input.exitCode, input.pollSignal);
3585
4257
  const outcome = input.recordedFailure?.terminalOutcome ?? (input.exitCode === 0 ? "success" : cancelled ? "cancelled" : "failure");
3586
- const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError(input);
4258
+ const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError2(input);
3587
4259
  const terminalSignal = terminalSignalFor(input, outcome);
3588
4260
  return {
3589
4261
  [CommandDimensions.ExitCode]: input.exitCode,
@@ -3597,6 +4269,7 @@ function buildCommandTerminalTelemetryProperties(input) {
3597
4269
  var CommonTelemetryEvents = {
3598
4270
  Start: "Application.Start",
3599
4271
  Error: "Application.Error",
4272
+ ProjectActivity: "Cli.ProjectActivity",
3600
4273
  ShipSucceeded: "Cli.ShipSucceeded"
3601
4274
  };
3602
4275
 
@@ -4062,132 +4735,57 @@ class TelemetryService {
4062
4735
  ...properties,
4063
4736
  [CommandDimensions.ErrorMessage]: err.message
4064
4737
  }, childContext),
4065
- type
4066
- });
4067
- throw error;
4068
- }
4069
- }
4070
- getActiveContext() {
4071
- return this.contextStorage.getContext();
4072
- }
4073
- leafCorrelation(explicit) {
4074
- const context = explicit ?? this.getActiveContext();
4075
- return {
4076
- operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
4077
- ...context !== undefined ? { parentId: context.id } : {}
4078
- };
4079
- }
4080
- spanFor(name, durationMs, success, properties, context) {
4081
- return {
4082
- name: redactSpanName(name),
4083
- durationMs,
4084
- success,
4085
- properties: this.enrichProperties(properties),
4086
- operationId: context.operationId,
4087
- ...context.parentId !== undefined ? { parentId: context.parentId } : {},
4088
- id: context.id,
4089
- ...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
4090
- };
4091
- }
4092
- enrichProperties(properties) {
4093
- const globalProperties = getGlobalTelemetryProperties();
4094
- const enriched = {
4095
- ...getExecutionContextTelemetryProperties(),
4096
- ...globalProperties,
4097
- ...this.defaultProperties,
4098
- ...redactProperties(properties ?? {}),
4099
- [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
4100
- [BaseDimensions.SessionId]: this.telemetryProvider.getSessionId?.() ?? getTelemetrySessionId()
4101
- };
4102
- return lowercaseIdDimensionValues(enriched);
4103
- }
4104
- generateId() {
4105
- const bytes = new Uint8Array(8);
4106
- let hex = "";
4107
- do {
4108
- crypto.getRandomValues(bytes);
4109
- hex = "";
4110
- for (const byte of bytes) {
4111
- hex += byte.toString(16).padStart(2, "0");
4112
- }
4113
- } while (/^0+$/.test(hex));
4114
- return hex;
4115
- }
4116
- }
4117
- // ../common/src/timings.ts
4118
- var TIMINGS_ENV_VAR = "UIP_TIMINGS";
4119
- function createStorage2() {
4120
- const [error, mod] = catchError(() => __require("node:async_hooks"));
4121
- if (error || typeof mod?.AsyncLocalStorage !== "function") {
4122
- return {
4123
- getStore: () => {
4124
- return;
4125
- },
4126
- run: (_store, fn) => fn()
4127
- };
4128
- }
4129
- return new mod.AsyncLocalStorage;
4130
- }
4131
- var storageSlot = singleton("TimingStorage");
4132
- var stateSlot = singleton("Timings");
4133
- var rootStartedSlot = singleton("TimingsRootStarted");
4134
- var longLivedHostSlot = singleton("TimingsLongLivedHost");
4135
- var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
4136
- function newState(baseline) {
4137
- return { baseline, httpMs: 0, httpCalls: 0 };
4138
- }
4139
- function getState() {
4140
- const scoped = storage.getStore();
4141
- if (scoped) {
4142
- return scoped;
4143
- }
4144
- const pinned = livePinnedState();
4145
- if (pinned !== undefined) {
4146
- return pinned;
4147
- }
4148
- return newState(processStartIsInvocationStart() ? 0 : performance.now());
4149
- }
4150
- function livePinnedState() {
4151
- const pinned = stateSlot.get();
4152
- return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
4153
- }
4154
- function processStartIsInvocationStart() {
4155
- return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
4156
- }
4157
- function timingsEnabled() {
4158
- if (typeof process === "undefined") {
4159
- return false;
4738
+ type
4739
+ });
4740
+ throw error;
4741
+ }
4160
4742
  }
4161
- const value = process.env?.[TIMINGS_ENV_VAR];
4162
- if (value === undefined) {
4163
- return false;
4743
+ getActiveContext() {
4744
+ return this.contextStorage.getContext();
4164
4745
  }
4165
- const normalized = value.trim().toLowerCase();
4166
- return normalized === "1" || normalized === "true";
4167
- }
4168
- function recordExitCode(exitCode) {
4169
- if (!timingsEnabled()) {
4170
- return;
4746
+ leafCorrelation(explicit) {
4747
+ const context = explicit ?? this.getActiveContext();
4748
+ return {
4749
+ operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
4750
+ ...context !== undefined ? { parentId: context.id } : {}
4751
+ };
4171
4752
  }
4172
- getState().exitCode = exitCode;
4173
- }
4174
- function invocationStartedAt() {
4175
- return new Date(performance.timeOrigin + getState().baseline);
4176
- }
4177
- function invocationElapsedMs() {
4178
- return performance.now() - getState().baseline;
4179
- }
4180
- function markCommandStart() {
4181
- if (!timingsEnabled()) {
4182
- return;
4753
+ spanFor(name, durationMs, success, properties, context) {
4754
+ return {
4755
+ name: redactSpanName(name),
4756
+ durationMs,
4757
+ success,
4758
+ properties: this.enrichProperties(properties),
4759
+ operationId: context.operationId,
4760
+ ...context.parentId !== undefined ? { parentId: context.parentId } : {},
4761
+ id: context.id,
4762
+ ...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
4763
+ };
4183
4764
  }
4184
- getState().commandStart = performance.now();
4185
- }
4186
- function recordCommandDuration(durationMs) {
4187
- if (!timingsEnabled()) {
4188
- return;
4765
+ enrichProperties(properties) {
4766
+ const globalProperties = getGlobalTelemetryProperties();
4767
+ const enriched = {
4768
+ ...getExecutionContextTelemetryProperties(),
4769
+ ...globalProperties,
4770
+ ...this.defaultProperties,
4771
+ ...redactProperties(properties ?? {}),
4772
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
4773
+ [BaseDimensions.SessionId]: this.telemetryProvider.getSessionId?.() ?? getTelemetrySessionId()
4774
+ };
4775
+ return lowercaseIdDimensionValues(enriched);
4776
+ }
4777
+ generateId() {
4778
+ const bytes = new Uint8Array(8);
4779
+ let hex = "";
4780
+ do {
4781
+ crypto.getRandomValues(bytes);
4782
+ hex = "";
4783
+ for (const byte of bytes) {
4784
+ hex += byte.toString(16).padStart(2, "0");
4785
+ }
4786
+ } while (/^0+$/.test(hex));
4787
+ return hex;
4189
4788
  }
4190
- getState().commandMs = durationMs;
4191
4789
  }
4192
4790
  // ../common/src/telemetry/proxy-http-agent.ts
4193
4791
  var slot = singleton("ProxyAuthHttpsAgent");
@@ -4195,6 +4793,15 @@ var slot = singleton("ProxyAuthHttpsAgent");
4195
4793
  // ../common/src/telemetry/node-appinsights-telemetry-provider.ts
4196
4794
  var providerSlot = singleton("TelemetryProvider");
4197
4795
 
4796
+ // ../common/src/telemetry/telemetry-config.ts
4797
+ function isTelemetryDisabled() {
4798
+ const value = process.env.UIPATH_TELEMETRY_DISABLED;
4799
+ return value === "1" || value === "true";
4800
+ }
4801
+ function isProjectTelemetryDisabled() {
4802
+ return isTelemetryDisabled() || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "1" || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "true";
4803
+ }
4804
+
4198
4805
  // ../common/src/telemetry/telemetry-spool.ts
4199
4806
  var sidecarEntrySlot = singleton("TelemetrySidecarEntry");
4200
4807
  var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
@@ -4230,7 +4837,6 @@ var telemetry = new Proxy({}, {
4230
4837
  return typeof value === "function" ? value.bind(instance) : value;
4231
4838
  }
4232
4839
  });
4233
-
4234
4840
  // ../common/src/formatter.ts
4235
4841
  var ANSI_STYLES = {
4236
4842
  red: "\x1B[31m",
@@ -4240,46 +4846,6 @@ var ANSI_RESET = "\x1B[0m";
4240
4846
  function styleLine(line, style) {
4241
4847
  return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
4242
4848
  }
4243
- var CLI_ERROR_CODES = [
4244
- "invalid_argument",
4245
- "authentication_required",
4246
- "permission_denied",
4247
- "local_permission_denied",
4248
- "not_found",
4249
- "rate_limited",
4250
- "network_error",
4251
- "timeout",
4252
- "server_error",
4253
- "method_not_allowed",
4254
- "not_supported",
4255
- "configuration_error",
4256
- "execution_failed",
4257
- "unknown_error"
4258
- ];
4259
- var RETRY_HINTS = [
4260
- "RetryWillNotFix",
4261
- "RetryLater",
4262
- "RetryAfter1Second",
4263
- "RetryAfter10Seconds",
4264
- "RetryAfter30Seconds",
4265
- "RetryAfter60Seconds"
4266
- ];
4267
- var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
4268
- var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
4269
- function isCliErrorCode(value) {
4270
- return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
4271
- }
4272
- function isRetryHint(value) {
4273
- return typeof value === "string" && RETRY_HINT_VALUES.has(value);
4274
- }
4275
- var RESULTS = {
4276
- Success: "Success",
4277
- Failure: "Failure",
4278
- ConfigError: "ConfigError",
4279
- AuthenticationError: "AuthenticationError",
4280
- ValidationError: "ValidationError",
4281
- TimeoutError: "TimeoutError"
4282
- };
4283
4849
  var EXIT_CODES = {
4284
4850
  Success: 0,
4285
4851
  Failure: 1,
@@ -4288,6 +4854,9 @@ var EXIT_CODES = {
4288
4854
  ValidationError: 3,
4289
4855
  TimeoutError: 4
4290
4856
  };
4857
+ function exitCodeForResult(result) {
4858
+ return EXIT_CODES[result] ?? EXIT_CODES.Failure;
4859
+ }
4291
4860
  function escapeNonAscii(jsonText) {
4292
4861
  return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
4293
4862
  const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
@@ -4963,8 +5532,8 @@ function carriesOnlyNulls(value) {
4963
5532
  }
4964
5533
  return false;
4965
5534
  }
4966
- function nameList(names, cap2 = 12) {
4967
- const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
5535
+ function nameList(names, cap = 12) {
5536
+ const shown = names.slice(0, cap).map((n) => `\`${n}\``);
4968
5537
  const rest = names.length - shown.length;
4969
5538
  return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
4970
5539
  }
@@ -5101,40 +5670,11 @@ function defaultErrorCodeForResult(result) {
5101
5670
  return "unknown_error";
5102
5671
  }
5103
5672
  }
5104
- function parseHttpStatusFromMessage2(message) {
5105
- const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
5106
- if (!match)
5107
- return;
5108
- const status = Number(match[1]);
5109
- return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
5110
- }
5111
- function defaultErrorCodeForHttpStatus(status) {
5112
- if (status === undefined)
5113
- return;
5114
- if (status === 400 || status === 409 || status === 422) {
5115
- return "invalid_argument";
5116
- }
5117
- if (status === 401)
5118
- return "authentication_required";
5119
- if (status === 403)
5120
- return "permission_denied";
5121
- if (status === 404)
5122
- return "not_found";
5123
- if (status === 405)
5124
- return "method_not_allowed";
5125
- if (status === 408)
5126
- return "timeout";
5127
- if (status === 429)
5128
- return "rate_limited";
5129
- if (status >= 500 && status < 600)
5130
- return "server_error";
5131
- return;
5132
- }
5133
5673
  var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
5134
5674
  function defaultErrorCodeForFailure(data) {
5135
5675
  if (data.Result === RESULTS.Failure) {
5136
- const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
5137
- const errorCode = defaultErrorCodeForHttpStatus(status);
5676
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
5677
+ const errorCode = classifyHttpStatus(status)?.errorCode;
5138
5678
  if (errorCode)
5139
5679
  return errorCode;
5140
5680
  if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
@@ -5143,17 +5683,6 @@ function defaultErrorCodeForFailure(data) {
5143
5683
  }
5144
5684
  return defaultErrorCodeForResult(data.Result);
5145
5685
  }
5146
- function defaultRetryForErrorCode(errorCode) {
5147
- switch (errorCode) {
5148
- case "network_error":
5149
- case "rate_limited":
5150
- case "server_error":
5151
- case "timeout":
5152
- return "RetryLater";
5153
- default:
5154
- return "RetryWillNotFix";
5155
- }
5156
- }
5157
5686
  var OutputFormatter;
5158
5687
  ((OutputFormatter) => {
5159
5688
  function success(data, options) {
@@ -5185,7 +5714,7 @@ var OutputFormatter;
5185
5714
  data.Log ??= getLogFilePath() || undefined;
5186
5715
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
5187
5716
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
5188
- const exitCode = EXIT_CODES[data.Result] ?? 1;
5717
+ const exitCode = exitCodeForResult(data.Result);
5189
5718
  setExitCode(exitCode);
5190
5719
  recordCommandFailureTelemetry({
5191
5720
  result: data.Result,
@@ -5279,47 +5808,228 @@ var OutputFormatter;
5279
5808
  }
5280
5809
  OutputFormatter.formatToString = formatToString;
5281
5810
  })(OutputFormatter ||= {});
5282
- // ../../node_modules/commander/esm.mjs
5283
- var import__ = __toESM(require_commander(), 1);
5284
- var {
5285
- program,
5286
- createCommand,
5287
- createArgument,
5288
- createOption,
5289
- CommanderError,
5290
- InvalidArgumentError,
5291
- InvalidOptionArgumentError,
5292
- Command,
5293
- Argument,
5294
- Option,
5295
- Help
5296
- } = import__.default;
5297
5811
 
5298
- // ../common/src/command-examples.ts
5299
- var examplesByCommand = new WeakMap;
5300
- Command.prototype.examples = function(examples) {
5301
- examplesByCommand.set(this, examples);
5302
- return this;
5303
- };
5304
- // ../common/src/preview.ts
5305
- var previewSlot = singleton("PreviewBuild");
5306
- function setPreviewBuild(isPreview) {
5307
- previewSlot.set(isPreview);
5812
+ // ../common/src/pass-through-tail.ts
5813
+ function maybeOption(arg) {
5814
+ return arg.length > 1 && arg[0] === "-";
5815
+ }
5816
+ function tokenizeTail(cmd, tail) {
5817
+ const find = (flag) => cmd.options.find((option) => option.long === flag || option.short === flag);
5818
+ const digitShort = cmd.options.some((option) => option.short !== undefined && /^-\d$/.test(option.short));
5819
+ const negativeNumber = (arg) => !digitShort && /^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg);
5820
+ const tokens = [];
5821
+ let firstUnknown = -1;
5822
+ let sentinel = -1;
5823
+ let variadic;
5824
+ let group;
5825
+ let groupIndex = 0;
5826
+ let i = 0;
5827
+ while (i < tail.length || group !== undefined) {
5828
+ const index = group === undefined ? i : groupIndex;
5829
+ const arg = group ?? tail[i++];
5830
+ group = undefined;
5831
+ if (arg === "--") {
5832
+ sentinel = index;
5833
+ tokens.push({ kind: "sentinel", index });
5834
+ for (let j = i;j < tail.length; j++) {
5835
+ tokens.push({
5836
+ kind: "operand",
5837
+ index: j,
5838
+ text: tail[j],
5839
+ literal: true
5840
+ });
5841
+ }
5842
+ break;
5843
+ }
5844
+ if (variadic && (!maybeOption(arg) || negativeNumber(arg))) {
5845
+ tokens.push({
5846
+ kind: "option",
5847
+ index,
5848
+ text: arg,
5849
+ option: variadic,
5850
+ value: arg
5851
+ });
5852
+ continue;
5853
+ }
5854
+ variadic = undefined;
5855
+ if (maybeOption(arg)) {
5856
+ const option = find(arg);
5857
+ if (option) {
5858
+ let value;
5859
+ if (option.required) {
5860
+ value = tail[i];
5861
+ if (value !== undefined)
5862
+ i++;
5863
+ } else if (option.optional) {
5864
+ const next = tail[i];
5865
+ if (next !== undefined && (!maybeOption(next) || negativeNumber(next))) {
5866
+ value = next;
5867
+ i++;
5868
+ }
5869
+ }
5870
+ tokens.push({
5871
+ kind: "option",
5872
+ index,
5873
+ text: arg,
5874
+ option,
5875
+ ...value === undefined ? {} : { value }
5876
+ });
5877
+ variadic = option.variadic ? option : undefined;
5878
+ continue;
5879
+ }
5880
+ }
5881
+ if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
5882
+ const option = find(`-${arg[1]}`);
5883
+ if (option) {
5884
+ if (option.required || option.optional) {
5885
+ tokens.push({
5886
+ kind: "option",
5887
+ index,
5888
+ text: arg,
5889
+ option,
5890
+ value: arg.slice(2)
5891
+ });
5892
+ } else {
5893
+ tokens.push({ kind: "option", index, text: arg, option });
5894
+ group = `-${arg.slice(2)}`;
5895
+ groupIndex = index;
5896
+ }
5897
+ continue;
5898
+ }
5899
+ }
5900
+ if (/^--[^=]+=/.test(arg)) {
5901
+ const equals = arg.indexOf("=");
5902
+ const option = find(arg.slice(0, equals));
5903
+ if (option && (option.required || option.optional)) {
5904
+ tokens.push({
5905
+ kind: "option",
5906
+ index,
5907
+ text: arg,
5908
+ option,
5909
+ value: arg.slice(equals + 1)
5910
+ });
5911
+ continue;
5912
+ }
5913
+ }
5914
+ if (maybeOption(arg) && !negativeNumber(arg)) {
5915
+ const equals = arg.startsWith("--") ? arg.indexOf("=") : -1;
5916
+ if (firstUnknown === -1)
5917
+ firstUnknown = index;
5918
+ tokens.push({
5919
+ kind: "unknown",
5920
+ index,
5921
+ text: arg,
5922
+ flag: equals > 0 ? arg.slice(0, equals) : arg,
5923
+ ...equals > 0 ? { inlineValue: arg.slice(equals + 1) } : {}
5924
+ });
5925
+ continue;
5926
+ }
5927
+ tokens.push({ kind: "operand", index, text: arg, literal: false });
5928
+ }
5929
+ return { tokens, firstUnknown, sentinel };
5308
5930
  }
5309
- function isPreviewBuild() {
5310
- return previewSlot.get(false) ?? false;
5931
+
5932
+ // ../common/src/project-telemetry.ts
5933
+ var RESOLVER = Symbol.for("@uipath/common/projectTelemetryResolver");
5934
+ var CAPTURE = Symbol.for("@uipath/common/projectTelemetryCapture");
5935
+ var CONTEXT_RESOLVER = Symbol.for("@uipath/common/projectContextTelemetryResolver");
5936
+ var RULES = Symbol.for("@uipath/common/projectTargetRules");
5937
+ function logSkipped(what, error) {
5938
+ logger.debug(`[project-telemetry] ${what} skipped: ${error instanceof Error ? error.message : String(error)}`);
5939
+ }
5940
+ function bounded(work, what) {
5941
+ return withinProjectIdentityBudget(work, () => logSkipped(what, `no answer within ${PROJECT_IDENTITY_LOOKUP_BUDGET_MS} ms`));
5942
+ }
5943
+ async function identityWithContext(command, identity) {
5944
+ const props = projectIdentityProperties(identity);
5945
+ if (!identity.projectDirectory || isProjectTelemetryDisabled())
5946
+ return props;
5947
+ for (let node = command;node; node = node.parent ?? undefined) {
5948
+ const resolver = node[CONTEXT_RESOLVER];
5949
+ if (typeof resolver !== "function")
5950
+ continue;
5951
+ try {
5952
+ return {
5953
+ ...await resolver(identity.projectDirectory),
5954
+ ...props
5955
+ };
5956
+ } catch (error) {
5957
+ logSkipped("solution context lookup", error);
5958
+ return props;
5959
+ }
5960
+ }
5961
+ return props;
5311
5962
  }
5312
- function previewOnly(register) {
5313
- if (isPreviewBuild()) {
5314
- register();
5963
+ function getProjectTelemetryResolver(command) {
5964
+ for (let node = command;node; node = node.parent) {
5965
+ const resolver = node[RESOLVER];
5966
+ if (typeof resolver === "function")
5967
+ return resolver;
5315
5968
  }
5969
+ return;
5316
5970
  }
5317
- Command.prototype.previewCommand = function(nameAndArgs, opts) {
5318
- if (isPreviewBuild()) {
5319
- return this.command(nameAndArgs, opts);
5971
+ function attachProjectTelemetryCapture(command, capture) {
5972
+ command[CAPTURE] = capture;
5973
+ }
5974
+ class ProjectTelemetrySession {
5975
+ resolver;
5976
+ command;
5977
+ target;
5978
+ props = {};
5979
+ explicit = false;
5980
+ input;
5981
+ constructor(resolver, command) {
5982
+ this.resolver = resolver;
5983
+ this.command = command;
5984
+ }
5985
+ async setTarget(path) {
5986
+ this.target = path;
5987
+ if (this.input) {
5988
+ await this.resolve({
5989
+ ...this.input,
5990
+ phase: "after",
5991
+ success: true
5992
+ });
5993
+ this.explicit = true;
5994
+ }
5320
5995
  }
5321
- return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
5322
- };
5996
+ async setIdentity(identity) {
5997
+ try {
5998
+ const props = await bounded(identityWithContext(this.command, identity), "project identity capture");
5999
+ if (props !== undefined)
6000
+ this.setProperties(props);
6001
+ } catch (error) {
6002
+ logSkipped("project identity capture", error);
6003
+ }
6004
+ }
6005
+ setProperties(properties) {
6006
+ try {
6007
+ this.props = { ...properties };
6008
+ this.explicit = true;
6009
+ } catch (error) {
6010
+ logSkipped("project identity properties", error);
6011
+ }
6012
+ }
6013
+ properties() {
6014
+ return { ...this.props };
6015
+ }
6016
+ async resolve(input) {
6017
+ this.input = input;
6018
+ if (this.explicit)
6019
+ return;
6020
+ try {
6021
+ const props = await bounded(this.resolver({
6022
+ ...input,
6023
+ target: this.target
6024
+ }), `project identity (${input.phase})`);
6025
+ if (props !== undefined) {
6026
+ this.props = props;
6027
+ }
6028
+ } catch (error) {
6029
+ logSkipped(`project identity (${input.phase})`, error);
6030
+ }
6031
+ }
6032
+ }
5323
6033
 
5324
6034
  // ../common/src/telemetry/command-attribution.ts
5325
6035
  var LEGACY_SKILL_NAMESPACE = "uipath:";
@@ -5565,8 +6275,7 @@ var pollSignalSlot = singleton("PollSignal");
5565
6275
  var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
5566
6276
  var processContext = {
5567
6277
  exit: (code) => {
5568
- recordExitCode(code);
5569
- setExitCode(code);
6278
+ recordCommandExit(code);
5570
6279
  },
5571
6280
  get pollSignal() {
5572
6281
  return pollSignalSlot.get();
@@ -5591,6 +6300,8 @@ function recordableArgValue(value, choices) {
5591
6300
  function extractCommandParams(cmd) {
5592
6301
  const params = {};
5593
6302
  forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
6303
+ if (name === undefined)
6304
+ return;
5594
6305
  const recordable = recordableArgValue(value, choices);
5595
6306
  params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
5596
6307
  });
@@ -5606,7 +6317,8 @@ function isDefaultedPositional(cmd, index) {
5606
6317
  function forEachSuppliedArgument(cmd, visit) {
5607
6318
  const registered = cmd.registeredArguments ?? [];
5608
6319
  const processed = cmd.processedArgs ?? [];
5609
- for (let i = 0;i < registered.length; i++) {
6320
+ const bound = boundPositionalCount(cmd);
6321
+ for (let i = 0;i < bound; i++) {
5610
6322
  const name = registered[i].name();
5611
6323
  if (name && processed[i] !== undefined) {
5612
6324
  visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
@@ -5621,6 +6333,71 @@ function forEachSuppliedArgument(cmd, visit) {
5621
6333
  visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
5622
6334
  }
5623
6335
  }
6336
+ forEachPassThroughToken(cmd, bound, (name, value) => {
6337
+ visit(name, value, name === undefined ? undefined : choicesByAttribute.get(name), false);
6338
+ });
6339
+ }
6340
+ function boundPositionalCount(cmd) {
6341
+ const registered = cmd.registeredArguments ?? [];
6342
+ if (registered.some((argument) => argument.variadic)) {
6343
+ return registered.length;
6344
+ }
6345
+ if ((cmd.args ?? []).length <= registered.length) {
6346
+ return registered.length;
6347
+ }
6348
+ const firstFlag = tokenizeTail(cmd, (cmd.args ?? []).slice(1)).tokens.find((token) => token.kind !== "operand")?.index ?? -1;
6349
+ return firstFlag === -1 ? registered.length : Math.min(registered.length, firstFlag + 1);
6350
+ }
6351
+ function forEachPassThroughToken(cmd, bound, visit) {
6352
+ const registered = cmd.registeredArguments ?? [];
6353
+ const fillsPositionals = !registered.some((argument) => argument.variadic);
6354
+ const { tokens, firstUnknown } = tokenizeTail(cmd, (cmd.args ?? []).slice(bound));
6355
+ const repeated = new Map;
6356
+ let nextPositional = bound;
6357
+ for (const token of tokens) {
6358
+ const pastUnknown = firstUnknown !== -1 && token.index > firstUnknown;
6359
+ if (token.kind === "sentinel")
6360
+ continue;
6361
+ if (token.kind === "operand") {
6362
+ const claimable = !pastUnknown && fillsPositionals && nextPositional < registered.length;
6363
+ const name = claimable ? registered[nextPositional++].name() : undefined;
6364
+ visit(name || undefined, token.text);
6365
+ continue;
6366
+ }
6367
+ if (token.kind === "unknown") {
6368
+ const bare = token.flag.replace(/^-+/, "");
6369
+ const key = bare.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
6370
+ const keyable = token.flag.startsWith("--") || token.flag.length === 2;
6371
+ if (!pastUnknown && keyable && /^[a-z][a-z0-9-]*$/i.test(bare) && key) {
6372
+ visit(key, token.inlineValue ?? true);
6373
+ } else {
6374
+ visit(undefined, token.text);
6375
+ if (token.inlineValue !== undefined) {
6376
+ visit(undefined, token.inlineValue);
6377
+ } else if (!token.flag.startsWith("--") && token.flag.length > 2) {
6378
+ visit(undefined, token.flag.slice(2));
6379
+ }
6380
+ }
6381
+ continue;
6382
+ }
6383
+ if (pastUnknown) {
6384
+ visit(undefined, token.text);
6385
+ if (token.value !== undefined)
6386
+ visit(undefined, token.value);
6387
+ continue;
6388
+ }
6389
+ const option = token.option;
6390
+ const name = option.attributeName();
6391
+ const value = option.negate ? false : option.required || option.optional ? token.value ?? true : true;
6392
+ const previous = repeated.get(name);
6393
+ if (previous) {
6394
+ previous.push(value);
6395
+ visit(name, previous);
6396
+ } else {
6397
+ repeated.set(name, [value]);
6398
+ visit(name, value);
6399
+ }
6400
+ }
5624
6401
  }
5625
6402
  function withheldArgumentValues(cmd) {
5626
6403
  const values = [];
@@ -5682,6 +6459,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5682
6459
  const telemetryName = commandTelemetryName(commandParts);
5683
6460
  const commandPath = commandInvocationPath(commandParts);
5684
6461
  const props = typeof properties === "function" ? properties(...args) : properties;
6462
+ const projectResolver = getProjectTelemetryResolver(command);
6463
+ const projectSession = projectResolver && !isProjectTelemetryDisabled() ? new ProjectTelemetrySession(projectResolver, command) : undefined;
5685
6464
  markCommandStart();
5686
6465
  const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
5687
6466
  try {
@@ -5694,6 +6473,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5694
6473
  if (violation) {
5695
6474
  return Promise.reject(violation);
5696
6475
  }
6476
+ if (projectSession) {
6477
+ return projectSession.resolve({ command, args, phase: "before" }).then(() => {
6478
+ attachProjectTelemetryCapture(command, projectSession);
6479
+ return fn(...args);
6480
+ });
6481
+ }
5697
6482
  return fn(...args);
5698
6483
  }));
5699
6484
  if (error) {
@@ -5702,22 +6487,26 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5702
6487
  const typed = error;
5703
6488
  const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
5704
6489
  const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
5705
- const finalResult = customResult ?? RESULTS.Failure;
6490
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
6491
+ const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
6492
+ const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
5706
6493
  const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
5707
6494
  const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
5708
6495
  const typedRetry = typed.retry ?? typed.Retry;
5709
6496
  const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
5710
6497
  const typedContext = typed.context ?? typed.Context;
5711
6498
  const customContext = isErrorContext(typedContext) ? typedContext : undefined;
5712
- const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
5713
6499
  fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
6500
+ const errorCode = customErrorCode ?? classified?.errorCode;
6501
+ const retry = customRetry ?? classified?.retry;
6502
+ const errorContext = customContext ?? classified?.context;
5714
6503
  OutputFormatter.error({
5715
6504
  Result: finalResult,
5716
- ...customErrorCode ? { ErrorCode: customErrorCode } : {},
6505
+ ...errorCode ? { ErrorCode: errorCode } : {},
5717
6506
  Message: errorMessage,
5718
6507
  Instructions: customInstructions ?? commandHelpHint(commandPath),
5719
- ...customRetry ? { Retry: customRetry } : {},
5720
- ...customContext ? { Context: customContext } : {}
6508
+ ...retry ? { Retry: retry } : {},
6509
+ ...errorContext ? { Context: errorContext } : {}
5721
6510
  });
5722
6511
  context.exit(fallbackExitCode);
5723
6512
  }
@@ -5726,6 +6515,14 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5726
6515
  const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
5727
6516
  const recordedFailure = takeRecordedCommandFailureTelemetry();
5728
6517
  const success = !error && exitCode === 0;
6518
+ if (projectSession) {
6519
+ await projectSession.resolve({
6520
+ command,
6521
+ args,
6522
+ phase: "after",
6523
+ success
6524
+ });
6525
+ }
5729
6526
  const terminalTelemetry = buildCommandTerminalTelemetryProperties({
5730
6527
  error,
5731
6528
  exitCode,
@@ -5743,6 +6540,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5743
6540
  }
5744
6541
  const baseProperties = redactProperties({
5745
6542
  ...commandParams,
6543
+ ...projectSession?.properties(),
5746
6544
  ...props,
5747
6545
  ...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
5748
6546
  ...buildAgentSessionTelemetry(process.env),
@@ -5753,6 +6551,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5753
6551
  });
5754
6552
  emitInvocationRequest(telemetryName, success, baseProperties);
5755
6553
  } finally {
6554
+ if (projectSession)
6555
+ attachProjectTelemetryCapture(command, undefined);
5756
6556
  releaseSuppliedArgumentValues(supplied);
5757
6557
  }
5758
6558
  });
@@ -6069,7 +6869,7 @@ var package_default = {
6069
6869
  name: "@uipath/coder-tool",
6070
6870
  author: "UiPath",
6071
6871
  license: "SEE LICENSE IN LICENSE.txt",
6072
- version: "1.205.0-preview.276",
6872
+ version: "1.206.0-preview.279",
6073
6873
  description: "Interactive coding agent (Pi) with UiPath LLM Gateway and BYO provider support.",
6074
6874
  publishConfig: {
6075
6875
  registry: "https://npm.pkg.github.com/"
@@ -6087,6 +6887,7 @@ var package_default = {
6087
6887
  ],
6088
6888
  scripts: {
6089
6889
  build: "bun ../../tools/build-tool.ts",
6890
+ typecheck: "tsc --noEmit",
6090
6891
  package: "bun run build && bun pm pack",
6091
6892
  test: "vitest run",
6092
6893
  "test:coverage": "vitest run --coverage",
@@ -6263,9 +7064,9 @@ function getProfileStorage() {
6263
7064
  if (isAuthProfileStorage(existing)) {
6264
7065
  return existing;
6265
7066
  }
6266
- const storage2 = createProfileStorage();
6267
- globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage2;
6268
- return storage2;
7067
+ const storage = createProfileStorage();
7068
+ globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
7069
+ return storage;
6269
7070
  }
6270
7071
  var profileStorage = getProfileStorage();
6271
7072
 
@@ -6296,8 +7097,8 @@ function resolveAuthProfileFilePath(profile) {
6296
7097
  if (normalized === undefined) {
6297
7098
  throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
6298
7099
  }
6299
- const fs2 = getFileSystem();
6300
- return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
7100
+ const fs = getFileSystem();
7101
+ return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
6301
7102
  }
6302
7103
  function getActiveAuthProfileFilePath() {
6303
7104
  const profile = getActiveAuthProfile();
@@ -6470,6 +7271,8 @@ var ENV_AUTH_VARS = {
6470
7271
  };
6471
7272
 
6472
7273
  class EnvAuthConfigError extends Error {
7274
+ errorCode = "configuration_error";
7275
+ retry = "RetryWillNotFix";
6473
7276
  constructor(message) {
6474
7277
  super(message);
6475
7278
  this.name = "EnvAuthConfigError";
@@ -6508,11 +7311,11 @@ var readAuthFromEnv = () => {
6508
7311
  if (!rawUrl) {
6509
7312
  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}).`);
6510
7313
  }
6511
- const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
7314
+ const baseUrl = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
6512
7315
  return {
6513
7316
  loginStatus: "Logged in",
6514
7317
  accessToken,
6515
- baseUrl: baseUrl2,
7318
+ baseUrl,
6516
7319
  organizationName,
6517
7320
  organizationId,
6518
7321
  tenantName,
@@ -6553,8 +7356,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
6553
7356
  async function refreshTokenFingerprint(refreshToken) {
6554
7357
  const bytes = new TextEncoder().encode(refreshToken);
6555
7358
  if (globalThis.crypto?.subtle) {
6556
- const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
6557
- return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
7359
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
7360
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
6558
7361
  }
6559
7362
  const { createHash } = await import("node:crypto");
6560
7363
  return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
@@ -6563,9 +7366,9 @@ function breakerPathFor(authPath) {
6563
7366
  return `${authPath}${BREAKER_SUFFIX}`;
6564
7367
  }
6565
7368
  async function loadRefreshBreaker(authPath) {
6566
- const fs2 = getFileSystem();
7369
+ const fs = getFileSystem();
6567
7370
  try {
6568
- const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
7371
+ const content = await fs.readFile(breakerPathFor(authPath), "utf-8");
6569
7372
  if (!content)
6570
7373
  return {};
6571
7374
  const parsed = JSON.parse(content);
@@ -6576,20 +7379,20 @@ async function loadRefreshBreaker(authPath) {
6576
7379
  }
6577
7380
  async function saveRefreshBreaker(authPath, state) {
6578
7381
  try {
6579
- const fs2 = getFileSystem();
6580
- const path2 = breakerPathFor(authPath);
6581
- await fs2.mkdir(fs2.path.dirname(path2));
6582
- const tempPath = `${path2}.tmp`;
6583
- await fs2.writeFile(tempPath, JSON.stringify(state));
6584
- await fs2.rename(tempPath, path2);
7382
+ const fs = getFileSystem();
7383
+ const path = breakerPathFor(authPath);
7384
+ await fs.mkdir(fs.path.dirname(path));
7385
+ const tempPath = `${path}.tmp`;
7386
+ await fs.writeFile(tempPath, JSON.stringify(state));
7387
+ await fs.rename(tempPath, path);
6585
7388
  } catch {}
6586
7389
  }
6587
7390
  async function clearRefreshBreaker(authPath) {
6588
- const fs2 = getFileSystem();
6589
- const path2 = breakerPathFor(authPath);
7391
+ const fs = getFileSystem();
7392
+ const path = breakerPathFor(authPath);
6590
7393
  try {
6591
- if (await fs2.exists(path2)) {
6592
- await fs2.rm(path2);
7394
+ if (await fs.exists(path)) {
7395
+ await fs.rm(path);
6593
7396
  }
6594
7397
  } catch {}
6595
7398
  }
@@ -6610,13 +7413,13 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
6610
7413
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
6611
7414
  var PIPE_NAME_MAX_LENGTH = 103;
6612
7415
  var getRobotIpcPipeNames = async () => {
6613
- const fs2 = getFileSystem();
6614
- const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
7416
+ const fs = getFileSystem();
7417
+ const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
6615
7418
  if (!username) {
6616
7419
  throw new Error("Unable to determine current username");
6617
7420
  }
6618
- const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
6619
- return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
7421
+ const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
7422
+ return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
6620
7423
  };
6621
7424
  var defaultIsRobotIpcAvailable = async () => {
6622
7425
  if (process.platform === "win32") {
@@ -6626,20 +7429,20 @@ var defaultIsRobotIpcAvailable = async () => {
6626
7429
  if (pipeNamesError || !pipeNames) {
6627
7430
  return false;
6628
7431
  }
6629
- const fs2 = getFileSystem();
7432
+ const fs = getFileSystem();
6630
7433
  for (const pipeName of pipeNames) {
6631
- const [existsError, exists] = await catchError2(fs2.exists(pipeName));
7434
+ const [existsError, exists] = await catchError2(fs.exists(pipeName));
6632
7435
  if (!existsError && exists === true) {
6633
7436
  return true;
6634
7437
  }
6635
7438
  }
6636
7439
  return false;
6637
7440
  };
6638
- var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
7441
+ var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
6639
7442
  const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
6640
7443
  promise.then((value) => {
6641
7444
  clearTimeout(timer);
6642
- resolve2(value);
7445
+ resolve(value);
6643
7446
  }, (error) => {
6644
7447
  clearTimeout(timer);
6645
7448
  reject(error);
@@ -6812,9 +7615,12 @@ var refreshAccessToken = async ({
6812
7615
  body: tokenParams
6813
7616
  });
6814
7617
  const tokenData = await tokenResponse.json();
6815
- if (!tokenResponse.ok) {
7618
+ if (tokenResponse.status === 400 || tokenResponse.status === 401) {
6816
7619
  throw new TokenRefreshOAuthError;
6817
7620
  }
7621
+ if (!tokenResponse.ok) {
7622
+ throw new Error(`Token refresh failed: HTTP ${tokenResponse.status}`);
7623
+ }
6818
7624
  const newAccessToken = tokenData.access_token;
6819
7625
  const newRefreshToken = tokenData.refresh_token;
6820
7626
  if (typeof newAccessToken !== "string" || typeof newRefreshToken !== "string") {
@@ -6846,9 +7652,9 @@ var errorCode = (err) => {
6846
7652
  }
6847
7653
  return "EUNKNOWN";
6848
7654
  };
6849
- var probeAsync = async (fs2, candidate) => {
7655
+ var probeAsync = async (fs, candidate) => {
6850
7656
  try {
6851
- const stats = await fs2.stat(candidate);
7657
+ const stats = await fs.stat(candidate);
6852
7658
  if (stats === null) {
6853
7659
  return { exists: false };
6854
7660
  }
@@ -6875,36 +7681,36 @@ var probeAsync = async (fs2, candidate) => {
6875
7681
  }
6876
7682
  };
6877
7683
  var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
6878
- const fs2 = getFileSystem();
6879
- if (fs2.path.isAbsolute(envFilePath)) {
6880
- const probe2 = await probeAsync(fs2, envFilePath);
6881
- return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
7684
+ const fs = getFileSystem();
7685
+ if (fs.path.isAbsolute(envFilePath)) {
7686
+ const probe = await probeAsync(fs, envFilePath);
7687
+ return probe.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
6882
7688
  exists: false,
6883
7689
  absolutePath: envFilePath,
6884
7690
  source: "absolute",
6885
- ...probe2.unusable ? { unusable: probe2.unusable } : {}
7691
+ ...probe.unusable ? { unusable: probe.unusable } : {}
6886
7692
  };
6887
7693
  }
6888
- const cwd = opts?.cwd ?? fs2.env.cwd();
7694
+ const cwd = opts?.cwd ?? fs.env.cwd();
6889
7695
  let searchDir = cwd;
6890
7696
  while (true) {
6891
- const candidate = fs2.path.join(searchDir, envFilePath);
6892
- const probe2 = await probeAsync(fs2, candidate);
6893
- if (probe2.exists) {
7697
+ const candidate = fs.path.join(searchDir, envFilePath);
7698
+ const probe = await probeAsync(fs, candidate);
7699
+ if (probe.exists) {
6894
7700
  return {
6895
7701
  exists: true,
6896
7702
  absolutePath: candidate,
6897
7703
  source: searchDir === cwd ? "cwd" : "ancestor"
6898
7704
  };
6899
7705
  }
6900
- const parentDir = fs2.path.dirname(searchDir);
7706
+ const parentDir = fs.path.dirname(searchDir);
6901
7707
  if (parentDir === searchDir) {
6902
7708
  break;
6903
7709
  }
6904
7710
  searchDir = parentDir;
6905
7711
  }
6906
- const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
6907
- const probe = await probeAsync(fs2, homePath);
7712
+ const homePath = fs.path.join(fs.env.homedir(), envFilePath);
7713
+ const probe = await probeAsync(fs, homePath);
6908
7714
  if (probe.exists) {
6909
7715
  return { exists: true, absolutePath: homePath, source: "home" };
6910
7716
  }
@@ -6947,12 +7753,12 @@ var parseEnvContent = (content) => {
6947
7753
  return env;
6948
7754
  };
6949
7755
  var loadEnvFileAsync = async ({ envPath }) => {
6950
- const fs2 = getFileSystem();
6951
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
6952
- if (!await fs2.exists(absolutePath)) {
7756
+ const fs = getFileSystem();
7757
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
7758
+ if (!await fs.exists(absolutePath)) {
6953
7759
  throw new Error(`Environment file not found: ${envPath}`);
6954
7760
  }
6955
- const content = await fs2.readFile(absolutePath, "utf-8");
7761
+ const content = await fs.readFile(absolutePath, "utf-8");
6956
7762
  if (content === null) {
6957
7763
  throw new Error(`Environment file not found: ${envPath}`);
6958
7764
  }
@@ -6963,10 +7769,10 @@ var saveEnvFileAsync = async ({
6963
7769
  data,
6964
7770
  merge = true
6965
7771
  }) => {
6966
- const fs2 = getFileSystem();
6967
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
7772
+ const fs = getFileSystem();
7773
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
6968
7774
  let existingData = {};
6969
- if (merge && await fs2.exists(absolutePath)) {
7775
+ if (merge && await fs.exists(absolutePath)) {
6970
7776
  try {
6971
7777
  existingData = await loadEnvFileAsync({ envPath: absolutePath });
6972
7778
  } catch {}
@@ -6984,11 +7790,11 @@ var saveEnvFileAsync = async ({
6984
7790
  const content = `${lines.join(`
6985
7791
  `)}
6986
7792
  `;
6987
- const dir = fs2.path.dirname(absolutePath);
6988
- await fs2.mkdir(dir);
7793
+ const dir = fs.path.dirname(absolutePath);
7794
+ await fs.mkdir(dir);
6989
7795
  const tempPath = `${absolutePath}.tmp`;
6990
- await fs2.writeFile(tempPath, content);
6991
- await fs2.rename(tempPath, absolutePath);
7796
+ await fs.writeFile(tempPath, content);
7797
+ await fs.rename(tempPath, absolutePath);
6992
7798
  };
6993
7799
 
6994
7800
  // ../auth/src/loginStatus.ts
@@ -7112,11 +7918,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
7112
7918
  return { credentials };
7113
7919
  }
7114
7920
  async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
7115
- const fs2 = getFs();
7116
- const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
7921
+ const fs = getFs();
7922
+ const globalPath = fs.path.join(fs.env.homedir(), envFilePath);
7117
7923
  if (absolutePath === globalPath)
7118
7924
  return;
7119
- if (!await fs2.exists(globalPath))
7925
+ if (!await fs.exists(globalPath))
7120
7926
  return;
7121
7927
  try {
7122
7928
  const globalCreds = await loadEnvFile({ envPath: globalPath });
@@ -7722,15 +8528,15 @@ var PI_SUBCOMMANDS = new Set([
7722
8528
  "config"
7723
8529
  ]);
7724
8530
  async function resolveAgentGuide() {
7725
- const fs2 = getFileSystem();
8531
+ const fs = getFileSystem();
7726
8532
  const candidates = [
7727
8533
  new URL("./templates/uipath-cli.md", import.meta.url),
7728
8534
  new URL("../../templates/uipath-cli.md", import.meta.url)
7729
8535
  ];
7730
8536
  for (const url of candidates) {
7731
- const path2 = fileURLToPath(url);
7732
- if (await fs2.exists(path2)) {
7733
- const text = await fs2.readFile(path2, "utf-8");
8537
+ const path = fileURLToPath(url);
8538
+ if (await fs.exists(path)) {
8539
+ const text = await fs.readFile(path, "utf-8");
7734
8540
  return text ?? undefined;
7735
8541
  }
7736
8542
  }
@@ -7764,8 +8570,8 @@ async function runPi(args, hardExit) {
7764
8570
  const exitCodeBefore = process.exitCode;
7765
8571
  let requestedExitCode;
7766
8572
  let resolveExit = () => {};
7767
- const exitRequested = new Promise((resolve2) => {
7768
- resolveExit = resolve2;
8573
+ const exitRequested = new Promise((resolve) => {
8574
+ resolveExit = resolve;
7769
8575
  });
7770
8576
  process.exit = (code) => {
7771
8577
  if (requestedExitCode === undefined) {
@@ -7808,16 +8614,16 @@ function registerChatCommand(command, context = processContext, hardExit) {
7808
8614
  }
7809
8615
 
7810
8616
  // src/tool.ts
7811
- var metadata = {
8617
+ var metadata2 = {
7812
8618
  name: "coder-tool",
7813
8619
  version: package_default.version,
7814
8620
  description: "Build UiPath automations with an AI agent (Pi) that drives uip — via UiPath LLM Gateway or your own model keys.",
7815
8621
  commandPrefix: "coder"
7816
8622
  };
7817
- var registerCommands = async (program2) => {
7818
- previewOnly(() => registerChatCommand(program2));
8623
+ var registerCommands2 = async (program) => {
8624
+ previewOnly(() => registerChatCommand(program));
7819
8625
  };
7820
8626
 
7821
- export { Command, setPreviewBuild, metadata, registerCommands };
8627
+ export { Command, setPreviewBuild, metadata2, registerCommands2 };
7822
8628
 
7823
- //# debugId=282EC8756F7F578A64756E2164756E21
8629
+ //# debugId=6C68DE475B8CABF764756E2164756E21