@uipath/context-grounding-tool 1.205.0-preview.277 → 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,407 @@ 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;
2956
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;
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 isPreviewBuild() {
3678
+ return previewSlot.get(false) ?? false;
3679
+ }
3680
+ Command.prototype.previewCommand = function(nameAndArgs, opts) {
3681
+ if (isPreviewBuild()) {
3682
+ return this.command(nameAndArgs, opts);
3683
+ }
3684
+ return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
3685
+ };
2957
3686
 
2958
3687
  // ../common/src/output-context.ts
2959
3688
  function createStorage() {
@@ -2988,8 +3717,8 @@ function getOutputSink() {
2988
3717
 
2989
3718
  // ../common/src/logger.ts
2990
3719
  var logFilePathSlot = singleton("logFilePath");
2991
- function setGlobalLogFilePath(path2) {
2992
- logFilePathSlot.set(path2);
3720
+ function setGlobalLogFilePath(path) {
3721
+ logFilePathSlot.set(path);
2993
3722
  }
2994
3723
  function getGlobalLogFilePath() {
2995
3724
  return logFilePathSlot.get("");
@@ -3057,14 +3786,14 @@ class SimpleLogger {
3057
3786
  return this.fileLoggingEnabled || !!getGlobalLogFilePath();
3058
3787
  }
3059
3788
  writeToFile(formatted) {
3060
- const path2 = this.logFilePath || getGlobalLogFilePath();
3061
- if (!path2)
3789
+ const path = this.logFilePath || getGlobalLogFilePath();
3790
+ if (!path)
3062
3791
  return;
3063
3792
  const timestamp = new Date().toISOString();
3064
3793
  this.pendingWrites = Promise.all([
3065
3794
  this.pendingWrites,
3066
3795
  this.pendingInit
3067
- ]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
3796
+ ]).then(() => getFileSystem().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
3068
3797
  }
3069
3798
  write(formatted) {
3070
3799
  if (this.isFileLoggingActive()) {
@@ -3114,17 +3843,17 @@ class SimpleLogger {
3114
3843
  setGlobalLogFilePath("");
3115
3844
  }
3116
3845
  }
3117
- setLogFile(path2) {
3118
- this.logFilePath = path2;
3119
- setGlobalLogFilePath(path2);
3120
- if (!path2)
3846
+ setLogFile(path) {
3847
+ this.logFilePath = path;
3848
+ setGlobalLogFilePath(path);
3849
+ if (!path)
3121
3850
  return;
3122
3851
  this.fileLoggingEnabled = true;
3123
- const fs2 = getFileSystem();
3852
+ const fs = getFileSystem();
3124
3853
  this.pendingInit = (async () => {
3125
3854
  const [error] = await catchError((async () => {
3126
- await fs2.mkdir(fs2.path.dirname(path2));
3127
- await fs2.writeFile(path2, "");
3855
+ await fs.mkdir(fs.path.dirname(path));
3856
+ await fs.writeFile(path, "");
3128
3857
  })());
3129
3858
  if (error)
3130
3859
  this.fileLoggingEnabled = false;
@@ -3172,192 +3901,136 @@ function getLogFilePath() {
3172
3901
  return logger.getLogFilePath();
3173
3902
  }
3174
3903
 
3175
- // ../common/src/output-codecs.ts
3176
- var yamlSlot = singleton("YamlCodec");
3177
- var jmespathSlot = singleton("JmespathCodec");
3178
- async function loadOutputCodecsAsync(needed) {
3179
- const loads = [];
3180
- if (needed.yaml && yamlSlot.get() === undefined) {
3181
- loads.push(import("./js-yaml-88tdqrtd.js").then((mod) => {
3182
- yamlSlot.set(mod);
3183
- }));
3184
- }
3185
- if (needed.filter && jmespathSlot.get() === undefined) {
3186
- loads.push(import("./jmespath-231m3hyn.js").then((m)=>__toESM(m.default,1)).then((mod) => {
3187
- jmespathSlot.set(mod);
3188
- }));
3189
- }
3190
- await Promise.all(loads);
3191
- }
3192
- function getYamlCodec() {
3193
- return yamlSlot.get();
3194
- }
3195
- function getJmespathCodec() {
3196
- return jmespathSlot.get();
3197
- }
3198
-
3199
- // ../common/src/output-format-context.ts
3200
- var formatSlot = singleton("OutputFormat");
3201
- var formatExplicitSlot = singleton("OutputFormatExplicit");
3202
- var helpRequestedSlot = singleton("HelpRequested");
3203
- var filterSlot = singleton("OutputFilter");
3204
- function getOutputFormat() {
3205
- return formatSlot.get("json");
3206
- }
3207
- function getOutputFormatExplicit() {
3208
- return formatExplicitSlot.get(false) ?? false;
3209
- }
3210
- function getOutputFilter() {
3211
- return filterSlot.get();
3212
- }
3213
-
3214
- // ../common/src/telemetry/telemetry-dimensions.ts
3215
- var BaseDimensions = {
3216
- ApplicationName: "ApplicationName",
3217
- ProductVersion: "ProductVersion",
3218
- InstallationId: "InstallationId",
3219
- CloudUserId: "CloudUserId",
3220
- CloudTenantId: "CloudTenantId",
3221
- CloudOrganizationId: "CloudOrganizationId",
3222
- IsInternalUser: "IsInternalUser",
3223
- Environment: "Environment",
3224
- BaseUrl: "BaseUrl",
3225
- Region: "Region",
3226
- Agent: "Agent",
3227
- AgentVersion: "AgentVersion",
3228
- AgentModel: "AgentModel",
3229
- ToolName: "ToolName",
3230
- ToolVersion: "ToolVersion",
3231
- ExecutionContext: "ExecutionContext",
3232
- CiProvider: "CiProvider",
3233
- SessionIdSource: "SessionIdSource",
3234
- SessionId: "SessionId"
3235
- };
3236
- var CommandDimensions = {
3237
- IsCommand: "IsCommand",
3238
- IsReexec: "IsReexec",
3239
- CommandName: "CommandName",
3240
- ExitCode: "ExitCode",
3241
- TerminalOutcome: "TerminalOutcome",
3242
- ErrorClass: "ErrorClass",
3243
- TerminalSignal: "TerminalSignal",
3244
- ErrorMessage: "ErrorMessage",
3245
- SkillName: "SkillName",
3246
- ProductArea: "ProductArea",
3247
- Mode: "Mode"
3248
- };
3249
- var ShipDimensions = {
3250
- ShipKind: "ShipKind",
3251
- Target: "Target",
3252
- ProjectType: "ProjectType",
3253
- ProjectTypes: "ProjectTypes",
3254
- ArtifactCorrelationKey: "ArtifactCorrelationKey",
3255
- PackageName: "PackageName",
3256
- PackageVersion: "PackageVersion",
3257
- PackageVersionKey: "PackageVersionKey",
3258
- DeploymentKey: "DeploymentKey",
3259
- SolutionId: "SolutionId",
3260
- FolderKey: "FolderKey",
3261
- FeedId: "FeedId"
3262
- };
3263
- var ErrorDimensions = {
3264
- Result: "Result",
3265
- ErrorCode: "ErrorCode",
3266
- Retry: "Retry",
3267
- ErrorMessage: "ErrorMessage",
3268
- HttpStatus: "HttpStatus",
3269
- UpstreamErrorCode: "UpstreamErrorCode"
3270
- };
3271
- var AuthDimensions = {
3272
- AuthenticationMethod: "AuthenticationMethod",
3273
- Success: "Success",
3274
- Reason: "Reason"
3275
- };
3276
- var SkillsDimensions = {
3277
- SchemaVersion: "SchemaVersion",
3278
- AgentType: "AgentType",
3279
- SkillsVersion: "SkillsVersion",
3280
- UipSubcommand: "UipSubcommand",
3281
- FileExtension: "FileExtension",
3282
- SubagentModel: "SubagentModel",
3283
- SubagentType: "SubagentType",
3284
- PermissionMode: "PermissionMode",
3285
- EffortLevel: "EffortLevel",
3286
- SessionSource: "SessionSource",
3287
- Outcome: "Outcome",
3288
- DurationMs: "DurationMs",
3289
- Source: "Source"
3290
- };
3291
- var PackagerDimensions = {
3292
- ProjectId: "ProjectId",
3293
- ProjectType: "ProjectType",
3294
- SolutionId: "SolutionId"
3295
- };
3296
- var ScopeDimensions = {
3297
- FolderId: "FolderId"
3298
- };
3299
- var ID_DIMENSIONS = new Set([
3300
- BaseDimensions.CloudUserId,
3301
- BaseDimensions.CloudTenantId,
3302
- BaseDimensions.CloudOrganizationId,
3303
- BaseDimensions.InstallationId,
3304
- ShipDimensions.ArtifactCorrelationKey,
3305
- ShipDimensions.PackageVersionKey,
3306
- ShipDimensions.DeploymentKey,
3307
- ShipDimensions.SolutionId,
3308
- ShipDimensions.FolderKey,
3309
- ShipDimensions.FeedId,
3310
- PackagerDimensions.ProjectId
3311
- ]);
3312
- var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
3313
- var RESERVED_DIMENSION_NAMES = new Set([
3314
- ...Object.values(BaseDimensions),
3315
- ...Object.values(CommandDimensions),
3316
- ...Object.values(ShipDimensions),
3317
- ...Object.values(ErrorDimensions),
3318
- ...Object.values(AuthDimensions),
3319
- ...Object.values(SkillsDimensions),
3320
- ...Object.values(PackagerDimensions),
3321
- ...Object.values(ScopeDimensions)
3322
- ]);
3323
- var CURATED_DIMENSIONS = new Set([
3324
- BaseDimensions.ApplicationName,
3325
- BaseDimensions.ProductVersion,
3326
- BaseDimensions.InstallationId,
3327
- BaseDimensions.CloudUserId,
3328
- BaseDimensions.CloudTenantId,
3329
- BaseDimensions.CloudOrganizationId,
3330
- BaseDimensions.IsInternalUser,
3331
- BaseDimensions.Environment,
3332
- BaseDimensions.BaseUrl,
3333
- BaseDimensions.Region,
3334
- BaseDimensions.Agent,
3335
- BaseDimensions.AgentVersion,
3336
- BaseDimensions.ToolVersion,
3337
- BaseDimensions.ExecutionContext,
3338
- BaseDimensions.CiProvider,
3339
- BaseDimensions.SessionIdSource,
3340
- BaseDimensions.SessionId,
3341
- ...Object.values(CommandDimensions),
3342
- ...Object.values(ShipDimensions)
3343
- ]);
3344
- function lowercaseIdDimensionValues(properties) {
3345
- let changed = false;
3346
- const result = {
3347
- ...properties
3348
- };
3349
- for (const key of Object.keys(result)) {
3350
- const value = result[key];
3351
- if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
3352
- continue;
3353
- }
3354
- const lowered = value.toLowerCase();
3355
- if (lowered !== value) {
3356
- result[key] = lowered;
3357
- changed = true;
3358
- }
3904
+ // ../common/src/timings.ts
3905
+ var TIMINGS_ENV_VAR = "UIP_TIMINGS";
3906
+ function createStorage2() {
3907
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
3908
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
3909
+ return {
3910
+ getStore: () => {
3911
+ return;
3912
+ },
3913
+ run: (_store, fn) => fn()
3914
+ };
3359
3915
  }
3360
- return changed ? result : properties;
3916
+ return new mod.AsyncLocalStorage;
3917
+ }
3918
+ var storageSlot = singleton("TimingStorage");
3919
+ var stateSlot = singleton("Timings");
3920
+ var rootStartedSlot = singleton("TimingsRootStarted");
3921
+ var longLivedHostSlot = singleton("TimingsLongLivedHost");
3922
+ var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
3923
+ function newState(baseline) {
3924
+ return { baseline, httpMs: 0, httpCalls: 0 };
3925
+ }
3926
+ function getState() {
3927
+ const scoped = storage.getStore();
3928
+ if (scoped) {
3929
+ return scoped;
3930
+ }
3931
+ const pinned = livePinnedState();
3932
+ if (pinned !== undefined) {
3933
+ return pinned;
3934
+ }
3935
+ return newState(processStartIsInvocationStart() ? 0 : performance.now());
3936
+ }
3937
+ function livePinnedState() {
3938
+ const pinned = stateSlot.get();
3939
+ return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
3940
+ }
3941
+ function processStartIsInvocationStart() {
3942
+ return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
3943
+ }
3944
+ function timingsEnabled() {
3945
+ if (typeof process === "undefined") {
3946
+ return false;
3947
+ }
3948
+ const value = process.env?.[TIMINGS_ENV_VAR];
3949
+ if (value === undefined) {
3950
+ return false;
3951
+ }
3952
+ const normalized = value.trim().toLowerCase();
3953
+ return normalized === "1" || normalized === "true";
3954
+ }
3955
+ function recordExitCode(exitCode) {
3956
+ if (!timingsEnabled()) {
3957
+ return;
3958
+ }
3959
+ getState().exitCode = exitCode;
3960
+ }
3961
+ function invocationStartedAt() {
3962
+ return new Date(performance.timeOrigin + getState().baseline);
3963
+ }
3964
+ function invocationElapsedMs() {
3965
+ return performance.now() - getState().baseline;
3966
+ }
3967
+ function markCommandStart() {
3968
+ if (!timingsEnabled()) {
3969
+ return;
3970
+ }
3971
+ getState().commandStart = performance.now();
3972
+ }
3973
+ function recordCommandDuration(durationMs) {
3974
+ if (!timingsEnabled()) {
3975
+ return;
3976
+ }
3977
+ getState().commandMs = durationMs;
3978
+ }
3979
+
3980
+ // ../common/src/exit-code.ts
3981
+ function setExitCode(code) {
3982
+ process.exitCode = code;
3983
+ recordExitCode(code);
3984
+ }
3985
+ var GENERIC_FAILURE_EXIT_CODE = 1;
3986
+ function recordCommandExit(code) {
3987
+ if (code === GENERIC_FAILURE_EXIT_CODE && getExitCode() !== 0) {
3988
+ return;
3989
+ }
3990
+ setExitCode(code);
3991
+ }
3992
+ function getExitCode() {
3993
+ const code = process.exitCode;
3994
+ return typeof code === "number" ? code : 0;
3995
+ }
3996
+
3997
+ // ../common/src/output-codecs.ts
3998
+ var yamlSlot = singleton("YamlCodec");
3999
+ var jmespathSlot = singleton("JmespathCodec");
4000
+ async function loadOutputCodecsAsync(needed) {
4001
+ const loads = [];
4002
+ if (needed.yaml && yamlSlot.get() === undefined) {
4003
+ loads.push(import("./js-yaml-a2bk27p6.js").then((mod) => {
4004
+ yamlSlot.set(mod);
4005
+ }));
4006
+ }
4007
+ if (needed.filter && jmespathSlot.get() === undefined) {
4008
+ loads.push(import("./jmespath-ab6tdc42.js").then((m)=>__toESM(m.default,1)).then((mod) => {
4009
+ jmespathSlot.set(mod);
4010
+ }));
4011
+ }
4012
+ await Promise.all(loads);
4013
+ }
4014
+ function getYamlCodec() {
4015
+ return yamlSlot.get();
4016
+ }
4017
+ function getJmespathCodec() {
4018
+ return jmespathSlot.get();
4019
+ }
4020
+
4021
+ // ../common/src/output-format-context.ts
4022
+ var formatSlot = singleton("OutputFormat");
4023
+ var formatExplicitSlot = singleton("OutputFormatExplicit");
4024
+ var helpRequestedSlot = singleton("HelpRequested");
4025
+ var filterSlot = singleton("OutputFilter");
4026
+ function getOutputFormat() {
4027
+ return formatSlot.get("json");
4028
+ }
4029
+ function getOutputFormatExplicit() {
4030
+ return formatExplicitSlot.get(false) ?? false;
4031
+ }
4032
+ function getOutputFilter() {
4033
+ return filterSlot.get();
3361
4034
  }
3362
4035
 
3363
4036
  // ../common/src/telemetry/command-terminal.ts
@@ -3478,17 +4151,8 @@ function terminalSignalFor(input, outcome) {
3478
4151
  }
3479
4152
  return outcome === "cancelled" ? "SIGINT" : undefined;
3480
4153
  }
3481
- function classifyHttpStatus(status) {
3482
- if (status === 401 || status === 403) {
3483
- return "auth";
3484
- }
3485
- if (status === 400 || status === 409 || status === 422) {
3486
- return "validation";
3487
- }
3488
- if (status === 408) {
3489
- return "timeout";
3490
- }
3491
- return "network_http";
4154
+ function classifyFailingHttpStatus(status) {
4155
+ return classifyFromErrorCode(classifyHttpStatus(status)?.errorCode) ?? "network_http";
3492
4156
  }
3493
4157
  function classifyFromResult(result) {
3494
4158
  switch (result) {
@@ -3561,14 +4225,14 @@ function classifyFromError(error) {
3561
4225
  }
3562
4226
  return;
3563
4227
  }
3564
- function classifyError(input) {
4228
+ function classifyError2(input) {
3565
4229
  const recorded = input.recordedFailure;
3566
4230
  if (recorded?.errorClass) {
3567
4231
  return recorded.errorClass;
3568
4232
  }
3569
4233
  const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
3570
4234
  if (status !== undefined) {
3571
- return classifyHttpStatus(status);
4235
+ return classifyFailingHttpStatus(status);
3572
4236
  }
3573
4237
  return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
3574
4238
  }
@@ -3586,7 +4250,7 @@ function takeRecordedCommandFailureTelemetry() {
3586
4250
  function buildCommandTerminalTelemetryProperties(input) {
3587
4251
  const cancelled = isCancellationError(input.error, input.exitCode, input.pollSignal);
3588
4252
  const outcome = input.recordedFailure?.terminalOutcome ?? (input.exitCode === 0 ? "success" : cancelled ? "cancelled" : "failure");
3589
- const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError(input);
4253
+ const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError2(input);
3590
4254
  const terminalSignal = terminalSignalFor(input, outcome);
3591
4255
  return {
3592
4256
  [CommandDimensions.ExitCode]: input.exitCode,
@@ -3600,6 +4264,7 @@ function buildCommandTerminalTelemetryProperties(input) {
3600
4264
  var CommonTelemetryEvents = {
3601
4265
  Start: "Application.Start",
3602
4266
  Error: "Application.Error",
4267
+ ProjectActivity: "Cli.ProjectActivity",
3603
4268
  ShipSucceeded: "Cli.ShipSucceeded"
3604
4269
  };
3605
4270
 
@@ -4117,87 +4782,21 @@ class TelemetryService {
4117
4782
  return hex;
4118
4783
  }
4119
4784
  }
4120
- // ../common/src/timings.ts
4121
- var TIMINGS_ENV_VAR = "UIP_TIMINGS";
4122
- function createStorage2() {
4123
- const [error, mod] = catchError(() => __require("node:async_hooks"));
4124
- if (error || typeof mod?.AsyncLocalStorage !== "function") {
4125
- return {
4126
- getStore: () => {
4127
- return;
4128
- },
4129
- run: (_store, fn) => fn()
4130
- };
4131
- }
4132
- return new mod.AsyncLocalStorage;
4133
- }
4134
- var storageSlot = singleton("TimingStorage");
4135
- var stateSlot = singleton("Timings");
4136
- var rootStartedSlot = singleton("TimingsRootStarted");
4137
- var longLivedHostSlot = singleton("TimingsLongLivedHost");
4138
- var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
4139
- function newState(baseline) {
4140
- return { baseline, httpMs: 0, httpCalls: 0 };
4141
- }
4142
- function getState() {
4143
- const scoped = storage.getStore();
4144
- if (scoped) {
4145
- return scoped;
4146
- }
4147
- const pinned = livePinnedState();
4148
- if (pinned !== undefined) {
4149
- return pinned;
4150
- }
4151
- return newState(processStartIsInvocationStart() ? 0 : performance.now());
4152
- }
4153
- function livePinnedState() {
4154
- const pinned = stateSlot.get();
4155
- return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
4156
- }
4157
- function processStartIsInvocationStart() {
4158
- return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
4159
- }
4160
- function timingsEnabled() {
4161
- if (typeof process === "undefined") {
4162
- return false;
4163
- }
4164
- const value = process.env?.[TIMINGS_ENV_VAR];
4165
- if (value === undefined) {
4166
- return false;
4167
- }
4168
- const normalized = value.trim().toLowerCase();
4169
- return normalized === "1" || normalized === "true";
4170
- }
4171
- function recordExitCode(exitCode) {
4172
- if (!timingsEnabled()) {
4173
- return;
4174
- }
4175
- getState().exitCode = exitCode;
4176
- }
4177
- function invocationStartedAt() {
4178
- return new Date(performance.timeOrigin + getState().baseline);
4179
- }
4180
- function invocationElapsedMs() {
4181
- return performance.now() - getState().baseline;
4182
- }
4183
- function markCommandStart() {
4184
- if (!timingsEnabled()) {
4185
- return;
4186
- }
4187
- getState().commandStart = performance.now();
4188
- }
4189
- function recordCommandDuration(durationMs) {
4190
- if (!timingsEnabled()) {
4191
- return;
4192
- }
4193
- getState().commandMs = durationMs;
4194
- }
4195
4785
  // ../common/src/telemetry/proxy-http-agent.ts
4196
4786
  var slot = singleton("ProxyAuthHttpsAgent");
4197
4787
 
4198
4788
  // ../common/src/telemetry/node-appinsights-telemetry-provider.ts
4199
4789
  var providerSlot = singleton("TelemetryProvider");
4200
4790
 
4791
+ // ../common/src/telemetry/telemetry-config.ts
4792
+ function isTelemetryDisabled() {
4793
+ const value = process.env.UIPATH_TELEMETRY_DISABLED;
4794
+ return value === "1" || value === "true";
4795
+ }
4796
+ function isProjectTelemetryDisabled() {
4797
+ return isTelemetryDisabled() || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "1" || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "true";
4798
+ }
4799
+
4201
4800
  // ../common/src/telemetry/telemetry-spool.ts
4202
4801
  var sidecarEntrySlot = singleton("TelemetrySidecarEntry");
4203
4802
  var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
@@ -4233,7 +4832,6 @@ var telemetry = new Proxy({}, {
4233
4832
  return typeof value === "function" ? value.bind(instance) : value;
4234
4833
  }
4235
4834
  });
4236
-
4237
4835
  // ../common/src/formatter.ts
4238
4836
  var ANSI_STYLES = {
4239
4837
  red: "\x1B[31m",
@@ -4243,46 +4841,6 @@ var ANSI_RESET = "\x1B[0m";
4243
4841
  function styleLine(line, style) {
4244
4842
  return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
4245
4843
  }
4246
- var CLI_ERROR_CODES = [
4247
- "invalid_argument",
4248
- "authentication_required",
4249
- "permission_denied",
4250
- "local_permission_denied",
4251
- "not_found",
4252
- "rate_limited",
4253
- "network_error",
4254
- "timeout",
4255
- "server_error",
4256
- "method_not_allowed",
4257
- "not_supported",
4258
- "configuration_error",
4259
- "execution_failed",
4260
- "unknown_error"
4261
- ];
4262
- var RETRY_HINTS = [
4263
- "RetryWillNotFix",
4264
- "RetryLater",
4265
- "RetryAfter1Second",
4266
- "RetryAfter10Seconds",
4267
- "RetryAfter30Seconds",
4268
- "RetryAfter60Seconds"
4269
- ];
4270
- var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
4271
- var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
4272
- function isCliErrorCode(value) {
4273
- return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
4274
- }
4275
- function isRetryHint(value) {
4276
- return typeof value === "string" && RETRY_HINT_VALUES.has(value);
4277
- }
4278
- var RESULTS = {
4279
- Success: "Success",
4280
- Failure: "Failure",
4281
- ConfigError: "ConfigError",
4282
- AuthenticationError: "AuthenticationError",
4283
- ValidationError: "ValidationError",
4284
- TimeoutError: "TimeoutError"
4285
- };
4286
4844
  var EXIT_CODES = {
4287
4845
  Success: 0,
4288
4846
  Failure: 1,
@@ -4291,6 +4849,9 @@ var EXIT_CODES = {
4291
4849
  ValidationError: 3,
4292
4850
  TimeoutError: 4
4293
4851
  };
4852
+ function exitCodeForResult(result) {
4853
+ return EXIT_CODES[result] ?? EXIT_CODES.Failure;
4854
+ }
4294
4855
  function escapeNonAscii(jsonText) {
4295
4856
  return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
4296
4857
  const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
@@ -4966,8 +5527,8 @@ function carriesOnlyNulls(value) {
4966
5527
  }
4967
5528
  return false;
4968
5529
  }
4969
- function nameList(names, cap2 = 12) {
4970
- const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
5530
+ function nameList(names, cap = 12) {
5531
+ const shown = names.slice(0, cap).map((n) => `\`${n}\``);
4971
5532
  const rest = names.length - shown.length;
4972
5533
  return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
4973
5534
  }
@@ -5096,48 +5657,19 @@ function defaultErrorCodeForResult(result) {
5096
5657
  return "authentication_required";
5097
5658
  case RESULTS.ConfigError:
5098
5659
  return "configuration_error";
5099
- case RESULTS.ValidationError:
5100
- return "invalid_argument";
5101
- case RESULTS.TimeoutError:
5102
- return "timeout";
5103
- default:
5104
- return "unknown_error";
5105
- }
5106
- }
5107
- function parseHttpStatusFromMessage2(message) {
5108
- const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
5109
- if (!match)
5110
- return;
5111
- const status = Number(match[1]);
5112
- return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
5113
- }
5114
- function defaultErrorCodeForHttpStatus(status) {
5115
- if (status === undefined)
5116
- return;
5117
- if (status === 400 || status === 409 || status === 422) {
5118
- return "invalid_argument";
5119
- }
5120
- if (status === 401)
5121
- return "authentication_required";
5122
- if (status === 403)
5123
- return "permission_denied";
5124
- if (status === 404)
5125
- return "not_found";
5126
- if (status === 405)
5127
- return "method_not_allowed";
5128
- if (status === 408)
5129
- return "timeout";
5130
- if (status === 429)
5131
- return "rate_limited";
5132
- if (status >= 500 && status < 600)
5133
- return "server_error";
5134
- return;
5660
+ case RESULTS.ValidationError:
5661
+ return "invalid_argument";
5662
+ case RESULTS.TimeoutError:
5663
+ return "timeout";
5664
+ default:
5665
+ return "unknown_error";
5666
+ }
5135
5667
  }
5136
5668
  var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
5137
5669
  function defaultErrorCodeForFailure(data) {
5138
5670
  if (data.Result === RESULTS.Failure) {
5139
- const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
5140
- const errorCode = defaultErrorCodeForHttpStatus(status);
5671
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
5672
+ const errorCode = classifyHttpStatus(status)?.errorCode;
5141
5673
  if (errorCode)
5142
5674
  return errorCode;
5143
5675
  if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
@@ -5146,17 +5678,6 @@ function defaultErrorCodeForFailure(data) {
5146
5678
  }
5147
5679
  return defaultErrorCodeForResult(data.Result);
5148
5680
  }
5149
- function defaultRetryForErrorCode(errorCode) {
5150
- switch (errorCode) {
5151
- case "network_error":
5152
- case "rate_limited":
5153
- case "server_error":
5154
- case "timeout":
5155
- return "RetryLater";
5156
- default:
5157
- return "RetryWillNotFix";
5158
- }
5159
- }
5160
5681
  var OutputFormatter;
5161
5682
  ((OutputFormatter) => {
5162
5683
  function success(data, options) {
@@ -5188,7 +5709,7 @@ var OutputFormatter;
5188
5709
  data.Log ??= getLogFilePath() || undefined;
5189
5710
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
5190
5711
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
5191
- const exitCode = EXIT_CODES[data.Result] ?? 1;
5712
+ const exitCode = exitCodeForResult(data.Result);
5192
5713
  setExitCode(exitCode);
5193
5714
  recordCommandFailureTelemetry({
5194
5715
  result: data.Result,
@@ -5282,39 +5803,228 @@ var OutputFormatter;
5282
5803
  }
5283
5804
  OutputFormatter.formatToString = formatToString;
5284
5805
  })(OutputFormatter ||= {});
5285
- // ../../node_modules/commander/esm.mjs
5286
- var import__ = __toESM(require_commander(), 1);
5287
- var {
5288
- program,
5289
- createCommand,
5290
- createArgument,
5291
- createOption,
5292
- CommanderError,
5293
- InvalidArgumentError,
5294
- InvalidOptionArgumentError,
5295
- Command,
5296
- Argument,
5297
- Option,
5298
- Help
5299
- } = import__.default;
5300
5806
 
5301
- // ../common/src/command-examples.ts
5302
- var examplesByCommand = new WeakMap;
5303
- Command.prototype.examples = function(examples) {
5304
- examplesByCommand.set(this, examples);
5305
- return this;
5306
- };
5307
- // ../common/src/preview.ts
5308
- var previewSlot = singleton("PreviewBuild");
5309
- function isPreviewBuild() {
5310
- return previewSlot.get(false) ?? false;
5807
+ // ../common/src/pass-through-tail.ts
5808
+ function maybeOption(arg) {
5809
+ return arg.length > 1 && arg[0] === "-";
5810
+ }
5811
+ function tokenizeTail(cmd, tail) {
5812
+ const find = (flag) => cmd.options.find((option) => option.long === flag || option.short === flag);
5813
+ const digitShort = cmd.options.some((option) => option.short !== undefined && /^-\d$/.test(option.short));
5814
+ const negativeNumber = (arg) => !digitShort && /^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg);
5815
+ const tokens = [];
5816
+ let firstUnknown = -1;
5817
+ let sentinel = -1;
5818
+ let variadic;
5819
+ let group;
5820
+ let groupIndex = 0;
5821
+ let i = 0;
5822
+ while (i < tail.length || group !== undefined) {
5823
+ const index = group === undefined ? i : groupIndex;
5824
+ const arg = group ?? tail[i++];
5825
+ group = undefined;
5826
+ if (arg === "--") {
5827
+ sentinel = index;
5828
+ tokens.push({ kind: "sentinel", index });
5829
+ for (let j = i;j < tail.length; j++) {
5830
+ tokens.push({
5831
+ kind: "operand",
5832
+ index: j,
5833
+ text: tail[j],
5834
+ literal: true
5835
+ });
5836
+ }
5837
+ break;
5838
+ }
5839
+ if (variadic && (!maybeOption(arg) || negativeNumber(arg))) {
5840
+ tokens.push({
5841
+ kind: "option",
5842
+ index,
5843
+ text: arg,
5844
+ option: variadic,
5845
+ value: arg
5846
+ });
5847
+ continue;
5848
+ }
5849
+ variadic = undefined;
5850
+ if (maybeOption(arg)) {
5851
+ const option = find(arg);
5852
+ if (option) {
5853
+ let value;
5854
+ if (option.required) {
5855
+ value = tail[i];
5856
+ if (value !== undefined)
5857
+ i++;
5858
+ } else if (option.optional) {
5859
+ const next = tail[i];
5860
+ if (next !== undefined && (!maybeOption(next) || negativeNumber(next))) {
5861
+ value = next;
5862
+ i++;
5863
+ }
5864
+ }
5865
+ tokens.push({
5866
+ kind: "option",
5867
+ index,
5868
+ text: arg,
5869
+ option,
5870
+ ...value === undefined ? {} : { value }
5871
+ });
5872
+ variadic = option.variadic ? option : undefined;
5873
+ continue;
5874
+ }
5875
+ }
5876
+ if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
5877
+ const option = find(`-${arg[1]}`);
5878
+ if (option) {
5879
+ if (option.required || option.optional) {
5880
+ tokens.push({
5881
+ kind: "option",
5882
+ index,
5883
+ text: arg,
5884
+ option,
5885
+ value: arg.slice(2)
5886
+ });
5887
+ } else {
5888
+ tokens.push({ kind: "option", index, text: arg, option });
5889
+ group = `-${arg.slice(2)}`;
5890
+ groupIndex = index;
5891
+ }
5892
+ continue;
5893
+ }
5894
+ }
5895
+ if (/^--[^=]+=/.test(arg)) {
5896
+ const equals = arg.indexOf("=");
5897
+ const option = find(arg.slice(0, equals));
5898
+ if (option && (option.required || option.optional)) {
5899
+ tokens.push({
5900
+ kind: "option",
5901
+ index,
5902
+ text: arg,
5903
+ option,
5904
+ value: arg.slice(equals + 1)
5905
+ });
5906
+ continue;
5907
+ }
5908
+ }
5909
+ if (maybeOption(arg) && !negativeNumber(arg)) {
5910
+ const equals = arg.startsWith("--") ? arg.indexOf("=") : -1;
5911
+ if (firstUnknown === -1)
5912
+ firstUnknown = index;
5913
+ tokens.push({
5914
+ kind: "unknown",
5915
+ index,
5916
+ text: arg,
5917
+ flag: equals > 0 ? arg.slice(0, equals) : arg,
5918
+ ...equals > 0 ? { inlineValue: arg.slice(equals + 1) } : {}
5919
+ });
5920
+ continue;
5921
+ }
5922
+ tokens.push({ kind: "operand", index, text: arg, literal: false });
5923
+ }
5924
+ return { tokens, firstUnknown, sentinel };
5311
5925
  }
5312
- Command.prototype.previewCommand = function(nameAndArgs, opts) {
5313
- if (isPreviewBuild()) {
5314
- return this.command(nameAndArgs, opts);
5926
+
5927
+ // ../common/src/project-telemetry.ts
5928
+ var RESOLVER = Symbol.for("@uipath/common/projectTelemetryResolver");
5929
+ var CAPTURE = Symbol.for("@uipath/common/projectTelemetryCapture");
5930
+ var CONTEXT_RESOLVER = Symbol.for("@uipath/common/projectContextTelemetryResolver");
5931
+ var RULES = Symbol.for("@uipath/common/projectTargetRules");
5932
+ function logSkipped(what, error) {
5933
+ logger.debug(`[project-telemetry] ${what} skipped: ${error instanceof Error ? error.message : String(error)}`);
5934
+ }
5935
+ function bounded(work, what) {
5936
+ return withinProjectIdentityBudget(work, () => logSkipped(what, `no answer within ${PROJECT_IDENTITY_LOOKUP_BUDGET_MS} ms`));
5937
+ }
5938
+ async function identityWithContext(command, identity) {
5939
+ const props = projectIdentityProperties(identity);
5940
+ if (!identity.projectDirectory || isProjectTelemetryDisabled())
5941
+ return props;
5942
+ for (let node = command;node; node = node.parent ?? undefined) {
5943
+ const resolver = node[CONTEXT_RESOLVER];
5944
+ if (typeof resolver !== "function")
5945
+ continue;
5946
+ try {
5947
+ return {
5948
+ ...await resolver(identity.projectDirectory),
5949
+ ...props
5950
+ };
5951
+ } catch (error) {
5952
+ logSkipped("solution context lookup", error);
5953
+ return props;
5954
+ }
5315
5955
  }
5316
- return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
5317
- };
5956
+ return props;
5957
+ }
5958
+ function getProjectTelemetryResolver(command) {
5959
+ for (let node = command;node; node = node.parent) {
5960
+ const resolver = node[RESOLVER];
5961
+ if (typeof resolver === "function")
5962
+ return resolver;
5963
+ }
5964
+ return;
5965
+ }
5966
+ function attachProjectTelemetryCapture(command, capture) {
5967
+ command[CAPTURE] = capture;
5968
+ }
5969
+ class ProjectTelemetrySession {
5970
+ resolver;
5971
+ command;
5972
+ target;
5973
+ props = {};
5974
+ explicit = false;
5975
+ input;
5976
+ constructor(resolver, command) {
5977
+ this.resolver = resolver;
5978
+ this.command = command;
5979
+ }
5980
+ async setTarget(path) {
5981
+ this.target = path;
5982
+ if (this.input) {
5983
+ await this.resolve({
5984
+ ...this.input,
5985
+ phase: "after",
5986
+ success: true
5987
+ });
5988
+ this.explicit = true;
5989
+ }
5990
+ }
5991
+ async setIdentity(identity) {
5992
+ try {
5993
+ const props = await bounded(identityWithContext(this.command, identity), "project identity capture");
5994
+ if (props !== undefined)
5995
+ this.setProperties(props);
5996
+ } catch (error) {
5997
+ logSkipped("project identity capture", error);
5998
+ }
5999
+ }
6000
+ setProperties(properties) {
6001
+ try {
6002
+ this.props = { ...properties };
6003
+ this.explicit = true;
6004
+ } catch (error) {
6005
+ logSkipped("project identity properties", error);
6006
+ }
6007
+ }
6008
+ properties() {
6009
+ return { ...this.props };
6010
+ }
6011
+ async resolve(input) {
6012
+ this.input = input;
6013
+ if (this.explicit)
6014
+ return;
6015
+ try {
6016
+ const props = await bounded(this.resolver({
6017
+ ...input,
6018
+ target: this.target
6019
+ }), `project identity (${input.phase})`);
6020
+ if (props !== undefined) {
6021
+ this.props = props;
6022
+ }
6023
+ } catch (error) {
6024
+ logSkipped(`project identity (${input.phase})`, error);
6025
+ }
6026
+ }
6027
+ }
5318
6028
 
5319
6029
  // ../common/src/telemetry/command-attribution.ts
5320
6030
  var LEGACY_SKILL_NAMESPACE = "uipath:";
@@ -5560,8 +6270,7 @@ var pollSignalSlot = singleton("PollSignal");
5560
6270
  var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
5561
6271
  var processContext = {
5562
6272
  exit: (code) => {
5563
- recordExitCode(code);
5564
- setExitCode(code);
6273
+ recordCommandExit(code);
5565
6274
  },
5566
6275
  get pollSignal() {
5567
6276
  return pollSignalSlot.get();
@@ -5586,6 +6295,8 @@ function recordableArgValue(value, choices) {
5586
6295
  function extractCommandParams(cmd) {
5587
6296
  const params = {};
5588
6297
  forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
6298
+ if (name === undefined)
6299
+ return;
5589
6300
  const recordable = recordableArgValue(value, choices);
5590
6301
  params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
5591
6302
  });
@@ -5601,7 +6312,8 @@ function isDefaultedPositional(cmd, index) {
5601
6312
  function forEachSuppliedArgument(cmd, visit) {
5602
6313
  const registered = cmd.registeredArguments ?? [];
5603
6314
  const processed = cmd.processedArgs ?? [];
5604
- for (let i = 0;i < registered.length; i++) {
6315
+ const bound = boundPositionalCount(cmd);
6316
+ for (let i = 0;i < bound; i++) {
5605
6317
  const name = registered[i].name();
5606
6318
  if (name && processed[i] !== undefined) {
5607
6319
  visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
@@ -5616,6 +6328,71 @@ function forEachSuppliedArgument(cmd, visit) {
5616
6328
  visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
5617
6329
  }
5618
6330
  }
6331
+ forEachPassThroughToken(cmd, bound, (name, value) => {
6332
+ visit(name, value, name === undefined ? undefined : choicesByAttribute.get(name), false);
6333
+ });
6334
+ }
6335
+ function boundPositionalCount(cmd) {
6336
+ const registered = cmd.registeredArguments ?? [];
6337
+ if (registered.some((argument) => argument.variadic)) {
6338
+ return registered.length;
6339
+ }
6340
+ if ((cmd.args ?? []).length <= registered.length) {
6341
+ return registered.length;
6342
+ }
6343
+ const firstFlag = tokenizeTail(cmd, (cmd.args ?? []).slice(1)).tokens.find((token) => token.kind !== "operand")?.index ?? -1;
6344
+ return firstFlag === -1 ? registered.length : Math.min(registered.length, firstFlag + 1);
6345
+ }
6346
+ function forEachPassThroughToken(cmd, bound, visit) {
6347
+ const registered = cmd.registeredArguments ?? [];
6348
+ const fillsPositionals = !registered.some((argument) => argument.variadic);
6349
+ const { tokens, firstUnknown } = tokenizeTail(cmd, (cmd.args ?? []).slice(bound));
6350
+ const repeated = new Map;
6351
+ let nextPositional = bound;
6352
+ for (const token of tokens) {
6353
+ const pastUnknown = firstUnknown !== -1 && token.index > firstUnknown;
6354
+ if (token.kind === "sentinel")
6355
+ continue;
6356
+ if (token.kind === "operand") {
6357
+ const claimable = !pastUnknown && fillsPositionals && nextPositional < registered.length;
6358
+ const name = claimable ? registered[nextPositional++].name() : undefined;
6359
+ visit(name || undefined, token.text);
6360
+ continue;
6361
+ }
6362
+ if (token.kind === "unknown") {
6363
+ const bare = token.flag.replace(/^-+/, "");
6364
+ const key = bare.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
6365
+ const keyable = token.flag.startsWith("--") || token.flag.length === 2;
6366
+ if (!pastUnknown && keyable && /^[a-z][a-z0-9-]*$/i.test(bare) && key) {
6367
+ visit(key, token.inlineValue ?? true);
6368
+ } else {
6369
+ visit(undefined, token.text);
6370
+ if (token.inlineValue !== undefined) {
6371
+ visit(undefined, token.inlineValue);
6372
+ } else if (!token.flag.startsWith("--") && token.flag.length > 2) {
6373
+ visit(undefined, token.flag.slice(2));
6374
+ }
6375
+ }
6376
+ continue;
6377
+ }
6378
+ if (pastUnknown) {
6379
+ visit(undefined, token.text);
6380
+ if (token.value !== undefined)
6381
+ visit(undefined, token.value);
6382
+ continue;
6383
+ }
6384
+ const option = token.option;
6385
+ const name = option.attributeName();
6386
+ const value = option.negate ? false : option.required || option.optional ? token.value ?? true : true;
6387
+ const previous = repeated.get(name);
6388
+ if (previous) {
6389
+ previous.push(value);
6390
+ visit(name, previous);
6391
+ } else {
6392
+ repeated.set(name, [value]);
6393
+ visit(name, value);
6394
+ }
6395
+ }
5619
6396
  }
5620
6397
  function withheldArgumentValues(cmd) {
5621
6398
  const values = [];
@@ -5677,6 +6454,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5677
6454
  const telemetryName = commandTelemetryName(commandParts);
5678
6455
  const commandPath = commandInvocationPath(commandParts);
5679
6456
  const props = typeof properties === "function" ? properties(...args) : properties;
6457
+ const projectResolver = getProjectTelemetryResolver(command);
6458
+ const projectSession = projectResolver && !isProjectTelemetryDisabled() ? new ProjectTelemetrySession(projectResolver, command) : undefined;
5680
6459
  markCommandStart();
5681
6460
  const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
5682
6461
  try {
@@ -5689,6 +6468,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5689
6468
  if (violation) {
5690
6469
  return Promise.reject(violation);
5691
6470
  }
6471
+ if (projectSession) {
6472
+ return projectSession.resolve({ command, args, phase: "before" }).then(() => {
6473
+ attachProjectTelemetryCapture(command, projectSession);
6474
+ return fn(...args);
6475
+ });
6476
+ }
5692
6477
  return fn(...args);
5693
6478
  }));
5694
6479
  if (error) {
@@ -5697,22 +6482,26 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5697
6482
  const typed = error;
5698
6483
  const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
5699
6484
  const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
5700
- const finalResult = customResult ?? RESULTS.Failure;
6485
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
6486
+ const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
6487
+ const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
5701
6488
  const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
5702
6489
  const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
5703
6490
  const typedRetry = typed.retry ?? typed.Retry;
5704
6491
  const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
5705
6492
  const typedContext = typed.context ?? typed.Context;
5706
6493
  const customContext = isErrorContext(typedContext) ? typedContext : undefined;
5707
- const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
5708
6494
  fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
6495
+ const errorCode = customErrorCode ?? classified?.errorCode;
6496
+ const retry = customRetry ?? classified?.retry;
6497
+ const errorContext = customContext ?? classified?.context;
5709
6498
  OutputFormatter.error({
5710
6499
  Result: finalResult,
5711
- ...customErrorCode ? { ErrorCode: customErrorCode } : {},
6500
+ ...errorCode ? { ErrorCode: errorCode } : {},
5712
6501
  Message: errorMessage,
5713
6502
  Instructions: customInstructions ?? commandHelpHint(commandPath),
5714
- ...customRetry ? { Retry: customRetry } : {},
5715
- ...customContext ? { Context: customContext } : {}
6503
+ ...retry ? { Retry: retry } : {},
6504
+ ...errorContext ? { Context: errorContext } : {}
5716
6505
  });
5717
6506
  context.exit(fallbackExitCode);
5718
6507
  }
@@ -5721,6 +6510,14 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5721
6510
  const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
5722
6511
  const recordedFailure = takeRecordedCommandFailureTelemetry();
5723
6512
  const success = !error && exitCode === 0;
6513
+ if (projectSession) {
6514
+ await projectSession.resolve({
6515
+ command,
6516
+ args,
6517
+ phase: "after",
6518
+ success
6519
+ });
6520
+ }
5724
6521
  const terminalTelemetry = buildCommandTerminalTelemetryProperties({
5725
6522
  error,
5726
6523
  exitCode,
@@ -5738,6 +6535,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5738
6535
  }
5739
6536
  const baseProperties = redactProperties({
5740
6537
  ...commandParams,
6538
+ ...projectSession?.properties(),
5741
6539
  ...props,
5742
6540
  ...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
5743
6541
  ...buildAgentSessionTelemetry(process.env),
@@ -5748,6 +6546,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5748
6546
  });
5749
6547
  emitInvocationRequest(telemetryName, success, baseProperties);
5750
6548
  } finally {
6549
+ if (projectSession)
6550
+ attachProjectTelemetryCapture(command, undefined);
5751
6551
  releaseSuppliedArgumentValues(supplied);
5752
6552
  }
5753
6553
  });
@@ -6062,11 +6862,11 @@ var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
6062
6862
  var factorySlot = singleton("PackagerFactoryProvider");
6063
6863
  // ../uipath-python-bridge/src/cache.ts
6064
6864
  async function readCache(cacheFile) {
6065
- const fs2 = getFileSystem();
6066
- const [existsError, exists] = await catchError(fs2.exists(cacheFile));
6865
+ const fs = getFileSystem();
6866
+ const [existsError, exists] = await catchError(fs.exists(cacheFile));
6067
6867
  if (existsError || !exists)
6068
6868
  return null;
6069
- const [readError, content] = await catchError(fs2.readFile(cacheFile, "utf-8"));
6869
+ const [readError, content] = await catchError(fs.readFile(cacheFile, "utf-8"));
6070
6870
  if (readError) {
6071
6871
  logger.warn(`Failed to load cache: ${readError}`);
6072
6872
  return null;
@@ -6078,11 +6878,63 @@ async function readCache(cacheFile) {
6078
6878
  }
6079
6879
  return cache;
6080
6880
  }
6881
+ // ../uipath-python-bridge/package.json
6882
+ var package_default = {
6883
+ name: "@uipath/uipath-python-bridge",
6884
+ author: "UiPath",
6885
+ license: "SEE LICENSE IN LICENSE.txt",
6886
+ version: "1.206.0-preview.279",
6887
+ description: "Shared Python detection, caching, and CLI bridge for UiPath Python SDK tools.",
6888
+ keywords: [
6889
+ "uip",
6890
+ "python",
6891
+ "bridge"
6892
+ ],
6893
+ uipath: {
6894
+ requires: {
6895
+ uipath: ">=2.14.41"
6896
+ }
6897
+ },
6898
+ type: "module",
6899
+ main: "./dist/index.js",
6900
+ exports: {
6901
+ ".": "./dist/index.js"
6902
+ },
6903
+ files: [
6904
+ "dist"
6905
+ ],
6906
+ repository: {
6907
+ type: "git",
6908
+ url: "https://github.com/UiPath/cli.git",
6909
+ directory: "packages/uipath-python-bridge"
6910
+ },
6911
+ publishConfig: {
6912
+ registry: "https://npm.pkg.github.com/@uipath"
6913
+ },
6914
+ scripts: {
6915
+ build: "bun build ./src/index.ts --outdir dist --format esm --target node --external applicationinsights --sourcemap=linked",
6916
+ typecheck: "tsc --noEmit",
6917
+ test: "vitest run",
6918
+ "test:coverage": "vitest run --coverage",
6919
+ lint: "biome check .",
6920
+ "lint:fix": "biome check --write ."
6921
+ },
6922
+ devDependencies: {
6923
+ "@uipath/auth": "workspace:*",
6924
+ "@uipath/common": "workspace:*",
6925
+ "@uipath/filesystem": "workspace:*",
6926
+ "@types/bun": "^1.3.11",
6927
+ commander: "^14.0.3",
6928
+ typescript: "^7.0.2"
6929
+ }
6930
+ };
6931
+
6081
6932
  // ../uipath-python-bridge/src/config.ts
6082
6933
  var DEFAULT_CONFIG = {
6083
- allowedPythonVersions: ["3.14", "3.13", "3.12", "3.11"],
6934
+ allowedPythonVersions: ["3.14", "3.13", "3.12", "3.11", "3.15"],
6084
6935
  packageName: "uipath",
6085
- cacheFileName: ".uipath-python-cache.json"
6936
+ cacheFileName: ".uipath-python-cache.json",
6937
+ uipathVersionRequirement: package_default.uipath.requires.uipath
6086
6938
  };
6087
6939
  function getAllowedPythonVersions() {
6088
6940
  const envVersions = process.env.PYTHON_TOOL_PYTHON_VERSIONS;
@@ -6097,6 +6949,9 @@ function getPackageName() {
6097
6949
  function getCacheFileName() {
6098
6950
  return DEFAULT_CONFIG.cacheFileName;
6099
6951
  }
6952
+ function getUipathVersionRequirement() {
6953
+ return DEFAULT_CONFIG.uipathVersionRequirement;
6954
+ }
6100
6955
  function matchesPattern(args, pattern) {
6101
6956
  if (typeof pattern === "string") {
6102
6957
  return args.includes(pattern);
@@ -6308,9 +7163,9 @@ function getProfileStorage() {
6308
7163
  if (isAuthProfileStorage(existing)) {
6309
7164
  return existing;
6310
7165
  }
6311
- const storage2 = createProfileStorage();
6312
- globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage2;
6313
- return storage2;
7166
+ const storage = createProfileStorage();
7167
+ globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
7168
+ return storage;
6314
7169
  }
6315
7170
  var profileStorage = getProfileStorage();
6316
7171
 
@@ -6341,8 +7196,8 @@ function resolveAuthProfileFilePath(profile) {
6341
7196
  if (normalized === undefined) {
6342
7197
  throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
6343
7198
  }
6344
- const fs2 = getFileSystem();
6345
- return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR2, PROFILE_DIR, normalized, AUTH_FILENAME);
7199
+ const fs = getFileSystem();
7200
+ return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR2, PROFILE_DIR, normalized, AUTH_FILENAME);
6346
7201
  }
6347
7202
  function getActiveAuthProfileFilePath() {
6348
7203
  const profile = getActiveAuthProfile();
@@ -6515,6 +7370,8 @@ var ENV_AUTH_VARS = {
6515
7370
  };
6516
7371
 
6517
7372
  class EnvAuthConfigError extends Error {
7373
+ errorCode = "configuration_error";
7374
+ retry = "RetryWillNotFix";
6518
7375
  constructor(message) {
6519
7376
  super(message);
6520
7377
  this.name = "EnvAuthConfigError";
@@ -6553,11 +7410,11 @@ var readAuthFromEnv = () => {
6553
7410
  if (!rawUrl) {
6554
7411
  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}).`);
6555
7412
  }
6556
- const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
7413
+ const baseUrl = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
6557
7414
  return {
6558
7415
  loginStatus: "Logged in",
6559
7416
  accessToken,
6560
- baseUrl: baseUrl2,
7417
+ baseUrl,
6561
7418
  organizationName,
6562
7419
  organizationId,
6563
7420
  tenantName,
@@ -6598,8 +7455,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
6598
7455
  async function refreshTokenFingerprint(refreshToken) {
6599
7456
  const bytes = new TextEncoder().encode(refreshToken);
6600
7457
  if (globalThis.crypto?.subtle) {
6601
- const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
6602
- return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
7458
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
7459
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
6603
7460
  }
6604
7461
  const { createHash } = await import("node:crypto");
6605
7462
  return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
@@ -6608,9 +7465,9 @@ function breakerPathFor(authPath) {
6608
7465
  return `${authPath}${BREAKER_SUFFIX}`;
6609
7466
  }
6610
7467
  async function loadRefreshBreaker(authPath) {
6611
- const fs2 = getFileSystem();
7468
+ const fs = getFileSystem();
6612
7469
  try {
6613
- const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
7470
+ const content = await fs.readFile(breakerPathFor(authPath), "utf-8");
6614
7471
  if (!content)
6615
7472
  return {};
6616
7473
  const parsed = JSON.parse(content);
@@ -6621,20 +7478,20 @@ async function loadRefreshBreaker(authPath) {
6621
7478
  }
6622
7479
  async function saveRefreshBreaker(authPath, state) {
6623
7480
  try {
6624
- const fs2 = getFileSystem();
6625
- const path2 = breakerPathFor(authPath);
6626
- await fs2.mkdir(fs2.path.dirname(path2));
6627
- const tempPath = `${path2}.tmp`;
6628
- await fs2.writeFile(tempPath, JSON.stringify(state));
6629
- await fs2.rename(tempPath, path2);
7481
+ const fs = getFileSystem();
7482
+ const path = breakerPathFor(authPath);
7483
+ await fs.mkdir(fs.path.dirname(path));
7484
+ const tempPath = `${path}.tmp`;
7485
+ await fs.writeFile(tempPath, JSON.stringify(state));
7486
+ await fs.rename(tempPath, path);
6630
7487
  } catch {}
6631
7488
  }
6632
7489
  async function clearRefreshBreaker(authPath) {
6633
- const fs2 = getFileSystem();
6634
- const path2 = breakerPathFor(authPath);
7490
+ const fs = getFileSystem();
7491
+ const path = breakerPathFor(authPath);
6635
7492
  try {
6636
- if (await fs2.exists(path2)) {
6637
- await fs2.rm(path2);
7493
+ if (await fs.exists(path)) {
7494
+ await fs.rm(path);
6638
7495
  }
6639
7496
  } catch {}
6640
7497
  }
@@ -6655,13 +7512,13 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
6655
7512
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
6656
7513
  var PIPE_NAME_MAX_LENGTH = 103;
6657
7514
  var getRobotIpcPipeNames = async () => {
6658
- const fs2 = getFileSystem();
6659
- const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
7515
+ const fs = getFileSystem();
7516
+ const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
6660
7517
  if (!username) {
6661
7518
  throw new Error("Unable to determine current username");
6662
7519
  }
6663
- const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
6664
- return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
7520
+ const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
7521
+ return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
6665
7522
  };
6666
7523
  var defaultIsRobotIpcAvailable = async () => {
6667
7524
  if (process.platform === "win32") {
@@ -6671,20 +7528,20 @@ var defaultIsRobotIpcAvailable = async () => {
6671
7528
  if (pipeNamesError || !pipeNames) {
6672
7529
  return false;
6673
7530
  }
6674
- const fs2 = getFileSystem();
7531
+ const fs = getFileSystem();
6675
7532
  for (const pipeName of pipeNames) {
6676
- const [existsError, exists] = await catchError2(fs2.exists(pipeName));
7533
+ const [existsError, exists] = await catchError2(fs.exists(pipeName));
6677
7534
  if (!existsError && exists === true) {
6678
7535
  return true;
6679
7536
  }
6680
7537
  }
6681
7538
  return false;
6682
7539
  };
6683
- var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
7540
+ var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
6684
7541
  const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
6685
7542
  promise.then((value) => {
6686
7543
  clearTimeout(timer);
6687
- resolve2(value);
7544
+ resolve(value);
6688
7545
  }, (error) => {
6689
7546
  clearTimeout(timer);
6690
7547
  reject(error);
@@ -6857,9 +7714,12 @@ var refreshAccessToken = async ({
6857
7714
  body: tokenParams
6858
7715
  });
6859
7716
  const tokenData = await tokenResponse.json();
6860
- if (!tokenResponse.ok) {
7717
+ if (tokenResponse.status === 400 || tokenResponse.status === 401) {
6861
7718
  throw new TokenRefreshOAuthError;
6862
7719
  }
7720
+ if (!tokenResponse.ok) {
7721
+ throw new Error(`Token refresh failed: HTTP ${tokenResponse.status}`);
7722
+ }
6863
7723
  const newAccessToken = tokenData.access_token;
6864
7724
  const newRefreshToken = tokenData.refresh_token;
6865
7725
  if (typeof newAccessToken !== "string" || typeof newRefreshToken !== "string") {
@@ -6891,9 +7751,9 @@ var errorCode = (err) => {
6891
7751
  }
6892
7752
  return "EUNKNOWN";
6893
7753
  };
6894
- var probeAsync = async (fs2, candidate) => {
7754
+ var probeAsync = async (fs, candidate) => {
6895
7755
  try {
6896
- const stats = await fs2.stat(candidate);
7756
+ const stats = await fs.stat(candidate);
6897
7757
  if (stats === null) {
6898
7758
  return { exists: false };
6899
7759
  }
@@ -6920,36 +7780,36 @@ var probeAsync = async (fs2, candidate) => {
6920
7780
  }
6921
7781
  };
6922
7782
  var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
6923
- const fs2 = getFileSystem();
6924
- if (fs2.path.isAbsolute(envFilePath)) {
6925
- const probe2 = await probeAsync(fs2, envFilePath);
6926
- return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
7783
+ const fs = getFileSystem();
7784
+ if (fs.path.isAbsolute(envFilePath)) {
7785
+ const probe = await probeAsync(fs, envFilePath);
7786
+ return probe.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
6927
7787
  exists: false,
6928
7788
  absolutePath: envFilePath,
6929
7789
  source: "absolute",
6930
- ...probe2.unusable ? { unusable: probe2.unusable } : {}
7790
+ ...probe.unusable ? { unusable: probe.unusable } : {}
6931
7791
  };
6932
7792
  }
6933
- const cwd = opts?.cwd ?? fs2.env.cwd();
7793
+ const cwd = opts?.cwd ?? fs.env.cwd();
6934
7794
  let searchDir = cwd;
6935
7795
  while (true) {
6936
- const candidate = fs2.path.join(searchDir, envFilePath);
6937
- const probe2 = await probeAsync(fs2, candidate);
6938
- if (probe2.exists) {
7796
+ const candidate = fs.path.join(searchDir, envFilePath);
7797
+ const probe = await probeAsync(fs, candidate);
7798
+ if (probe.exists) {
6939
7799
  return {
6940
7800
  exists: true,
6941
7801
  absolutePath: candidate,
6942
7802
  source: searchDir === cwd ? "cwd" : "ancestor"
6943
7803
  };
6944
7804
  }
6945
- const parentDir = fs2.path.dirname(searchDir);
7805
+ const parentDir = fs.path.dirname(searchDir);
6946
7806
  if (parentDir === searchDir) {
6947
7807
  break;
6948
7808
  }
6949
7809
  searchDir = parentDir;
6950
7810
  }
6951
- const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
6952
- const probe = await probeAsync(fs2, homePath);
7811
+ const homePath = fs.path.join(fs.env.homedir(), envFilePath);
7812
+ const probe = await probeAsync(fs, homePath);
6953
7813
  if (probe.exists) {
6954
7814
  return { exists: true, absolutePath: homePath, source: "home" };
6955
7815
  }
@@ -6992,12 +7852,12 @@ var parseEnvContent = (content) => {
6992
7852
  return env;
6993
7853
  };
6994
7854
  var loadEnvFileAsync = async ({ envPath }) => {
6995
- const fs2 = getFileSystem();
6996
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
6997
- if (!await fs2.exists(absolutePath)) {
7855
+ const fs = getFileSystem();
7856
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
7857
+ if (!await fs.exists(absolutePath)) {
6998
7858
  throw new Error(`Environment file not found: ${envPath}`);
6999
7859
  }
7000
- const content = await fs2.readFile(absolutePath, "utf-8");
7860
+ const content = await fs.readFile(absolutePath, "utf-8");
7001
7861
  if (content === null) {
7002
7862
  throw new Error(`Environment file not found: ${envPath}`);
7003
7863
  }
@@ -7008,10 +7868,10 @@ var saveEnvFileAsync = async ({
7008
7868
  data,
7009
7869
  merge = true
7010
7870
  }) => {
7011
- const fs2 = getFileSystem();
7012
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
7871
+ const fs = getFileSystem();
7872
+ const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
7013
7873
  let existingData = {};
7014
- if (merge && await fs2.exists(absolutePath)) {
7874
+ if (merge && await fs.exists(absolutePath)) {
7015
7875
  try {
7016
7876
  existingData = await loadEnvFileAsync({ envPath: absolutePath });
7017
7877
  } catch {}
@@ -7029,11 +7889,11 @@ var saveEnvFileAsync = async ({
7029
7889
  const content = `${lines.join(`
7030
7890
  `)}
7031
7891
  `;
7032
- const dir = fs2.path.dirname(absolutePath);
7033
- await fs2.mkdir(dir);
7892
+ const dir = fs.path.dirname(absolutePath);
7893
+ await fs.mkdir(dir);
7034
7894
  const tempPath = `${absolutePath}.tmp`;
7035
- await fs2.writeFile(tempPath, content);
7036
- await fs2.rename(tempPath, absolutePath);
7895
+ await fs.writeFile(tempPath, content);
7896
+ await fs.rename(tempPath, absolutePath);
7037
7897
  };
7038
7898
 
7039
7899
  // ../auth/src/loginStatus.ts
@@ -7157,11 +8017,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
7157
8017
  return { credentials };
7158
8018
  }
7159
8019
  async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
7160
- const fs2 = getFs();
7161
- const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
8020
+ const fs = getFs();
8021
+ const globalPath = fs.path.join(fs.env.homedir(), envFilePath);
7162
8022
  if (absolutePath === globalPath)
7163
8023
  return;
7164
- if (!await fs2.exists(globalPath))
8024
+ if (!await fs.exists(globalPath))
7165
8025
  return;
7166
8026
  try {
7167
8027
  const globalCreds = await loadEnvFile({ envPath: globalPath });
@@ -7592,7 +8452,7 @@ var getAuthEnv = async (options = {}) => {
7592
8452
  const org = status.organizationName || status.organizationId;
7593
8453
  const tenant = status.tenantName || status.tenantId;
7594
8454
  if (org && tenant) {
7595
- authEnv.UIPATH_URL = `${status.baseUrl.replace(/\/+$/, "")}/${org}/${tenant}`;
8455
+ authEnv.UIPATH_URL = `${status.baseUrl.replace(/\/+$/, "")}/${encodeURIComponent(org)}/${encodeURIComponent(tenant)}`;
7596
8456
  }
7597
8457
  }
7598
8458
  if (status.organizationId)
@@ -7622,7 +8482,7 @@ function hasTypeOption(args) {
7622
8482
  return args.some((arg) => TYPE_OPTION.test(arg));
7623
8483
  }
7624
8484
  async function supportsNewTypeOption(exePath, cwd, env = {}, signal) {
7625
- return new Promise((resolve2) => {
8485
+ return new Promise((resolve) => {
7626
8486
  execFile(exePath, ["new", "--help"], {
7627
8487
  cwd,
7628
8488
  env: { ...process.env, ...env },
@@ -7630,10 +8490,136 @@ async function supportsNewTypeOption(exePath, cwd, env = {}, signal) {
7630
8490
  windowsHide: true,
7631
8491
  signal
7632
8492
  }, (error, stdout) => {
7633
- resolve2(!error && TYPE_LISTED.test(typeof stdout === "string" ? stdout : ""));
8493
+ resolve(!error && TYPE_LISTED.test(typeof stdout === "string" ? stdout : ""));
8494
+ });
8495
+ });
8496
+ }
8497
+
8498
+ // ../uipath-python-bridge/src/uipath-version.ts
8499
+ import { execFile as execFile2 } from "node:child_process";
8500
+
8501
+ // ../uipath-python-bridge/src/package-version.ts
8502
+ var VERSION_RE = /^v?(\d+)\.(\d+)(?:\.(\d+))?/;
8503
+ function parseSimpleVersion(raw) {
8504
+ const match = raw.trim().match(VERSION_RE);
8505
+ if (!match)
8506
+ return null;
8507
+ return {
8508
+ major: Number(match[1]),
8509
+ minor: Number(match[2]),
8510
+ patch: match[3] === undefined ? 0 : Number(match[3])
8511
+ };
8512
+ }
8513
+ function compareSimpleVersion(a, b) {
8514
+ return a.major - b.major || a.minor - b.minor || a.patch - b.patch;
8515
+ }
8516
+ var MINIMUM_RE = /^>=\s*(\d+)\.(\d+)\.(\d+)$/;
8517
+ function parseMinimumVersion(specifier) {
8518
+ const match = specifier.trim().match(MINIMUM_RE);
8519
+ if (!match)
8520
+ return null;
8521
+ return {
8522
+ major: Number(match[1]),
8523
+ minor: Number(match[2]),
8524
+ patch: Number(match[3])
8525
+ };
8526
+ }
8527
+ function formatSimpleVersion(version) {
8528
+ return `${version.major}.${version.minor}.${version.patch}`;
8529
+ }
8530
+
8531
+ // ../uipath-python-bridge/src/uipath-version.ts
8532
+ var VERSION_LINE = /uipath\s+version\s+(\S+)/i;
8533
+ async function probeUipathVersion(exePath, options = {}) {
8534
+ return new Promise((resolve) => {
8535
+ execFile2(exePath, ["--version"], {
8536
+ cwd: options.cwd,
8537
+ encoding: "utf-8",
8538
+ windowsHide: true,
8539
+ signal: options.signal
8540
+ }, (error, stdout, stderr) => {
8541
+ const out = typeof stdout === "string" ? stdout.trim() : "";
8542
+ const err = typeof stderr === "string" ? stderr.trim() : "";
8543
+ if (error) {
8544
+ resolve({ error: describeProbeError(exePath, error, err) });
8545
+ return;
8546
+ }
8547
+ const match = out.match(VERSION_LINE);
8548
+ if (!match) {
8549
+ resolve({
8550
+ error: `Could not parse version from '${exePath} --version' output: ${out || "<empty>"}`
8551
+ });
8552
+ return;
8553
+ }
8554
+ resolve({ version: match[1] });
7634
8555
  });
7635
8556
  });
7636
8557
  }
8558
+ function describeProbeError(exePath, error, stderr) {
8559
+ if (typeof error.code === "number") {
8560
+ return `'${exePath} --version' exited with code ${error.code}${stderr ? `: ${stderr}` : ""}`;
8561
+ }
8562
+ return `Failed to run '${exePath} --version': ${error.message}`;
8563
+ }
8564
+ function resolveRequirement() {
8565
+ const requirement = getUipathVersionRequirement();
8566
+ const minimum = parseMinimumVersion(requirement);
8567
+ if (!minimum) {
8568
+ return {
8569
+ requirement,
8570
+ invalid: {
8571
+ ok: false,
8572
+ kind: "unverifiable",
8573
+ requirement,
8574
+ message: `Invalid uipath version requirement '${requirement}' declared by @uipath/uipath-python-bridge.`
8575
+ }
8576
+ };
8577
+ }
8578
+ return { requirement, minimum };
8579
+ }
8580
+ function judge(version, exePath, requirement, minimum) {
8581
+ const parsed = parseSimpleVersion(version);
8582
+ if (!parsed) {
8583
+ return {
8584
+ ok: false,
8585
+ kind: "unverifiable",
8586
+ requirement,
8587
+ message: `Could not read uipath version '${version}' reported by ${exePath}.`
8588
+ };
8589
+ }
8590
+ if (compareSimpleVersion(parsed, minimum) < 0) {
8591
+ return {
8592
+ ok: false,
8593
+ kind: "unsupported",
8594
+ version,
8595
+ requirement,
8596
+ message: `uipath ${version} found at ${exePath}; ${formatSimpleVersion(minimum)} or later is required.`
8597
+ };
8598
+ }
8599
+ return { ok: true, version, requirement };
8600
+ }
8601
+ async function checkUipathVersion(exePath, options = {}) {
8602
+ const resolved = resolveRequirement();
8603
+ if ("invalid" in resolved)
8604
+ return resolved.invalid;
8605
+ const probe = await probeUipathVersion(exePath, options);
8606
+ if ("error" in probe) {
8607
+ return {
8608
+ ok: false,
8609
+ kind: "unverifiable",
8610
+ requirement: resolved.requirement,
8611
+ message: probe.error
8612
+ };
8613
+ }
8614
+ return judge(probe.version, exePath, resolved.requirement, resolved.minimum);
8615
+ }
8616
+ function uipathVersionInstructions(check, toolName) {
8617
+ const setupHint = `then re-run 'uip ${toolName} setup --force'`;
8618
+ if (check.kind === "unverifiable") {
8619
+ return `Make sure the uipath package is installed and runnable in that environment, ${setupHint}.`;
8620
+ }
8621
+ return `Upgrade uipath, ${setupHint}.`;
8622
+ }
7637
8623
 
7638
8624
  // ../uipath-python-bridge/src/execute.ts
7639
8625
  var ENV_FILE_NAME = ".env";
@@ -7661,8 +8647,8 @@ function envValueFromFile(content, name) {
7661
8647
  if (!line || line.startsWith("#")) {
7662
8648
  return false;
7663
8649
  }
7664
- const [key, ...valueParts2] = line.split("=");
7665
- return key.trim() === name && valueParts2.join("=").trim().length > 0;
8650
+ const [key, ...valueParts] = line.split("=");
8651
+ return key.trim() === name && valueParts.join("=").trim().length > 0;
7666
8652
  });
7667
8653
  if (!envLine) {
7668
8654
  return null;
@@ -7670,16 +8656,16 @@ function envValueFromFile(content, name) {
7670
8656
  const [, ...valueParts] = envLine.split("=");
7671
8657
  return valueParts.join("=").trim().replace(/^["']|["']$/g, "") || null;
7672
8658
  }
7673
- async function getConfiguredEnvValue(fs2, name) {
8659
+ async function getConfiguredEnvValue(fs, name) {
7674
8660
  const processValue = process.env[name]?.trim();
7675
8661
  if (processValue) {
7676
8662
  return processValue;
7677
8663
  }
7678
- const envPath = fs2.path.join(fs2.env.cwd(), ENV_FILE_NAME);
7679
- if (!await fs2.exists(envPath)) {
8664
+ const envPath = fs.path.join(fs.env.cwd(), ENV_FILE_NAME);
8665
+ if (!await fs.exists(envPath)) {
7680
8666
  return null;
7681
8667
  }
7682
- const [readError, content] = await catchError(fs2.readFile(envPath, "utf-8"));
8668
+ const [readError, content] = await catchError(fs.readFile(envPath, "utf-8"));
7683
8669
  return !readError && typeof content === "string" ? envValueFromFile(content, name) : null;
7684
8670
  }
7685
8671
  var fail = (reason, message, instructions, extras = {}) => ({
@@ -7701,8 +8687,8 @@ function childStdio(stdio) {
7701
8687
  }
7702
8688
  }
7703
8689
  async function runUipathPythonCommand(args, options = {}) {
7704
- const fs2 = getFileSystem();
7705
- const cacheFile = fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
8690
+ const fs = getFileSystem();
8691
+ const cacheFile = fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
7706
8692
  const toolLabel = options.toolName ?? options.commandPrefix ?? "codedagent";
7707
8693
  const setupCommand = `uip ${toolLabel} setup`;
7708
8694
  const setupHint = `Run '${setupCommand}' first to configure the environment. ` + `Activate the project's virtual environment and run ${setupCommand} --force.`;
@@ -7710,7 +8696,7 @@ async function runUipathPythonCommand(args, options = {}) {
7710
8696
  if (!cache?.uipathExePath) {
7711
8697
  return fail("python_not_configured", "Python not configured.", setupHint);
7712
8698
  }
7713
- if (!await fs2.exists(cache.uipathExePath)) {
8699
+ if (!await fs.exists(cache.uipathExePath)) {
7714
8700
  return fail("uipath_exe_missing", "uipath executable not found. Please install it using 'pip install uipath' or 'uv add uipath'.", setupHint);
7715
8701
  }
7716
8702
  const processed = processCommandArgs(args, options.commandRules ?? []);
@@ -7728,21 +8714,21 @@ async function runUipathPythonCommand(args, options = {}) {
7728
8714
  if (!applies) {
7729
8715
  continue;
7730
8716
  }
7731
- const value = await getConfiguredEnvValue(fs2, requirement.name);
8717
+ const value = await getConfiguredEnvValue(fs, requirement.name);
7732
8718
  if (!value) {
7733
8719
  return fail("required_env_missing", `${requirement.name} environment variable not found.`, requirement.instructions);
7734
8720
  }
7735
8721
  requiredEnv[requirement.name] = value;
7736
8722
  }
7737
- const { authEnv, loginStatus: loginStatus2 } = await getAuthEnv();
7738
- if (!loginStatus2) {
8723
+ const { authEnv, loginStatus } = await getAuthEnv();
8724
+ if (!loginStatus) {
7739
8725
  logger.debug("Auth unavailable, continuing without credentials.");
7740
8726
  }
7741
8727
  if (options.commandPreflight) {
7742
8728
  const preflight = options.commandPreflight;
7743
8729
  const [preflightError, preflightResult] = await catchError(Promise.resolve().then(() => preflight({
7744
8730
  args: commandArgs,
7745
- loginStatus: loginStatus2,
8731
+ loginStatus,
7746
8732
  authEnv
7747
8733
  })));
7748
8734
  if (preflightError) {
@@ -7753,7 +8739,15 @@ async function runUipathPythonCommand(args, options = {}) {
7753
8739
  }
7754
8740
  }
7755
8741
  const stdio = options.stdio ?? "inherit";
7756
- const cwd = options.cwd ?? fs2.env.cwd();
8742
+ const cwd = options.cwd ?? fs.env.cwd();
8743
+ const versionCheck = await checkUipathVersion(cache.uipathExePath, {
8744
+ cwd,
8745
+ signal: options.signal
8746
+ });
8747
+ if (!versionCheck.ok) {
8748
+ return fail(versionCheck.kind === "unsupported" ? "uipath_version_unsupported" : "uipath_version_unverifiable", versionCheck.message, uipathVersionInstructions(versionCheck, toolLabel));
8749
+ }
8750
+ logger.debug(`Using uipath ${versionCheck.version} at ${cache.uipathExePath} (source: ${cache.source ?? "unknown"}; requires uipath${versionCheck.requirement})`);
7757
8751
  if (options.pinNewType && processed.args[0] === "new" && !isHelpCommand(processed.args) && await supportsNewTypeOption(cache.uipathExePath, cwd, { ...authEnv, ...requiredEnv }, options.signal)) {
7758
8752
  commandArgs.push("--type", options.pinNewType);
7759
8753
  }
@@ -7784,8 +8778,8 @@ async function runUipathPythonCommand(args, options = {}) {
7784
8778
  getOutputSink().writeErr(chunk);
7785
8779
  });
7786
8780
  }
7787
- const [spawnError, exitCode] = await catchError(new Promise((resolve2, reject) => {
7788
- proc.on("close", (code) => resolve2(code ?? 1));
8781
+ const [spawnError, exitCode] = await catchError(new Promise((resolve, reject) => {
8782
+ proc.on("close", (code) => resolve(code ?? 1));
7789
8783
  proc.on("error", reject);
7790
8784
  }));
7791
8785
  if (spawnError) {
@@ -7802,6 +8796,7 @@ async function runUipathPythonCommand(args, options = {}) {
7802
8796
  return {
7803
8797
  ok: true,
7804
8798
  pythonExePath: cache.uipathExePath,
8799
+ uipathVersion: versionCheck.version,
7805
8800
  exitCode: 0,
7806
8801
  stdout: stdio === "pipe" ? stdout : undefined,
7807
8802
  stderr: stdio === "pipe" ? stderr : undefined
@@ -7810,6 +8805,8 @@ async function runUipathPythonCommand(args, options = {}) {
7810
8805
  var CLI_RESULT_BY_REASON = {
7811
8806
  python_not_configured: RESULTS.ConfigError,
7812
8807
  uipath_exe_missing: RESULTS.ConfigError,
8808
+ uipath_version_unsupported: RESULTS.ConfigError,
8809
+ uipath_version_unverifiable: RESULTS.ConfigError,
7813
8810
  command_disabled: RESULTS.ValidationError,
7814
8811
  new_type_not_allowed: RESULTS.ValidationError,
7815
8812
  required_env_missing: RESULTS.ConfigError,
@@ -7845,8 +8842,8 @@ function createExecuteCommand(config) {
7845
8842
  processContext.exit(reportUipathPythonFailure(result));
7846
8843
  return result;
7847
8844
  };
7848
- const registerExecCommand = (program2) => {
7849
- program2.command("exec", { hidden: true }).description("Execute the uipath package with provided arguments").allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, async (_options, cmd) => {
8845
+ const registerExecCommand = (program) => {
8846
+ program.command("exec", { hidden: true }).description("Execute the uipath package with provided arguments").allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, async (_options, cmd) => {
7850
8847
  await executeCommand(["_", "_", "exec", ...cmd.args], {});
7851
8848
  });
7852
8849
  };
@@ -7859,11 +8856,10 @@ class PythonService {
7859
8856
  cacheFile;
7860
8857
  config;
7861
8858
  uipathExePath;
7862
- packageVersion;
7863
8859
  constructor(config) {
7864
- const fs2 = getFileSystem();
8860
+ const fs = getFileSystem();
7865
8861
  this.config = config;
7866
- this.cacheFile = config.cacheFile || fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
8862
+ this.cacheFile = config.cacheFile || fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
7867
8863
  }
7868
8864
  async setup(packageName, force = false) {
7869
8865
  const [error, result] = await catchError(this._setupInternal(packageName, force));
@@ -7919,26 +8915,20 @@ To install the package, run:
7919
8915
  ${pythonPath} -m pip install ${packageName}`
7920
8916
  };
7921
8917
  }
7922
- const versionResult = await this.getUipathVersion(this.uipathExePath);
7923
- if ("error" in versionResult) {
7924
- return {
7925
- success: false,
8918
+ const versionCheck = await checkUipathVersion(this.uipathExePath);
8919
+ if (!versionCheck.ok) {
8920
+ return this.rejectVersion(versionCheck, {
7926
8921
  pythonPath,
7927
8922
  pythonVersion: version,
7928
- packageInstalled: true,
7929
- uipathExePath: this.uipathExePath,
7930
- source,
7931
- error: versionResult.error
7932
- };
8923
+ source
8924
+ });
7933
8925
  }
7934
- this.packageVersion = versionResult.version;
7935
8926
  await this.saveCache({
7936
8927
  pythonPath,
7937
8928
  version,
7938
8929
  lastValidated: new Date().toISOString(),
7939
8930
  packageName,
7940
8931
  uipathExePath: this.uipathExePath,
7941
- packageVersion: this.packageVersion,
7942
8932
  source
7943
8933
  });
7944
8934
  return {
@@ -7946,18 +8936,18 @@ To install the package, run:
7946
8936
  pythonPath,
7947
8937
  pythonVersion: version,
7948
8938
  packageInstalled: true,
7949
- packageVersion: this.packageVersion,
8939
+ packageVersion: versionCheck.version,
7950
8940
  uipathExePath: this.uipathExePath,
7951
8941
  source
7952
8942
  };
7953
8943
  }
7954
8944
  async reuseCache(packageName, virtualEnv) {
7955
- const fs2 = getFileSystem();
8945
+ const fs = getFileSystem();
7956
8946
  logger.debug("Checking cache...");
7957
8947
  const cached = await this.loadCache();
7958
8948
  if (!cached)
7959
8949
  return null;
7960
- if (!cached.uipathExePath || !await fs2.exists(cached.uipathExePath)) {
8950
+ if (!cached.uipathExePath || !await fs.exists(cached.uipathExePath)) {
7961
8951
  logger.warn("Cached Python path no longer exists, re-detecting...");
7962
8952
  return null;
7963
8953
  }
@@ -7970,21 +8960,13 @@ To install the package, run:
7970
8960
  this.uipathExePath = cached.uipathExePath;
7971
8961
  const source = cached.source ?? (virtualEnv ? "venv" : "path");
7972
8962
  logger.info(`Using cached uipath executable: ${this.uipathExePath}`);
7973
- this.packageVersion = cached.packageVersion;
7974
- if (!this.packageVersion) {
7975
- const versionResult = await this.getUipathVersion(this.uipathExePath);
7976
- if ("error" in versionResult) {
7977
- return {
7978
- success: false,
7979
- pythonPath,
7980
- pythonVersion: version,
7981
- packageInstalled: true,
7982
- uipathExePath: this.uipathExePath,
7983
- source,
7984
- error: versionResult.error
7985
- };
7986
- }
7987
- this.packageVersion = versionResult.version;
8963
+ const versionCheck = await checkUipathVersion(this.uipathExePath);
8964
+ if (!versionCheck.ok) {
8965
+ return this.rejectVersion(versionCheck, {
8966
+ pythonPath,
8967
+ pythonVersion: version,
8968
+ source
8969
+ });
7988
8970
  }
7989
8971
  await this.saveCache({
7990
8972
  pythonPath,
@@ -7992,7 +8974,6 @@ To install the package, run:
7992
8974
  lastValidated: new Date().toISOString(),
7993
8975
  packageName,
7994
8976
  uipathExePath: this.uipathExePath,
7995
- packageVersion: this.packageVersion,
7996
8977
  source
7997
8978
  });
7998
8979
  return {
@@ -8000,15 +8981,15 @@ To install the package, run:
8000
8981
  pythonPath,
8001
8982
  pythonVersion: version,
8002
8983
  packageInstalled: true,
8003
- packageVersion: this.packageVersion,
8984
+ packageVersion: versionCheck.version,
8004
8985
  uipathExePath: this.uipathExePath,
8005
8986
  source
8006
8987
  };
8007
8988
  }
8008
8989
  async detectVenvPython(virtualEnv) {
8009
- const fs2 = getFileSystem();
8990
+ const fs = getFileSystem();
8010
8991
  const isWindows = platform() === "win32";
8011
- const command = isWindows ? fs2.path.join(virtualEnv, "Scripts", "python.exe") : fs2.path.join(virtualEnv, "bin", "python");
8992
+ const command = isWindows ? fs.path.join(virtualEnv, "Scripts", "python.exe") : fs.path.join(virtualEnv, "bin", "python");
8012
8993
  const checkedVersions = [];
8013
8994
  const searchedCommands = [];
8014
8995
  const version = await this.checkPythonVersion(command, [], checkedVersions, searchedCommands);
@@ -8018,12 +8999,12 @@ To install the package, run:
8018
8999
  error: this.buildNotFoundError(checkedVersions, searchedCommands)
8019
9000
  };
8020
9001
  }
8021
- const metadataPath = await this.findUipathExeFromMetadata(fs2, command, []);
9002
+ const metadataPath = await this.findUipathExeFromMetadata(fs, command, []);
8022
9003
  let uipathExePath = metadataPath;
8023
9004
  if (!uipathExePath) {
8024
- const candidate = isWindows ? fs2.path.join(virtualEnv, "Scripts", "uipath.exe") : fs2.path.join(virtualEnv, "bin", "uipath");
9005
+ const candidate = isWindows ? fs.path.join(virtualEnv, "Scripts", "uipath.exe") : fs.path.join(virtualEnv, "bin", "uipath");
8025
9006
  logger.debug(`Checking for uipath executable at: ${candidate}`);
8026
- if (await fs2.exists(candidate)) {
9007
+ if (await fs.exists(candidate)) {
8027
9008
  logger.info(`Found uipath executable at: ${candidate}`);
8028
9009
  uipathExePath = candidate;
8029
9010
  } else {
@@ -8042,8 +9023,8 @@ To install the package, run:
8042
9023
  if (process.env.VIRTUAL_ENV) {
8043
9024
  return null;
8044
9025
  }
8045
- const fs2 = getFileSystem();
8046
- if (!await fs2.exists(fs2.path.join(fs2.env.cwd(), ".venv"))) {
9026
+ const fs = getFileSystem();
9027
+ if (!await fs.exists(fs.path.join(fs.env.cwd(), ".venv"))) {
8047
9028
  return null;
8048
9029
  }
8049
9030
  return {
@@ -8067,12 +9048,12 @@ To install the package, run:
8067
9048
  };
8068
9049
  }
8069
9050
  async checkPythonCommand(command, args, checkedVersions, searchedCommands) {
8070
- const fs2 = getFileSystem();
9051
+ const fs = getFileSystem();
8071
9052
  const version = await this.checkPythonVersion(command, args, checkedVersions, searchedCommands);
8072
9053
  if (!version)
8073
9054
  return null;
8074
9055
  const commandStr = args.length > 0 ? `${command} ${args.join(" ")}` : command;
8075
- const uipathExePath = await this.findUipathExe(fs2, command, args);
9056
+ const uipathExePath = await this.findUipathExe(fs, command, args);
8076
9057
  return {
8077
9058
  success: true,
8078
9059
  pythonPath: commandStr,
@@ -8093,8 +9074,8 @@ To install the package, run:
8093
9074
  const stderrChunks = [];
8094
9075
  versionProc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
8095
9076
  versionProc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
8096
- const [versionError, exitCode] = await catchError(new Promise((resolve2, reject) => {
8097
- versionProc.on("exit", (code) => resolve2(code ?? 1));
9077
+ const [versionError, exitCode] = await catchError(new Promise((resolve, reject) => {
9078
+ versionProc.on("exit", (code) => resolve(code ?? 1));
8098
9079
  versionProc.on("error", (error) => reject(error));
8099
9080
  }));
8100
9081
  if (versionError) {
@@ -8121,31 +9102,31 @@ To install the package, run:
8121
9102
  logger.info(`Found valid Python: ${commandStr} - ${version}`);
8122
9103
  return version;
8123
9104
  }
8124
- async findUipathExe(fs2, command, args) {
8125
- const metadataPath = await this.findUipathExeFromMetadata(fs2, command, args);
9105
+ async findUipathExe(fs, command, args) {
9106
+ const metadataPath = await this.findUipathExeFromMetadata(fs, command, args);
8126
9107
  if (metadataPath)
8127
9108
  return metadataPath;
8128
9109
  const isWindows = platform() === "win32";
8129
9110
  const candidatePaths = [];
8130
9111
  const virtualEnv = process.env.VIRTUAL_ENV;
8131
9112
  if (virtualEnv) {
8132
- candidatePaths.push(isWindows ? fs2.path.join(virtualEnv, "Scripts", "uipath.exe") : fs2.path.join(virtualEnv, "bin", "uipath"));
9113
+ candidatePaths.push(isWindows ? fs.path.join(virtualEnv, "Scripts", "uipath.exe") : fs.path.join(virtualEnv, "bin", "uipath"));
8133
9114
  }
8134
9115
  const prefix = await this.getPythonPrefix(command, args);
8135
9116
  if (prefix) {
8136
- candidatePaths.push(isWindows ? fs2.path.join(prefix, "Scripts", "uipath.exe") : fs2.path.join(prefix, "bin", "uipath"));
9117
+ candidatePaths.push(isWindows ? fs.path.join(prefix, "Scripts", "uipath.exe") : fs.path.join(prefix, "bin", "uipath"));
8137
9118
  }
8138
9119
  for (const candidate of candidatePaths) {
8139
9120
  logger.debug(`Checking for uipath executable at: ${candidate}`);
8140
- if (await fs2.exists(candidate)) {
9121
+ if (await fs.exists(candidate)) {
8141
9122
  logger.info(`Found uipath executable at: ${candidate}`);
8142
9123
  return candidate;
8143
9124
  }
8144
9125
  }
8145
- const pathCandidates = this.getPathUipathCandidates(fs2, isWindows);
9126
+ const pathCandidates = this.getPathUipathCandidates(fs, isWindows);
8146
9127
  for (const candidate of pathCandidates) {
8147
9128
  logger.debug(`Checking for uipath executable on PATH at: ${candidate}`);
8148
- if (await fs2.exists(candidate)) {
9129
+ if (await fs.exists(candidate)) {
8149
9130
  logger.info(`Found uipath executable at: ${candidate}`);
8150
9131
  return candidate;
8151
9132
  }
@@ -8154,7 +9135,7 @@ To install the package, run:
8154
9135
  logger.error(`uipath executable not found. Checked: ${checkedCandidates.join(", ")}`);
8155
9136
  return;
8156
9137
  }
8157
- async findUipathExeFromMetadata(fs2, command, args) {
9138
+ async findUipathExeFromMetadata(fs, command, args) {
8158
9139
  const script = `
8159
9140
  from importlib.metadata import distribution, PackageNotFoundError
8160
9141
  import os
@@ -8176,8 +9157,8 @@ sys.exit(3)
8176
9157
  const stderrChunks = [];
8177
9158
  proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
8178
9159
  proc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
8179
- const [error, exitCode] = await catchError(new Promise((resolve2, reject) => {
8180
- proc.on("exit", (code) => resolve2(code ?? 1));
9160
+ const [error, exitCode] = await catchError(new Promise((resolve, reject) => {
9161
+ proc.on("exit", (code) => resolve(code ?? 1));
8181
9162
  proc.on("error", (err) => reject(err));
8182
9163
  }));
8183
9164
  if (error) {
@@ -8194,7 +9175,7 @@ sys.exit(3)
8194
9175
  logger.debug("uipath executable metadata lookup returned empty path");
8195
9176
  return;
8196
9177
  }
8197
- if (!await fs2.exists(resolved)) {
9178
+ if (!await fs.exists(resolved)) {
8198
9179
  logger.debug(`uipath executable path from metadata does not exist: ${resolved}`);
8199
9180
  return;
8200
9181
  }
@@ -8207,8 +9188,8 @@ sys.exit(3)
8207
9188
  });
8208
9189
  const stdoutChunks = [];
8209
9190
  proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
8210
- const [error, exitCode] = await catchError(new Promise((resolve2, reject) => {
8211
- proc.on("exit", (code) => resolve2(code ?? 1));
9191
+ const [error, exitCode] = await catchError(new Promise((resolve, reject) => {
9192
+ proc.on("exit", (code) => resolve(code ?? 1));
8212
9193
  proc.on("error", (err) => reject(err));
8213
9194
  }));
8214
9195
  if (error) {
@@ -8220,46 +9201,27 @@ sys.exit(3)
8220
9201
  const prefix = Buffer.concat(stdoutChunks).toString("utf-8").trim();
8221
9202
  return prefix || undefined;
8222
9203
  }
8223
- async getUipathVersion(exePath) {
8224
- const proc = spawn2(exePath, ["--version"], {
8225
- stdio: ["ignore", "pipe", "pipe"]
8226
- });
8227
- const stdoutChunks = [];
8228
- const stderrChunks = [];
8229
- proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
8230
- proc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
8231
- const [spawnError, exitCode] = await catchError(new Promise((resolve2, reject) => {
8232
- proc.on("exit", (code) => resolve2(code ?? 1));
8233
- proc.on("error", (err) => reject(err));
8234
- }));
8235
- if (spawnError) {
8236
- return {
8237
- error: `Failed to run '${exePath} --version': ${spawnError.message}`
8238
- };
8239
- }
8240
- const stdout = Buffer.concat(stdoutChunks).toString("utf-8").trim();
8241
- const stderr = Buffer.concat(stderrChunks).toString("utf-8").trim();
8242
- if (exitCode !== 0) {
8243
- return {
8244
- error: `'${exePath} --version' exited with code ${exitCode}${stderr ? `: ${stderr}` : ""}`
8245
- };
8246
- }
8247
- const match = stdout.match(/uipath\s+version\s+(\S+)/i);
8248
- if (!match) {
8249
- return {
8250
- error: `Could not parse version from '${exePath} --version' output: ${stdout || "<empty>"}`
8251
- };
8252
- }
8253
- return { version: match[1] };
9204
+ rejectVersion(check, context) {
9205
+ return {
9206
+ success: false,
9207
+ pythonPath: context.pythonPath,
9208
+ pythonVersion: context.pythonVersion,
9209
+ packageInstalled: true,
9210
+ packageVersion: check.kind === "unsupported" ? check.version : undefined,
9211
+ uipathExePath: this.uipathExePath,
9212
+ source: context.source,
9213
+ error: check.message,
9214
+ instructions: uipathVersionInstructions(check, this.config.toolName ?? "codedagent")
9215
+ };
8254
9216
  }
8255
- getPathUipathCandidates(fs2, isWindows) {
9217
+ getPathUipathCandidates(fs, isWindows) {
8256
9218
  const pathValue = process.env.PATH || (isWindows ? process.env.Path : undefined);
8257
9219
  if (!pathValue)
8258
9220
  return [];
8259
9221
  const delimiter = isWindows ? ";" : ":";
8260
9222
  const pathEntries = pathValue.split(delimiter).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => entry.length > 0);
8261
9223
  const executableNames = isWindows ? this.getWindowsExecutableNames() : ["uipath"];
8262
- return pathEntries.flatMap((entry) => executableNames.map((name) => fs2.path.join(entry, name)));
9224
+ return pathEntries.flatMap((entry) => executableNames.map((name) => fs.path.join(entry, name)));
8263
9225
  }
8264
9226
  getWindowsExecutableNames() {
8265
9227
  const pathExt = process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD";
@@ -8335,14 +9297,14 @@ Please install one of the required Python versions:
8335
9297
  return readCache(this.cacheFile);
8336
9298
  }
8337
9299
  async saveCache(cache) {
8338
- const fs2 = getFileSystem();
8339
- const dir = fs2.path.dirname(this.cacheFile);
8340
- const [mkdirError] = await catchError(fs2.mkdir(dir));
9300
+ const fs = getFileSystem();
9301
+ const dir = fs.path.dirname(this.cacheFile);
9302
+ const [mkdirError] = await catchError(fs.mkdir(dir));
8341
9303
  if (mkdirError) {
8342
9304
  logger.warn(`Failed to create cache directory: ${mkdirError}`);
8343
9305
  return;
8344
9306
  }
8345
- const [writeError] = await catchError(fs2.writeFile(this.cacheFile, JSON.stringify(cache, null, 2)));
9307
+ const [writeError] = await catchError(fs.writeFile(this.cacheFile, JSON.stringify(cache, null, 2)));
8346
9308
  if (writeError) {
8347
9309
  logger.warn(`Failed to save cache: ${writeError}`);
8348
9310
  return;
@@ -8363,8 +9325,8 @@ function isPathInside(target, root) {
8363
9325
  }
8364
9326
  // ../uipath-python-bridge/src/register.ts
8365
9327
  function createSetupCommand(config) {
8366
- return (program2) => {
8367
- program2.command("setup").description("Detect Python installation and verify package is installed").option("--force", "Force re-detection of Python even if cached", false).trackedAction(processContext, async (options) => {
9328
+ return (program) => {
9329
+ program.command("setup").description("Detect Python installation and verify package is installed").option("--force", "Force re-detection of Python even if cached", false).trackedAction(processContext, async (options) => {
8368
9330
  const packageName = config.packageName || getPackageName();
8369
9331
  const allowedVersions = getAllowedPythonVersions();
8370
9332
  if (allowedVersions.length === 0) {
@@ -8401,6 +9363,7 @@ Searching for Python installations: ${allowedVersions}`);
8401
9363
  Package: packageName,
8402
9364
  PackageInstalled: result.packageInstalled ? "Yes" : "No",
8403
9365
  PackageVersion: result.packageVersion ?? "N/A",
9366
+ RequiredPackageVersion: getUipathVersionRequirement(),
8404
9367
  UipathPath: result.uipathExePath,
8405
9368
  Source: result.source
8406
9369
  }
@@ -8410,9 +9373,9 @@ Searching for Python installations: ${allowedVersions}`);
8410
9373
  };
8411
9374
  }
8412
9375
  function createDefaultAction(executeCommand) {
8413
- return (program2) => {
8414
- program2.trackedAction(processContext, async () => {
8415
- const userArgs = program2.args.length > 0 ? normalizeDefaultActionArgs(program2.args) : [];
9376
+ return (program) => {
9377
+ program.trackedAction(processContext, async () => {
9378
+ const userArgs = program.args.length > 0 ? normalizeDefaultActionArgs(program.args) : [];
8416
9379
  const extra = userArgs.length > 0 ? userArgs : ["--help"];
8417
9380
  await executeCommand(["_", "_", "exec", ...extra], {});
8418
9381
  });
@@ -8422,28 +9385,28 @@ function normalizeDefaultActionArgs(args) {
8422
9385
  return args.length === 1 && args[0] === "-h" ? ["--help"] : args;
8423
9386
  }
8424
9387
  function createHelpCommand(executeCommand) {
8425
- return (program2) => {
8426
- program2.command("help").description("Display help for the python tool").trackedAction(processContext, async () => {
9388
+ return (program) => {
9389
+ program.command("help").description("Display help for the python tool").trackedAction(processContext, async () => {
8427
9390
  await executeCommand(["_", "_", "exec", "--help"], {});
8428
9391
  });
8429
9392
  };
8430
9393
  }
8431
9394
  function createCommandForwarder(executeCommand) {
8432
- return (program2) => {
8433
- program2.on("command:*", async (operands) => {
9395
+ return (program) => {
9396
+ program.on("command:*", async (operands) => {
8434
9397
  const unknownCommand = operands[0];
8435
- if (!program2.commands.some((c) => c.name() === unknownCommand)) {
9398
+ if (!program.commands.some((c) => c.name() === unknownCommand)) {
8436
9399
  await executeCommand(["_", "_", "exec", ...operands], {});
8437
9400
  }
8438
9401
  });
8439
9402
  };
8440
9403
  }
8441
9404
  // package.json
8442
- var package_default = {
9405
+ var package_default2 = {
8443
9406
  name: "@uipath/context-grounding-tool",
8444
9407
  author: "UiPath",
8445
9408
  license: "SEE LICENSE IN LICENSE.txt",
8446
- version: "1.205.0-preview.277",
9409
+ version: "1.206.0-preview.279",
8447
9410
  description: "Tool for context grounding operations via the UiPath Python SDK",
8448
9411
  keywords: [
8449
9412
  "uipcli-tool",
@@ -8472,6 +9435,7 @@ var package_default = {
8472
9435
  },
8473
9436
  scripts: {
8474
9437
  build: "bun ../../tools/build-tool.ts",
9438
+ typecheck: "tsc --noEmit",
8475
9439
  package: "bun run build && bun pm pack",
8476
9440
  test: "vitest run",
8477
9441
  "test:coverage": "vitest run --coverage",
@@ -8497,9 +9461,9 @@ var COMMAND_RULES = [
8497
9461
 
8498
9462
  // src/tool.ts
8499
9463
  var COMMAND_PREFIX = "context-grounding";
8500
- var metadata = {
9464
+ var metadata2 = {
8501
9465
  name: "context-grounding-tool",
8502
- version: package_default.version,
9466
+ version: package_default2.version,
8503
9467
  description: "A tool for context grounding operations via the UiPath Python SDK.",
8504
9468
  commandPrefix: COMMAND_PREFIX
8505
9469
  };
@@ -8515,18 +9479,18 @@ var registerSetupCommand = createSetupCommand({
8515
9479
  });
8516
9480
  var registerDefaultAction = createDefaultAction(executeCommand);
8517
9481
  var registerHelpCommand = createHelpCommand(executeCommand);
8518
- var registerCommands = async (program2) => {
8519
- program2.allowUnknownOption(true);
8520
- program2.allowExcessArguments(true);
8521
- program2.helpOption(false);
8522
- registerDefaultAction(program2);
8523
- registerSetupCommand(program2);
8524
- registerExecCommand(program2);
8525
- registerHelpCommand(program2);
8526
- createCommandForwarder(executeCommand)(program2);
8527
- program2.showHelpAfterError(false);
9482
+ var registerCommands2 = async (program) => {
9483
+ program.allowUnknownOption(true);
9484
+ program.allowExcessArguments(true);
9485
+ program.helpOption(false);
9486
+ registerDefaultAction(program);
9487
+ registerSetupCommand(program);
9488
+ registerExecCommand(program);
9489
+ registerHelpCommand(program);
9490
+ createCommandForwarder(executeCommand)(program);
9491
+ program.showHelpAfterError(false);
8528
9492
  };
8529
9493
 
8530
- export { Command, metadata, registerCommands };
9494
+ export { Command, metadata2, registerCommands2 };
8531
9495
 
8532
- //# debugId=02F2D70FDEBB43EC64756E2164756E21
9496
+ //# debugId=3136C8B8F070614864756E2164756E21