@uipath/data-fabric-tool 1.205.0-preview.281 → 1.206.0-preview.282

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/README.md +41 -0
  2. package/dist/{entities-inline-baef06jh.js → entities-inline-2t6gm4dg.js} +67 -52
  3. package/dist/{federated-payload-9pzxpsw5.js → federated-payload-5aj381w4.js} +61 -26
  4. package/dist/{getMachineId-bsd-67w37xtj.js → getMachineId-bsd-hr7dy73y.js} +3 -3
  5. package/dist/{getMachineId-darwin-4g3xfpfp.js → getMachineId-darwin-k0c7ykqv.js} +3 -3
  6. package/dist/{getMachineId-linux-a4p6fb9w.js → getMachineId-linux-f0m4gd78.js} +2 -2
  7. package/dist/{getMachineId-unsupported-77w362eh.js → getMachineId-unsupported-e99prk6h.js} +2 -2
  8. package/dist/{getMachineId-win-9cfxg9c8.js → getMachineId-win-zqh7yjfs.js} +3 -3
  9. package/dist/{index-sby22td6.js → index-nzr4mx5p.js} +2 -22
  10. package/dist/index.js +11 -13
  11. package/dist/{jmespath-231m3hyn.js → jmespath-ab6tdc42.js} +1 -1
  12. package/dist/{js-yaml-88tdqrtd.js → js-yaml-a2bk27p6.js} +1 -3
  13. package/dist/{packager-tool-pz3g5mpk.js → packager-tool-0j0r03b9.js} +3 -3
  14. package/dist/{packager-tool-bndhpxxj.js → packager-tool-4b88bsfh.js} +30 -30
  15. package/dist/{packager-tool-2wp1xwz4.js → packager-tool-4h93ssh9.js} +6 -6
  16. package/dist/{packager-tool-m0btwdsf.js → packager-tool-8h3n7zh5.js} +207 -3
  17. package/dist/{packager-tool-1de529jm.js → packager-tool-epsr41wx.js} +12 -3
  18. package/dist/{packager-tool-2czkpqb0.js → packager-tool-ggemp2c3.js} +1 -1
  19. package/dist/{packager-tool-r0r0wqk6.js → packager-tool-k1j9cp3v.js} +164 -60
  20. package/dist/{packager-tool-w9r3qa12.js → packager-tool-rmg1jqy3.js} +1183 -1166
  21. package/dist/{packager-tool-xnrdmg37.js → packager-tool-xskp1rxe.js} +1494 -1214
  22. package/dist/packager-tool.js +5 -6
  23. package/dist/tool.js +10 -12
  24. package/package.json +2 -2
@@ -1,22 +1,31 @@
1
1
  import {
2
- MAX_MULTILINE_MAX_FIELDS,
3
- catchError,
4
- describeThrownValue,
5
- findInvalidFieldConstraints,
2
+ BaseDimensions,
3
+ CommandDimensions,
4
+ ErrorDimensions,
5
+ SkillsDimensions,
6
+ lowercaseIdDimensionValues,
7
+ projectIdentityProperties,
8
+ PROJECT_IDENTITY_LOOKUP_BUDGET_MS,
9
+ withinProjectIdentityBudget,
10
+ singleton,
6
11
  recordSuppliedArgumentValues,
7
- redactError,
12
+ releaseSuppliedArgumentValues,
13
+ redactSpanName,
8
14
  redactHttpDependencyName,
15
+ redactError,
9
16
  redactProperties,
10
- redactSpanName,
11
- releaseSuppliedArgumentValues,
12
- singleton,
17
+ describeThrownValue,
18
+ catchError,
19
+ MAX_MULTILINE_MAX_FIELDS,
20
+ findInvalidFieldConstraints,
13
21
  validateName
14
- } from "./packager-tool-m0btwdsf.js";
22
+ } from "./packager-tool-8h3n7zh5.js";
15
23
  import {
24
+ __toESM,
16
25
  __commonJS,
17
- __require,
18
- __toESM
19
- } from "./packager-tool-1de529jm.js";
26
+ __exportCjs,
27
+ __require
28
+ } from "./packager-tool-epsr41wx.js";
20
29
 
21
30
  // ../../node_modules/commander/lib/error.js
22
31
  var require_error = __commonJS(function(exports) {
@@ -138,7 +147,7 @@ var require_help = __commonJS(function(exports) {
138
147
  this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
139
148
  }
140
149
  visibleCommands(cmd) {
141
- const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
150
+ const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
142
151
  const helpCommand = cmd._getHelpCommand();
143
152
  if (helpCommand && !helpCommand._hidden) {
144
153
  visibleCommands.push(helpCommand);
@@ -618,8 +627,8 @@ var require_option = __commonJS(function(exports) {
618
627
  }
619
628
  }
620
629
  function camelcase(str) {
621
- return str.split("-").reduce((str2, word) => {
622
- return str2 + word[0].toUpperCase() + word.slice(1);
630
+ return str.split("-").reduce((str, word) => {
631
+ return str + word[0].toUpperCase() + word.slice(1);
623
632
  });
624
633
  }
625
634
  function splitOptionFlags(flags) {
@@ -740,8 +749,8 @@ var require_suggestSimilar = __commonJS(function(exports) {
740
749
  var require_command = __commonJS(function(exports) {
741
750
  var EventEmitter = __require("node:events").EventEmitter;
742
751
  var childProcess = __require("node:child_process");
743
- var path2 = __require("node:path");
744
- var fs2 = __require("node:fs");
752
+ var path = __require("node:path");
753
+ var fs = __require("node:fs");
745
754
  var process2 = __require("node:process");
746
755
  var { Argument, humanReadableArgName } = require_argument();
747
756
  var { CommanderError } = require_error();
@@ -1190,44 +1199,44 @@ Expecting one of '${allowedValues.join("', '")}'`);
1190
1199
  });
1191
1200
  return source;
1192
1201
  }
1193
- _prepareUserArgs(argv, parseOptions) {
1194
- if (argv !== undefined && !Array.isArray(argv)) {
1202
+ _prepareUserArgs(argv2, parseOptions) {
1203
+ if (argv2 !== undefined && !Array.isArray(argv2)) {
1195
1204
  throw new Error("first parameter to parse must be array or undefined");
1196
1205
  }
1197
1206
  parseOptions = parseOptions || {};
1198
- if (argv === undefined && parseOptions.from === undefined) {
1207
+ if (argv2 === undefined && parseOptions.from === undefined) {
1199
1208
  if (process2.versions?.electron) {
1200
1209
  parseOptions.from = "electron";
1201
1210
  }
1202
- const execArgv = process2.execArgv ?? [];
1203
- if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
1211
+ const execArgv2 = process2.execArgv ?? [];
1212
+ if (execArgv2.includes("-e") || execArgv2.includes("--eval") || execArgv2.includes("-p") || execArgv2.includes("--print")) {
1204
1213
  parseOptions.from = "eval";
1205
1214
  }
1206
1215
  }
1207
- if (argv === undefined) {
1208
- argv = process2.argv;
1216
+ if (argv2 === undefined) {
1217
+ argv2 = process2.argv;
1209
1218
  }
1210
- this.rawArgs = argv.slice();
1219
+ this.rawArgs = argv2.slice();
1211
1220
  let userArgs;
1212
1221
  switch (parseOptions.from) {
1213
1222
  case undefined:
1214
1223
  case "node":
1215
- this._scriptPath = argv[1];
1216
- userArgs = argv.slice(2);
1224
+ this._scriptPath = argv2[1];
1225
+ userArgs = argv2.slice(2);
1217
1226
  break;
1218
1227
  case "electron":
1219
1228
  if (process2.defaultApp) {
1220
- this._scriptPath = argv[1];
1221
- userArgs = argv.slice(2);
1229
+ this._scriptPath = argv2[1];
1230
+ userArgs = argv2.slice(2);
1222
1231
  } else {
1223
- userArgs = argv.slice(1);
1232
+ userArgs = argv2.slice(1);
1224
1233
  }
1225
1234
  break;
1226
1235
  case "user":
1227
- userArgs = argv.slice(0);
1236
+ userArgs = argv2.slice(0);
1228
1237
  break;
1229
1238
  case "eval":
1230
- userArgs = argv.slice(1);
1239
+ userArgs = argv2.slice(1);
1231
1240
  break;
1232
1241
  default:
1233
1242
  throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
@@ -1276,7 +1285,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1276
1285
  this.processedArgs = [];
1277
1286
  }
1278
1287
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
1279
- if (fs2.existsSync(executableFile))
1288
+ if (fs.existsSync(executableFile))
1280
1289
  return;
1281
1290
  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";
1282
1291
  const executableMissing = `'${executableFile}' does not exist
@@ -1290,12 +1299,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
1290
1299
  let launchWithNode = false;
1291
1300
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1292
1301
  function findFile(baseDir, baseName) {
1293
- const localBin = path2.resolve(baseDir, baseName);
1294
- if (fs2.existsSync(localBin))
1302
+ const localBin = path.resolve(baseDir, baseName);
1303
+ if (fs.existsSync(localBin))
1295
1304
  return localBin;
1296
- if (sourceExt.includes(path2.extname(baseName)))
1305
+ if (sourceExt.includes(path.extname(baseName)))
1297
1306
  return;
1298
- const foundExt = sourceExt.find((ext) => fs2.existsSync(`${localBin}${ext}`));
1307
+ const foundExt = sourceExt.find((ext) => fs.existsSync(`${localBin}${ext}`));
1299
1308
  if (foundExt)
1300
1309
  return `${localBin}${foundExt}`;
1301
1310
  return;
@@ -1307,23 +1316,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
1307
1316
  if (this._scriptPath) {
1308
1317
  let resolvedScriptPath;
1309
1318
  try {
1310
- resolvedScriptPath = fs2.realpathSync(this._scriptPath);
1319
+ resolvedScriptPath = fs.realpathSync(this._scriptPath);
1311
1320
  } catch {
1312
1321
  resolvedScriptPath = this._scriptPath;
1313
1322
  }
1314
- executableDir = path2.resolve(path2.dirname(resolvedScriptPath), executableDir);
1323
+ executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
1315
1324
  }
1316
1325
  if (executableDir) {
1317
1326
  let localFile = findFile(executableDir, executableFile);
1318
1327
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1319
- const legacyName = path2.basename(this._scriptPath, path2.extname(this._scriptPath));
1328
+ const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
1320
1329
  if (legacyName !== this._name) {
1321
1330
  localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1322
1331
  }
1323
1332
  }
1324
1333
  executableFile = localFile || executableFile;
1325
1334
  }
1326
- launchWithNode = sourceExt.includes(path2.extname(executableFile));
1335
+ launchWithNode = sourceExt.includes(path.extname(executableFile));
1327
1336
  let proc;
1328
1337
  if (process2.platform !== "win32") {
1329
1338
  if (launchWithNode) {
@@ -1750,18 +1759,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
1750
1759
  this.error(message, { code: "commander.missingMandatoryOptionValue" });
1751
1760
  }
1752
1761
  _conflictingOption(option, conflictingOption) {
1753
- const findBestOptionFromValue = (option2) => {
1754
- const optionKey = option2.attributeName();
1762
+ const findBestOptionFromValue = (option) => {
1763
+ const optionKey = option.attributeName();
1755
1764
  const optionValue = this.getOptionValue(optionKey);
1756
1765
  const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
1757
1766
  const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
1758
1767
  if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
1759
1768
  return negativeOption;
1760
1769
  }
1761
- return positiveOption || option2;
1770
+ return positiveOption || option;
1762
1771
  };
1763
- const getErrorMessage = (option2) => {
1764
- const bestOption = findBestOptionFromValue(option2);
1772
+ const getErrorMessage = (option) => {
1773
+ const bestOption = findBestOptionFromValue(option);
1765
1774
  const optionKey = bestOption.attributeName();
1766
1775
  const source = this.getOptionValueSource(optionKey);
1767
1776
  if (source === "env") {
@@ -1912,13 +1921,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
1912
1921
  cmd.helpGroup(this._defaultCommandGroup);
1913
1922
  }
1914
1923
  nameFromFilename(filename) {
1915
- this._name = path2.basename(filename, path2.extname(filename));
1924
+ this._name = path.basename(filename, path.extname(filename));
1916
1925
  return this;
1917
1926
  }
1918
- executableDir(path3) {
1919
- if (path3 === undefined)
1927
+ executableDir(path) {
1928
+ if (path === undefined)
1920
1929
  return this._executableDir;
1921
- this._executableDir = path3;
1930
+ this._executableDir = path;
1922
1931
  return this;
1923
1932
  }
1924
1933
  helpInformation(contextOptions) {
@@ -2015,11 +2024,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2015
2024
  }
2016
2025
  help(contextOptions) {
2017
2026
  this.outputHelp(contextOptions);
2018
- let exitCode = Number(process2.exitCode ?? 0);
2019
- if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2020
- exitCode = 1;
2027
+ let exitCode2 = Number(process2.exitCode ?? 0);
2028
+ if (exitCode2 === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2029
+ exitCode2 = 1;
2021
2030
  }
2022
- this._exit(exitCode, "commander.help", "(outputHelp)");
2031
+ this._exit(exitCode2, "commander.help", "(outputHelp)");
2023
2032
  }
2024
2033
  addHelpText(position, text) {
2025
2034
  const allowedValues = ["beforeAll", "before", "after", "afterAll"];
@@ -2091,40 +2100,178 @@ Expecting one of '${allowedValues.join("', '")}'`);
2091
2100
  exports.useColor = useColor;
2092
2101
  });
2093
2102
 
2103
+ // ../common/src/result-types.ts
2104
+ var RESULTS = {
2105
+ Success: "Success",
2106
+ Failure: "Failure",
2107
+ ConfigError: "ConfigError",
2108
+ AuthenticationError: "AuthenticationError",
2109
+ ValidationError: "ValidationError",
2110
+ TimeoutError: "TimeoutError"
2111
+ };
2112
+
2094
2113
  // ../../node_modules/commander/index.js
2095
- var require_commander = __commonJS(function(exports) {
2096
- var { Argument } = require_argument();
2097
- var { Command } = require_command();
2098
- var { CommanderError, InvalidArgumentError } = require_error();
2099
- var { Help } = require_help();
2100
- var { Option } = require_option();
2101
- exports.program = new Command;
2102
- exports.createCommand = (name) => new Command(name);
2103
- exports.createOption = (flags, description) => new Option(flags, description);
2104
- exports.createArgument = (name, description) => new Argument(name, description);
2105
- exports.Command = Command;
2106
- exports.Option = Option;
2107
- exports.Argument = Argument;
2108
- exports.Help = Help;
2109
- exports.CommanderError = CommanderError;
2110
- exports.InvalidArgumentError = InvalidArgumentError;
2111
- exports.InvalidOptionArgumentError = InvalidArgumentError;
2114
+ var exports_commander = {};
2115
+ __exportCjs(exports_commander, {
2116
+ program: () => $program,
2117
+ createCommand: () => $createCommand,
2118
+ createOption: () => $createOption,
2119
+ createArgument: () => $createArgument,
2120
+ Command: () => $Command,
2121
+ Option: () => $Option,
2122
+ Argument: () => $Argument,
2123
+ Help: () => $Help,
2124
+ CommanderError: () => $CommanderError,
2125
+ InvalidArgumentError: () => $InvalidArgumentError,
2126
+ InvalidOptionArgumentError: () => $InvalidOptionArgumentError
2127
+ }, {
2128
+ program: (value) => $program = value,
2129
+ createCommand: (value) => $createCommand = value,
2130
+ createOption: (value) => $createOption = value,
2131
+ createArgument: (value) => $createArgument = value,
2132
+ Command: (value) => $Command = value,
2133
+ Option: (value) => $Option = value,
2134
+ Argument: (value) => $Argument = value,
2135
+ Help: (value) => $Help = value,
2136
+ CommanderError: (value) => $CommanderError = value,
2137
+ InvalidArgumentError: (value) => $InvalidArgumentError = value,
2138
+ InvalidOptionArgumentError: (value) => $InvalidOptionArgumentError = value
2112
2139
  });
2140
+ var { Argument } = require_argument();
2141
+ var { Command: Command2 } = require_command();
2142
+ var { CommanderError, InvalidArgumentError } = require_error();
2143
+ var { Help } = require_help();
2144
+ var { Option: Option2 } = require_option();
2145
+ var $program = new Command2;
2146
+ var $createCommand = (name) => new Command2(name);
2147
+ var $createOption = (flags, description) => new Option2(flags, description);
2148
+ var $createArgument = (name, description) => new Argument(name, description);
2149
+ var $Command = Command2;
2150
+ var $Option = Option2;
2151
+ var $Argument = Argument;
2152
+ var $Help = Help;
2153
+ var $CommanderError = CommanderError;
2154
+ var $InvalidArgumentError = InvalidArgumentError;
2155
+ var $InvalidOptionArgumentError = InvalidArgumentError;
2113
2156
 
2114
- // ../common/src/exit-code.ts
2115
- function setExitCode(code) {
2116
- process.exitCode = code;
2157
+ // ../../node_modules/commander/esm.mjs
2158
+ var {
2159
+ program,
2160
+ createCommand,
2161
+ createArgument,
2162
+ createOption,
2163
+ CommanderError: CommanderError2,
2164
+ InvalidArgumentError: InvalidArgumentError2,
2165
+ InvalidOptionArgumentError,
2166
+ Command,
2167
+ Argument: Argument2,
2168
+ Option,
2169
+ Help: Help2
2170
+ } = exports_commander;
2171
+
2172
+ // ../common/src/error-codes.ts
2173
+ var CLI_ERROR_CODES = [
2174
+ "invalid_argument",
2175
+ "authentication_required",
2176
+ "permission_denied",
2177
+ "local_permission_denied",
2178
+ "not_found",
2179
+ "rate_limited",
2180
+ "network_error",
2181
+ "timeout",
2182
+ "server_error",
2183
+ "method_not_allowed",
2184
+ "not_supported",
2185
+ "configuration_error",
2186
+ "execution_failed",
2187
+ "unknown_error"
2188
+ ];
2189
+ var RETRY_HINTS = [
2190
+ "RetryWillNotFix",
2191
+ "RetryLater",
2192
+ "RetryAfter1Second",
2193
+ "RetryAfter10Seconds",
2194
+ "RetryAfter30Seconds",
2195
+ "RetryAfter60Seconds"
2196
+ ];
2197
+ var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
2198
+ var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
2199
+ function isCliErrorCode(value) {
2200
+ return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
2201
+ }
2202
+ function isRetryHint(value) {
2203
+ return typeof value === "string" && RETRY_HINT_VALUES.has(value);
2204
+ }
2205
+ function carriedErrorCode(error) {
2206
+ if (!error || typeof error !== "object")
2207
+ return;
2208
+ const code = error.errorCode;
2209
+ return isCliErrorCode(code) ? code : undefined;
2210
+ }
2211
+ function carriedRetry(error) {
2212
+ if (!error || typeof error !== "object")
2213
+ return;
2214
+ const retry = error.retry;
2215
+ return isRetryHint(retry) ? retry : undefined;
2216
+ }
2217
+ function defaultRetryForErrorCode(errorCode) {
2218
+ switch (errorCode) {
2219
+ case "network_error":
2220
+ case "rate_limited":
2221
+ case "server_error":
2222
+ case "timeout":
2223
+ return "RetryLater";
2224
+ default:
2225
+ return "RetryWillNotFix";
2226
+ }
2117
2227
  }
2118
2228
 
2119
- // ../common/src/local-permission-codes.ts
2120
- var LOCAL_PERMISSION_ERROR_CODES = new Set([
2121
- "EACCES",
2122
- "EPERM",
2123
- "EROFS"
2124
- ]);
2229
+ // ../common/src/error-graph.ts
2230
+ function* walkErrorGraph(error) {
2231
+ const queue = [error];
2232
+ const seen = new Set;
2233
+ for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
2234
+ const current = queue.shift();
2235
+ if (current === null || typeof current !== "object")
2236
+ continue;
2237
+ if (seen.has(current))
2238
+ continue;
2239
+ seen.add(current);
2240
+ const cur = current;
2241
+ yield cur;
2242
+ if (cur.cause !== undefined)
2243
+ queue.push(cur.cause);
2244
+ if (Array.isArray(cur.errors))
2245
+ queue.push(...cur.errors);
2246
+ }
2247
+ return;
2248
+ }
2249
+ function parseHttpStatusFromMessage(message) {
2250
+ const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
2251
+ if (!match)
2252
+ return;
2253
+ const status = Number(match[1]);
2254
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
2255
+ }
2256
+ function findHttpStatusInGraph(error) {
2257
+ for (const node of walkErrorGraph(error)) {
2258
+ const response = node.response;
2259
+ const explicit = typeof node.status === "number" ? node.status : response?.status;
2260
+ if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
2261
+ return explicit;
2262
+ }
2263
+ if (typeof node.message === "string") {
2264
+ const parsed = parseHttpStatusFromMessage(node.message);
2265
+ if (parsed !== undefined && parsed >= 400) {
2266
+ return parsed;
2267
+ }
2268
+ }
2269
+ }
2270
+ return;
2271
+ }
2125
2272
 
2126
2273
  // ../filesystem/src/node.ts
2127
- import { randomUUID } from "node:crypto";
2274
+ import { createHash, randomUUID } from "node:crypto";
2128
2275
  import { existsSync } from "node:fs";
2129
2276
  import * as fs from "node:fs/promises";
2130
2277
  import * as os from "node:os";
@@ -2135,6 +2282,9 @@ var LOCK_MAX_WAIT_MS = 20000;
2135
2282
  var LOCK_MAX_HOLD_MS = 60000;
2136
2283
  var LOCK_RETRY_MIN_MS = 100;
2137
2284
  var LOCK_RETRY_JITTER_MS = 200;
2285
+ var HASH_CHUNK_BYTES = 256 * 1024;
2286
+ var hashBuffers = [];
2287
+ var HASH_BUFFERS_KEPT = 64;
2138
2288
 
2139
2289
  class NodeFileSystem {
2140
2290
  path = {
@@ -2153,7 +2303,7 @@ class NodeFileSystem {
2153
2303
  };
2154
2304
  utils = {
2155
2305
  open: async (url) => {
2156
- const { default: open } = await import("./index-sby22td6.js");
2306
+ const { default: open } = await import("./index-nzr4mx5p.js");
2157
2307
  await open(url);
2158
2308
  }
2159
2309
  };
@@ -2192,6 +2342,15 @@ class NodeFileSystem {
2192
2342
  throw error;
2193
2343
  }
2194
2344
  }
2345
+ async readdirEntries(dirPath) {
2346
+ try {
2347
+ return await fs.readdir(dirPath, { withFileTypes: true });
2348
+ } catch (error) {
2349
+ if (this.isEnoent(error))
2350
+ return [];
2351
+ throw error;
2352
+ }
2353
+ }
2195
2354
  async stat(filePath) {
2196
2355
  try {
2197
2356
  const stats = await fs.stat(filePath);
@@ -2199,7 +2358,8 @@ class NodeFileSystem {
2199
2358
  isFile: () => stats.isFile(),
2200
2359
  isDirectory: () => stats.isDirectory(),
2201
2360
  size: stats.size,
2202
- mtimeMs: stats.mtimeMs
2361
+ mtimeMs: stats.mtimeMs,
2362
+ ctimeMs: stats.ctimeMs
2203
2363
  };
2204
2364
  } catch (error) {
2205
2365
  if (this.isEnoent(error))
@@ -2313,6 +2473,42 @@ class NodeFileSystem {
2313
2473
  throw error;
2314
2474
  }
2315
2475
  }
2476
+ async hashFile(filePath) {
2477
+ let handle;
2478
+ try {
2479
+ handle = await fs.open(filePath, "r");
2480
+ } catch (error) {
2481
+ if (this.isEnoent(error))
2482
+ return null;
2483
+ throw error;
2484
+ }
2485
+ const buffer = hashBuffers.pop() ?? Buffer.allocUnsafe(HASH_CHUNK_BYTES);
2486
+ try {
2487
+ const opened = await handle.stat();
2488
+ const stats = {
2489
+ isFile: () => opened.isFile(),
2490
+ isDirectory: () => opened.isDirectory(),
2491
+ size: opened.size,
2492
+ mtimeMs: opened.mtimeMs,
2493
+ ctimeMs: opened.ctimeMs
2494
+ };
2495
+ const hash = createHash("sha256");
2496
+ let size = 0;
2497
+ for (;; ) {
2498
+ const { bytesRead } = await handle.read(buffer, 0, buffer.byteLength, null);
2499
+ if (bytesRead === 0)
2500
+ break;
2501
+ hash.update(buffer.subarray(0, bytesRead));
2502
+ size += bytesRead;
2503
+ }
2504
+ return { sha256: hash.digest("hex"), size, stats };
2505
+ } finally {
2506
+ if (hashBuffers.length < HASH_BUFFERS_KEPT) {
2507
+ hashBuffers.push(buffer);
2508
+ }
2509
+ await handle.close();
2510
+ }
2511
+ }
2316
2512
  async realpath(filePath) {
2317
2513
  try {
2318
2514
  return await fs.realpath(filePath);
@@ -2396,8 +2592,8 @@ function getOutputSink() {
2396
2592
 
2397
2593
  // ../common/src/logger.ts
2398
2594
  var logFilePathSlot = singleton("logFilePath");
2399
- function setGlobalLogFilePath(path2) {
2400
- logFilePathSlot.set(path2);
2595
+ function setGlobalLogFilePath(path) {
2596
+ logFilePathSlot.set(path);
2401
2597
  }
2402
2598
  function getGlobalLogFilePath() {
2403
2599
  return logFilePathSlot.get("");
@@ -2465,14 +2661,14 @@ class SimpleLogger {
2465
2661
  return this.fileLoggingEnabled || !!getGlobalLogFilePath();
2466
2662
  }
2467
2663
  writeToFile(formatted) {
2468
- const path2 = this.logFilePath || getGlobalLogFilePath();
2469
- if (!path2)
2664
+ const path = this.logFilePath || getGlobalLogFilePath();
2665
+ if (!path)
2470
2666
  return;
2471
2667
  const timestamp = new Date().toISOString();
2472
2668
  this.pendingWrites = Promise.all([
2473
2669
  this.pendingWrites,
2474
2670
  this.pendingInit
2475
- ]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
2671
+ ]).then(() => getFileSystem().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
2476
2672
  }
2477
2673
  write(formatted) {
2478
2674
  if (this.isFileLoggingActive()) {
@@ -2522,17 +2718,17 @@ class SimpleLogger {
2522
2718
  setGlobalLogFilePath("");
2523
2719
  }
2524
2720
  }
2525
- setLogFile(path2) {
2526
- this.logFilePath = path2;
2527
- setGlobalLogFilePath(path2);
2528
- if (!path2)
2721
+ setLogFile(path) {
2722
+ this.logFilePath = path;
2723
+ setGlobalLogFilePath(path);
2724
+ if (!path)
2529
2725
  return;
2530
2726
  this.fileLoggingEnabled = true;
2531
- const fs2 = getFileSystem();
2727
+ const fs = getFileSystem();
2532
2728
  this.pendingInit = (async () => {
2533
2729
  const [error] = await catchError((async () => {
2534
- await fs2.mkdir(fs2.path.dirname(path2));
2535
- await fs2.writeFile(path2, "");
2730
+ await fs.mkdir(fs.path.dirname(path));
2731
+ await fs.writeFile(path, "");
2536
2732
  })());
2537
2733
  if (error)
2538
2734
  this.fileLoggingEnabled = false;
@@ -2580,233 +2776,174 @@ function getLogFilePath() {
2580
2776
  return logger.getLogFilePath();
2581
2777
  }
2582
2778
 
2583
- // ../common/src/output-codecs.ts
2584
- var yamlSlot = singleton("YamlCodec");
2585
- var jmespathSlot = singleton("JmespathCodec");
2586
- async function loadOutputCodecsAsync(needed) {
2587
- const loads = [];
2588
- if (needed.yaml && yamlSlot.get() === undefined) {
2589
- loads.push(import("./js-yaml-88tdqrtd.js").then((mod) => {
2590
- yamlSlot.set(mod);
2591
- }));
2592
- }
2593
- if (needed.filter && jmespathSlot.get() === undefined) {
2594
- loads.push(import("./jmespath-231m3hyn.js").then((m)=>__toESM(m.default,1)).then((mod) => {
2595
- jmespathSlot.set(mod);
2596
- }));
2779
+ // ../common/src/timings.ts
2780
+ var TIMINGS_ENV_VAR = "UIP_TIMINGS";
2781
+ function createStorage2() {
2782
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
2783
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
2784
+ return {
2785
+ getStore: () => {
2786
+ return;
2787
+ },
2788
+ run: (_store, fn) => fn()
2789
+ };
2597
2790
  }
2598
- await Promise.all(loads);
2791
+ return new mod.AsyncLocalStorage;
2599
2792
  }
2600
- function getYamlCodec() {
2601
- return yamlSlot.get();
2793
+ var storageSlot = singleton("TimingStorage");
2794
+ var stateSlot = singleton("Timings");
2795
+ var rootStartedSlot = singleton("TimingsRootStarted");
2796
+ var longLivedHostSlot = singleton("TimingsLongLivedHost");
2797
+ var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
2798
+ function newState(baseline) {
2799
+ return { baseline, httpMs: 0, httpCalls: 0 };
2602
2800
  }
2603
- function getJmespathCodec() {
2604
- return jmespathSlot.get();
2801
+ function getState() {
2802
+ const scoped = storage.getStore();
2803
+ if (scoped) {
2804
+ return scoped;
2805
+ }
2806
+ const pinned = livePinnedState();
2807
+ if (pinned !== undefined) {
2808
+ return pinned;
2809
+ }
2810
+ return newState(processStartIsInvocationStart() ? 0 : performance.now());
2605
2811
  }
2606
-
2607
- // ../common/src/output-format-context.ts
2608
- var formatSlot = singleton("OutputFormat");
2609
- var formatExplicitSlot = singleton("OutputFormatExplicit");
2610
- var helpRequestedSlot = singleton("HelpRequested");
2611
- var filterSlot = singleton("OutputFilter");
2612
- function getOutputFormat() {
2613
- return formatSlot.get("json");
2812
+ function livePinnedState() {
2813
+ const pinned = stateSlot.get();
2814
+ return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
2614
2815
  }
2615
- function getOutputFilter() {
2616
- return filterSlot.get();
2816
+ function processStartIsInvocationStart() {
2817
+ return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
2617
2818
  }
2618
-
2619
- // ../common/src/error-graph.ts
2620
- function* walkErrorGraph(error) {
2621
- const queue = [error];
2622
- const seen = new Set;
2623
- for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
2624
- const current = queue.shift();
2625
- if (current === null || typeof current !== "object")
2626
- continue;
2627
- if (seen.has(current))
2628
- continue;
2629
- seen.add(current);
2630
- const cur = current;
2631
- yield cur;
2632
- if (cur.cause !== undefined)
2633
- queue.push(cur.cause);
2634
- if (Array.isArray(cur.errors))
2635
- queue.push(...cur.errors);
2819
+ function timingsEnabled() {
2820
+ if (typeof process === "undefined") {
2821
+ return false;
2636
2822
  }
2637
- return;
2823
+ const value = process.env?.[TIMINGS_ENV_VAR];
2824
+ if (value === undefined) {
2825
+ return false;
2826
+ }
2827
+ const normalized = value.trim().toLowerCase();
2828
+ return normalized === "1" || normalized === "true";
2638
2829
  }
2639
- function parseHttpStatusFromMessage(message) {
2640
- const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
2641
- if (!match)
2830
+ function recordExitCode(exitCode) {
2831
+ if (!timingsEnabled()) {
2642
2832
  return;
2643
- const status = Number(match[1]);
2644
- return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
2833
+ }
2834
+ getState().exitCode = exitCode;
2645
2835
  }
2646
- function findHttpStatusInGraph(error) {
2647
- for (const node of walkErrorGraph(error)) {
2648
- const response = node.response;
2649
- const explicit = typeof node.status === "number" ? node.status : response?.status;
2650
- if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
2651
- return explicit;
2652
- }
2653
- if (typeof node.message === "string") {
2654
- const parsed = parseHttpStatusFromMessage(node.message);
2655
- if (parsed !== undefined && parsed >= 400) {
2656
- return parsed;
2657
- }
2658
- }
2836
+ function invocationStartedAt() {
2837
+ return new Date(performance.timeOrigin + getState().baseline);
2838
+ }
2839
+ function invocationElapsedMs() {
2840
+ return performance.now() - getState().baseline;
2841
+ }
2842
+ function markCommandStart() {
2843
+ if (!timingsEnabled()) {
2844
+ return;
2845
+ }
2846
+ getState().commandStart = performance.now();
2847
+ }
2848
+ function recordCommandDuration(durationMs) {
2849
+ if (!timingsEnabled()) {
2850
+ return;
2851
+ }
2852
+ getState().commandMs = durationMs;
2853
+ }
2854
+
2855
+ // ../common/src/exit-code.ts
2856
+ function setExitCode(code) {
2857
+ process.exitCode = code;
2858
+ recordExitCode(code);
2859
+ }
2860
+ var GENERIC_FAILURE_EXIT_CODE = 1;
2861
+ function recordCommandExit(code) {
2862
+ if (code === GENERIC_FAILURE_EXIT_CODE && getExitCode() !== 0) {
2863
+ return;
2864
+ }
2865
+ setExitCode(code);
2866
+ }
2867
+ function getExitCode() {
2868
+ const code = process.exitCode;
2869
+ return typeof code === "number" ? code : 0;
2870
+ }
2871
+
2872
+ // ../common/src/http-status.ts
2873
+ function classifyHttpStatus(status) {
2874
+ if (status === undefined)
2875
+ return;
2876
+ if (status === 400 || status === 409 || status === 413 || status === 422) {
2877
+ return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
2878
+ }
2879
+ if (status === 401) {
2880
+ return {
2881
+ errorCode: "authentication_required",
2882
+ retry: "RetryWillNotFix"
2883
+ };
2884
+ }
2885
+ if (status === 403) {
2886
+ return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
2887
+ }
2888
+ if (status === 404) {
2889
+ return { errorCode: "not_found", retry: "RetryWillNotFix" };
2890
+ }
2891
+ if (status === 405) {
2892
+ return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
2893
+ }
2894
+ if (status === 408) {
2895
+ return { errorCode: "timeout", retry: "RetryLater" };
2896
+ }
2897
+ if (status === 429) {
2898
+ return { errorCode: "rate_limited", retry: "RetryLater" };
2899
+ }
2900
+ if (status >= 500 && status < 600) {
2901
+ return { errorCode: "server_error", retry: "RetryLater" };
2659
2902
  }
2660
2903
  return;
2661
2904
  }
2662
2905
 
2663
- // ../common/src/telemetry/telemetry-dimensions.ts
2664
- var BaseDimensions = {
2665
- ApplicationName: "ApplicationName",
2666
- ProductVersion: "ProductVersion",
2667
- InstallationId: "InstallationId",
2668
- CloudUserId: "CloudUserId",
2669
- CloudTenantId: "CloudTenantId",
2670
- CloudOrganizationId: "CloudOrganizationId",
2671
- IsInternalUser: "IsInternalUser",
2672
- Environment: "Environment",
2673
- BaseUrl: "BaseUrl",
2674
- Region: "Region",
2675
- Agent: "Agent",
2676
- AgentVersion: "AgentVersion",
2677
- AgentModel: "AgentModel",
2678
- ToolName: "ToolName",
2679
- ToolVersion: "ToolVersion",
2680
- ExecutionContext: "ExecutionContext",
2681
- CiProvider: "CiProvider",
2682
- SessionIdSource: "SessionIdSource",
2683
- SessionId: "SessionId"
2684
- };
2685
- var CommandDimensions = {
2686
- IsCommand: "IsCommand",
2687
- IsReexec: "IsReexec",
2688
- CommandName: "CommandName",
2689
- ExitCode: "ExitCode",
2690
- TerminalOutcome: "TerminalOutcome",
2691
- ErrorClass: "ErrorClass",
2692
- TerminalSignal: "TerminalSignal",
2693
- ErrorMessage: "ErrorMessage",
2694
- SkillName: "SkillName",
2695
- ProductArea: "ProductArea",
2696
- Mode: "Mode"
2697
- };
2698
- var ShipDimensions = {
2699
- ShipKind: "ShipKind",
2700
- Target: "Target",
2701
- ProjectType: "ProjectType",
2702
- ProjectTypes: "ProjectTypes",
2703
- ArtifactCorrelationKey: "ArtifactCorrelationKey",
2704
- PackageName: "PackageName",
2705
- PackageVersion: "PackageVersion",
2706
- PackageVersionKey: "PackageVersionKey",
2707
- DeploymentKey: "DeploymentKey",
2708
- SolutionId: "SolutionId",
2709
- FolderKey: "FolderKey",
2710
- FeedId: "FeedId"
2711
- };
2712
- var ErrorDimensions = {
2713
- Result: "Result",
2714
- ErrorCode: "ErrorCode",
2715
- Retry: "Retry",
2716
- ErrorMessage: "ErrorMessage",
2717
- HttpStatus: "HttpStatus",
2718
- UpstreamErrorCode: "UpstreamErrorCode"
2719
- };
2720
- var AuthDimensions = {
2721
- AuthenticationMethod: "AuthenticationMethod",
2722
- Success: "Success",
2723
- Reason: "Reason"
2724
- };
2725
- var SkillsDimensions = {
2726
- SchemaVersion: "SchemaVersion",
2727
- AgentType: "AgentType",
2728
- SkillsVersion: "SkillsVersion",
2729
- UipSubcommand: "UipSubcommand",
2730
- FileExtension: "FileExtension",
2731
- SubagentModel: "SubagentModel",
2732
- SubagentType: "SubagentType",
2733
- PermissionMode: "PermissionMode",
2734
- EffortLevel: "EffortLevel",
2735
- SessionSource: "SessionSource",
2736
- Outcome: "Outcome",
2737
- DurationMs: "DurationMs",
2738
- Source: "Source"
2739
- };
2740
- var PackagerDimensions = {
2741
- ProjectId: "ProjectId",
2742
- ProjectType: "ProjectType",
2743
- SolutionId: "SolutionId"
2744
- };
2745
- var ScopeDimensions = {
2746
- FolderId: "FolderId"
2747
- };
2748
- var ID_DIMENSIONS = new Set([
2749
- BaseDimensions.CloudUserId,
2750
- BaseDimensions.CloudTenantId,
2751
- BaseDimensions.CloudOrganizationId,
2752
- BaseDimensions.InstallationId,
2753
- ShipDimensions.ArtifactCorrelationKey,
2754
- ShipDimensions.PackageVersionKey,
2755
- ShipDimensions.DeploymentKey,
2756
- ShipDimensions.SolutionId,
2757
- ShipDimensions.FolderKey,
2758
- ShipDimensions.FeedId,
2759
- PackagerDimensions.ProjectId
2760
- ]);
2761
- var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
2762
- var RESERVED_DIMENSION_NAMES = new Set([
2763
- ...Object.values(BaseDimensions),
2764
- ...Object.values(CommandDimensions),
2765
- ...Object.values(ShipDimensions),
2766
- ...Object.values(ErrorDimensions),
2767
- ...Object.values(AuthDimensions),
2768
- ...Object.values(SkillsDimensions),
2769
- ...Object.values(PackagerDimensions),
2770
- ...Object.values(ScopeDimensions)
2771
- ]);
2772
- var CURATED_DIMENSIONS = new Set([
2773
- BaseDimensions.ApplicationName,
2774
- BaseDimensions.ProductVersion,
2775
- BaseDimensions.InstallationId,
2776
- BaseDimensions.CloudUserId,
2777
- BaseDimensions.CloudTenantId,
2778
- BaseDimensions.CloudOrganizationId,
2779
- BaseDimensions.IsInternalUser,
2780
- BaseDimensions.Environment,
2781
- BaseDimensions.BaseUrl,
2782
- BaseDimensions.Region,
2783
- BaseDimensions.Agent,
2784
- BaseDimensions.AgentVersion,
2785
- BaseDimensions.ToolVersion,
2786
- BaseDimensions.ExecutionContext,
2787
- BaseDimensions.CiProvider,
2788
- BaseDimensions.SessionIdSource,
2789
- BaseDimensions.SessionId,
2790
- ...Object.values(CommandDimensions),
2791
- ...Object.values(ShipDimensions)
2906
+ // ../common/src/local-permission-codes.ts
2907
+ var LOCAL_PERMISSION_ERROR_CODES = new Set([
2908
+ "EACCES",
2909
+ "EPERM",
2910
+ "EROFS"
2792
2911
  ]);
2793
- function lowercaseIdDimensionValues(properties) {
2794
- let changed = false;
2795
- const result = {
2796
- ...properties
2797
- };
2798
- for (const key of Object.keys(result)) {
2799
- const value = result[key];
2800
- if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
2801
- continue;
2802
- }
2803
- const lowered = value.toLowerCase();
2804
- if (lowered !== value) {
2805
- result[key] = lowered;
2806
- changed = true;
2807
- }
2912
+
2913
+ // ../common/src/output-codecs.ts
2914
+ var yamlSlot = singleton("YamlCodec");
2915
+ var jmespathSlot = singleton("JmespathCodec");
2916
+ async function loadOutputCodecsAsync(needed) {
2917
+ const loads = [];
2918
+ if (needed.yaml && yamlSlot.get() === undefined) {
2919
+ loads.push(import("./js-yaml-a2bk27p6.js").then((mod) => {
2920
+ yamlSlot.set(mod);
2921
+ }));
2922
+ }
2923
+ if (needed.filter && jmespathSlot.get() === undefined) {
2924
+ loads.push(import("./jmespath-ab6tdc42.js").then((m)=>__toESM(m.default,1)).then((mod) => {
2925
+ jmespathSlot.set(mod);
2926
+ }));
2808
2927
  }
2809
- return changed ? result : properties;
2928
+ await Promise.all(loads);
2929
+ }
2930
+ function getYamlCodec() {
2931
+ return yamlSlot.get();
2932
+ }
2933
+ function getJmespathCodec() {
2934
+ return jmespathSlot.get();
2935
+ }
2936
+
2937
+ // ../common/src/output-format-context.ts
2938
+ var formatSlot = singleton("OutputFormat");
2939
+ var formatExplicitSlot = singleton("OutputFormatExplicit");
2940
+ var helpRequestedSlot = singleton("HelpRequested");
2941
+ var filterSlot = singleton("OutputFilter");
2942
+ function getOutputFormat() {
2943
+ return formatSlot.get("json");
2944
+ }
2945
+ function getOutputFilter() {
2946
+ return filterSlot.get();
2810
2947
  }
2811
2948
 
2812
2949
  // ../common/src/telemetry/command-terminal.ts
@@ -2927,17 +3064,8 @@ function terminalSignalFor(input, outcome) {
2927
3064
  }
2928
3065
  return outcome === "cancelled" ? "SIGINT" : undefined;
2929
3066
  }
2930
- function classifyHttpStatus(status) {
2931
- if (status === 401 || status === 403) {
2932
- return "auth";
2933
- }
2934
- if (status === 400 || status === 409 || status === 422) {
2935
- return "validation";
2936
- }
2937
- if (status === 408) {
2938
- return "timeout";
2939
- }
2940
- return "network_http";
3067
+ function classifyFailingHttpStatus(status) {
3068
+ return classifyFromErrorCode(classifyHttpStatus(status)?.errorCode) ?? "network_http";
2941
3069
  }
2942
3070
  function classifyFromResult(result) {
2943
3071
  switch (result) {
@@ -3017,7 +3145,7 @@ function classifyError(input) {
3017
3145
  }
3018
3146
  const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
3019
3147
  if (status !== undefined) {
3020
- return classifyHttpStatus(status);
3148
+ return classifyFailingHttpStatus(status);
3021
3149
  }
3022
3150
  return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
3023
3151
  }
@@ -3049,6 +3177,7 @@ function buildCommandTerminalTelemetryProperties(input) {
3049
3177
  var CommonTelemetryEvents = {
3050
3178
  Start: "Application.Start",
3051
3179
  Error: "Application.Error",
3180
+ ProjectActivity: "Cli.ProjectActivity",
3052
3181
  ShipSucceeded: "Cli.ShipSucceeded"
3053
3182
  };
3054
3183
 
@@ -3566,87 +3695,21 @@ class TelemetryService {
3566
3695
  return hex;
3567
3696
  }
3568
3697
  }
3569
- // ../common/src/timings.ts
3570
- var TIMINGS_ENV_VAR = "UIP_TIMINGS";
3571
- function createStorage2() {
3572
- const [error, mod] = catchError(() => __require("node:async_hooks"));
3573
- if (error || typeof mod?.AsyncLocalStorage !== "function") {
3574
- return {
3575
- getStore: () => {
3576
- return;
3577
- },
3578
- run: (_store, fn) => fn()
3579
- };
3580
- }
3581
- return new mod.AsyncLocalStorage;
3582
- }
3583
- var storageSlot = singleton("TimingStorage");
3584
- var stateSlot = singleton("Timings");
3585
- var rootStartedSlot = singleton("TimingsRootStarted");
3586
- var longLivedHostSlot = singleton("TimingsLongLivedHost");
3587
- var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
3588
- function newState(baseline) {
3589
- return { baseline, httpMs: 0, httpCalls: 0 };
3590
- }
3591
- function getState() {
3592
- const scoped = storage.getStore();
3593
- if (scoped) {
3594
- return scoped;
3595
- }
3596
- const pinned = livePinnedState();
3597
- if (pinned !== undefined) {
3598
- return pinned;
3599
- }
3600
- return newState(processStartIsInvocationStart() ? 0 : performance.now());
3601
- }
3602
- function livePinnedState() {
3603
- const pinned = stateSlot.get();
3604
- return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
3605
- }
3606
- function processStartIsInvocationStart() {
3607
- return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
3608
- }
3609
- function timingsEnabled() {
3610
- if (typeof process === "undefined") {
3611
- return false;
3612
- }
3613
- const value = process.env?.[TIMINGS_ENV_VAR];
3614
- if (value === undefined) {
3615
- return false;
3616
- }
3617
- const normalized = value.trim().toLowerCase();
3618
- return normalized === "1" || normalized === "true";
3619
- }
3620
- function recordExitCode(exitCode) {
3621
- if (!timingsEnabled()) {
3622
- return;
3623
- }
3624
- getState().exitCode = exitCode;
3625
- }
3626
- function invocationStartedAt() {
3627
- return new Date(performance.timeOrigin + getState().baseline);
3628
- }
3629
- function invocationElapsedMs() {
3630
- return performance.now() - getState().baseline;
3631
- }
3632
- function markCommandStart() {
3633
- if (!timingsEnabled()) {
3634
- return;
3635
- }
3636
- getState().commandStart = performance.now();
3637
- }
3638
- function recordCommandDuration(durationMs) {
3639
- if (!timingsEnabled()) {
3640
- return;
3641
- }
3642
- getState().commandMs = durationMs;
3643
- }
3644
3698
  // ../common/src/telemetry/proxy-http-agent.ts
3645
3699
  var slot = singleton("ProxyAuthHttpsAgent");
3646
3700
 
3647
3701
  // ../common/src/telemetry/node-appinsights-telemetry-provider.ts
3648
3702
  var providerSlot = singleton("TelemetryProvider");
3649
3703
 
3704
+ // ../common/src/telemetry/telemetry-config.ts
3705
+ function isTelemetryDisabled() {
3706
+ const value = process.env.UIPATH_TELEMETRY_DISABLED;
3707
+ return value === "1" || value === "true";
3708
+ }
3709
+ function isProjectTelemetryDisabled() {
3710
+ return isTelemetryDisabled() || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "1" || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "true";
3711
+ }
3712
+
3650
3713
  // ../common/src/telemetry/telemetry-spool.ts
3651
3714
  var sidecarEntrySlot = singleton("TelemetrySidecarEntry");
3652
3715
  var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
@@ -3682,7 +3745,6 @@ var telemetry = new Proxy({}, {
3682
3745
  return typeof value === "function" ? value.bind(instance) : value;
3683
3746
  }
3684
3747
  });
3685
-
3686
3748
  // ../common/src/formatter.ts
3687
3749
  var ANSI_STYLES = {
3688
3750
  red: "\x1B[31m",
@@ -3692,46 +3754,6 @@ var ANSI_RESET = "\x1B[0m";
3692
3754
  function styleLine(line, style) {
3693
3755
  return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
3694
3756
  }
3695
- var CLI_ERROR_CODES = [
3696
- "invalid_argument",
3697
- "authentication_required",
3698
- "permission_denied",
3699
- "local_permission_denied",
3700
- "not_found",
3701
- "rate_limited",
3702
- "network_error",
3703
- "timeout",
3704
- "server_error",
3705
- "method_not_allowed",
3706
- "not_supported",
3707
- "configuration_error",
3708
- "execution_failed",
3709
- "unknown_error"
3710
- ];
3711
- var RETRY_HINTS = [
3712
- "RetryWillNotFix",
3713
- "RetryLater",
3714
- "RetryAfter1Second",
3715
- "RetryAfter10Seconds",
3716
- "RetryAfter30Seconds",
3717
- "RetryAfter60Seconds"
3718
- ];
3719
- var CLI_ERROR_CODE_VALUES = new Set(CLI_ERROR_CODES);
3720
- var RETRY_HINT_VALUES = new Set(RETRY_HINTS);
3721
- function isCliErrorCode(value) {
3722
- return typeof value === "string" && CLI_ERROR_CODE_VALUES.has(value);
3723
- }
3724
- function isRetryHint(value) {
3725
- return typeof value === "string" && RETRY_HINT_VALUES.has(value);
3726
- }
3727
- var RESULTS = {
3728
- Success: "Success",
3729
- Failure: "Failure",
3730
- ConfigError: "ConfigError",
3731
- AuthenticationError: "AuthenticationError",
3732
- ValidationError: "ValidationError",
3733
- TimeoutError: "TimeoutError"
3734
- };
3735
3757
  var EXIT_CODES = {
3736
3758
  Success: 0,
3737
3759
  Failure: 1,
@@ -3740,6 +3762,9 @@ var EXIT_CODES = {
3740
3762
  ValidationError: 3,
3741
3763
  TimeoutError: 4
3742
3764
  };
3765
+ function exitCodeForResult(result) {
3766
+ return EXIT_CODES[result] ?? EXIT_CODES.Failure;
3767
+ }
3743
3768
  function escapeNonAscii(jsonText) {
3744
3769
  return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
3745
3770
  const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
@@ -4553,40 +4578,11 @@ function defaultErrorCodeForResult(result) {
4553
4578
  return "unknown_error";
4554
4579
  }
4555
4580
  }
4556
- function parseHttpStatusFromMessage2(message) {
4557
- const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
4558
- if (!match)
4559
- return;
4560
- const status = Number(match[1]);
4561
- return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
4562
- }
4563
- function defaultErrorCodeForHttpStatus(status) {
4564
- if (status === undefined)
4565
- return;
4566
- if (status === 400 || status === 409 || status === 422) {
4567
- return "invalid_argument";
4568
- }
4569
- if (status === 401)
4570
- return "authentication_required";
4571
- if (status === 403)
4572
- return "permission_denied";
4573
- if (status === 404)
4574
- return "not_found";
4575
- if (status === 405)
4576
- return "method_not_allowed";
4577
- if (status === 408)
4578
- return "timeout";
4579
- if (status === 429)
4580
- return "rate_limited";
4581
- if (status >= 500 && status < 600)
4582
- return "server_error";
4583
- return;
4584
- }
4585
4581
  var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
4586
4582
  function defaultErrorCodeForFailure(data) {
4587
4583
  if (data.Result === RESULTS.Failure) {
4588
- const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
4589
- const errorCode = defaultErrorCodeForHttpStatus(status);
4584
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
4585
+ const errorCode = classifyHttpStatus(status)?.errorCode;
4590
4586
  if (errorCode)
4591
4587
  return errorCode;
4592
4588
  if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
@@ -4595,17 +4591,6 @@ function defaultErrorCodeForFailure(data) {
4595
4591
  }
4596
4592
  return defaultErrorCodeForResult(data.Result);
4597
4593
  }
4598
- function defaultRetryForErrorCode(errorCode) {
4599
- switch (errorCode) {
4600
- case "network_error":
4601
- case "rate_limited":
4602
- case "server_error":
4603
- case "timeout":
4604
- return "RetryLater";
4605
- default:
4606
- return "RetryWillNotFix";
4607
- }
4608
- }
4609
4594
  var OutputFormatter;
4610
4595
  ((OutputFormatter) => {
4611
4596
  function success(data, options) {
@@ -4637,7 +4622,7 @@ var OutputFormatter;
4637
4622
  data.Log ??= getLogFilePath() || undefined;
4638
4623
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
4639
4624
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
4640
- const exitCode = EXIT_CODES[data.Result] ?? 1;
4625
+ const exitCode = exitCodeForResult(data.Result);
4641
4626
  setExitCode(exitCode);
4642
4627
  recordCommandFailureTelemetry({
4643
4628
  result: data.Result,
@@ -4732,812 +4717,1107 @@ var OutputFormatter;
4732
4717
  OutputFormatter.formatToString = formatToString;
4733
4718
  })(OutputFormatter ||= {});
4734
4719
 
4735
- // ../../node_modules/commander/esm.mjs
4736
- var import__ = __toESM(require_commander(), 1);
4737
- var {
4738
- program,
4739
- createCommand,
4740
- createArgument,
4741
- createOption,
4742
- CommanderError,
4743
- InvalidArgumentError,
4744
- InvalidOptionArgumentError,
4745
- Command,
4746
- Argument,
4747
- Option,
4748
- Help
4749
- } = import__.default;
4750
-
4751
- // ../common/src/telemetry/command-attribution.ts
4752
- var LEGACY_SKILL_NAMESPACE = "uipath:";
4753
- var MAX_SKILL_NAME_LENGTH = 80;
4754
- var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
4755
- function productMode(productArea, mode) {
4756
- return { ProductArea: productArea, Mode: mode };
4757
- }
4758
- function attributionRecord(groups) {
4759
- const record = {};
4760
- for (const [productArea, mode, names] of groups) {
4761
- const attribution = productMode(productArea, mode);
4762
- for (const name of names) {
4763
- record[name] = attribution;
4764
- }
4720
+ // ../common/src/error-handler.ts
4721
+ 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.";
4722
+ 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.";
4723
+ var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
4724
+ 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.";
4725
+ 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.";
4726
+ 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.";
4727
+ var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
4728
+ var NETWORK_ERROR_CODES = new Set([
4729
+ "ECONNREFUSED",
4730
+ "ECONNRESET",
4731
+ "ENOTFOUND",
4732
+ "EAI_AGAIN",
4733
+ "ETIMEDOUT",
4734
+ "EPIPE",
4735
+ "EHOSTUNREACH",
4736
+ "ENETUNREACH",
4737
+ "EAI_FAIL"
4738
+ ]);
4739
+ var TLS_ERROR_CODES2 = new Set([
4740
+ "SELF_SIGNED_CERT_IN_CHAIN",
4741
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
4742
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
4743
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
4744
+ "UNABLE_TO_GET_ISSUER_CERT",
4745
+ "CERT_HAS_EXPIRED",
4746
+ "CERT_UNTRUSTED",
4747
+ "ERR_TLS_CERT_ALTNAME_INVALID"
4748
+ ]);
4749
+ 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.";
4750
+ 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.";
4751
+ var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
4752
+ function localPermissionInstructions(code, path) {
4753
+ const target = path !== undefined ? `'${path}'` : "a local file or resource";
4754
+ if (code === "EROFS") {
4755
+ 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.";
4765
4756
  }
4766
- return record;
4757
+ const onWindows = typeof process !== "undefined" && process.platform === "win32";
4758
+ 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.";
4759
+ 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}`;
4767
4760
  }
4768
- function commandAttribution(groups) {
4769
- const entries = [];
4770
- for (const [productArea, mode, prefixes] of groups) {
4771
- const attribution = productMode(productArea, mode);
4772
- for (const prefix of prefixes) {
4773
- entries.push({ prefix, attribution });
4761
+ function describeConnectivityError(error) {
4762
+ for (const cur of walkErrorGraph(error)) {
4763
+ const code = typeof cur.code === "string" ? cur.code : undefined;
4764
+ const message = typeof cur.message === "string" ? cur.message : undefined;
4765
+ if (code && TLS_ERROR_CODES2.has(code)) {
4766
+ return {
4767
+ code,
4768
+ kind: "tls",
4769
+ message: message ?? code,
4770
+ instructions: TLS_INSTRUCTIONS
4771
+ };
4772
+ }
4773
+ if (code && NETWORK_ERROR_CODES.has(code)) {
4774
+ return {
4775
+ code,
4776
+ kind: "network",
4777
+ message: message ?? code,
4778
+ instructions: NETWORK_INSTRUCTIONS
4779
+ };
4774
4780
  }
4775
4781
  }
4776
- return entries;
4782
+ return;
4777
4783
  }
4778
- var SKILL_ATTRIBUTION = attributionRecord([
4779
- ["admin", "operate", ["uipath-admin"]],
4780
- ["agents", "build", ["uipath-agents"]],
4781
- ["api-workflow", "build", ["uipath-api-workflow"]],
4782
- ["automation-discovery", "build", ["uipath-automation-discovery"]],
4783
- ["coded-apps", "build", ["uipath-coded-apps"]],
4784
- ["data-fabric", "operate", ["uipath-data-fabric"]],
4785
- ["cli", "troubleshoot", ["uipath-feedback"]],
4786
- ["governance", "operate", ["uipath-governance"]],
4787
- ["action-center", "build", ["uipath-human-in-the-loop"]],
4788
- ["document-understanding", "build", ["uipath-ixp"]],
4789
- [
4790
- "maestro",
4791
- "build",
4792
- ["uipath-maestro-bpmn", "uipath-maestro-case", "uipath-maestro-flow"]
4793
- ],
4794
- ["agenthub", "build", ["uipath-mcp-servers"]],
4795
- ["solution", "build", ["uipath-planner", "uipath-solution"]],
4796
- ["platform", "operate", ["uipath-platform"]],
4797
- ["quality", "troubleshoot", ["uipath-review"]],
4798
- ["rpa", "build", ["uipath-rpa"]],
4799
- ["business-rules", "build", ["uipath-rules"]],
4800
- ["cli", "operate", ["uipath-skill-catalog"]],
4801
- ["action-center", "operate", ["uipath-tasks"]],
4802
- ["test-manager", "operate", ["uipath-test"]],
4803
- ["platform", "troubleshoot", ["uipath-troubleshoot"]]
4804
- ]);
4805
- var KNOWN_SKILL_NAMES = new Set(Object.keys(SKILL_ATTRIBUTION));
4806
- var COMMAND_ATTRIBUTION = commandAttribution([
4807
- ["cli", "troubleshoot", ["uip.feedback"]],
4808
- ["llm-gateway", "operate", ["uip.llm-gateway"]],
4809
- ["llm-gateway", "operate", ["uip.llm-configuration", "uip.model-hub"]],
4810
- ["context-grounding", "build", ["uip.context-grounding"]],
4811
- ["api-workflow", "build", ["uip.api-workflow"]],
4812
- ["rpa", "build", ["uip.rpa-legacy"]],
4813
- ["conversational", "operate", ["uip.conversational"]],
4814
- ["agents", "build", ["uip.codedagent", "uip.agent"]],
4815
- ["coding-agents", "build", ["uip.coder"]],
4816
- ["agenthub", "build", ["uip.agenthub"]],
4817
- ["coded-apps", "build", ["uip.codedapp"]],
4818
- ["functions", "build", ["uip.function", "uip.functions"]],
4819
- ["solution", "build", ["uip.solution"]],
4820
- ["business-rules", "build", ["uip.rules"]],
4821
- ["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
4822
- ["llm-observability", "troubleshoot", ["uip.traces"]],
4823
- ["platform", "operate", ["uip.platform"]],
4824
- ["admin", "operate", ["uip.admin"]],
4825
- ["automation-ops", "operate", ["uip.aops"]],
4826
- ["documentation", "troubleshoot", ["uip.docsai"]],
4827
- ["governance", "operate", ["uip.gov"]],
4828
- ["insights", "operate", ["uip.insights"]],
4829
- ["document-understanding", "build", ["uip.ixp"]],
4830
- ["process-mining", "operate", ["uip.pm"]],
4831
- ["action-center", "operate", ["uip.tasks"]],
4832
- ["test-manager", "operate", ["uip.tm"]],
4833
- ["vertical-solutions", "build", ["uip.vss"]],
4834
- ["data-fabric", "operate", ["uip.df"]],
4835
- ["integration-service", "build", ["uip.is"]],
4836
- ["orchestrator", "operate", ["uip.or"]],
4837
- [
4838
- "cli",
4839
- "operate",
4840
- [
4841
- "uip.login",
4842
- "uip.logout",
4843
- "uip.user",
4844
- "uip.config",
4845
- "uip.tools",
4846
- "uip.skills",
4847
- "uip.completion",
4848
- "uip.update",
4849
- "uip.mcp",
4850
- "uip.track"
4851
- ]
4852
- ]
4853
- ]).sort((a, b) => b.prefix.length - a.prefix.length);
4854
- function normalizeCommandPath(value) {
4855
- if (typeof value !== "string") {
4856
- return;
4857
- }
4858
- const trimmed = value.trim().toLowerCase();
4859
- if (!trimmed) {
4860
- return;
4784
+ function describePermissionError(error) {
4785
+ for (const cur of walkErrorGraph(error)) {
4786
+ const message = typeof cur.message === "string" ? cur.message : undefined;
4787
+ const code = matchLocalPermissionCode(cur.code, message);
4788
+ if (!code)
4789
+ continue;
4790
+ const path = localPermissionPath(cur.path, message);
4791
+ return {
4792
+ code,
4793
+ message: message ?? code,
4794
+ ...path !== undefined ? { path } : {},
4795
+ instructions: localPermissionInstructions(code, path)
4796
+ };
4861
4797
  }
4862
- const tokens = trimmed.includes(" ") ? trimmed.split(/\s+/).filter((token) => token.length > 0).filter((token) => !token.startsWith("-")) : trimmed.split(".").filter((token) => token.length > 0);
4863
- if (tokens.length === 0) {
4864
- return;
4798
+ return;
4799
+ }
4800
+ function matchLocalPermissionCode(code, message) {
4801
+ if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
4802
+ return code;
4865
4803
  }
4866
- const commandTokens = tokens[0] === "uip" ? tokens : ["uip", ...tokens];
4867
- return commandTokens.join(".");
4804
+ const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
4805
+ return match ? match[1] : undefined;
4868
4806
  }
4869
- function getCommandProductModeAttribution(commandPath) {
4870
- const normalized = normalizeCommandPath(commandPath);
4871
- if (!normalized) {
4807
+ function localPermissionPath(path, message) {
4808
+ if (typeof path === "string")
4809
+ return path;
4810
+ return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
4811
+ }
4812
+ function readHeader(response, name) {
4813
+ const headers = response?.headers;
4814
+ if (!headers || typeof headers !== "object")
4872
4815
  return;
4816
+ if (typeof headers.get === "function") {
4817
+ const value = headers.get(name);
4818
+ if (value)
4819
+ return value;
4873
4820
  }
4874
- return COMMAND_ATTRIBUTION.find(({ prefix }) => normalized === prefix || normalized.startsWith(`${prefix}.`))?.attribution;
4821
+ const plain = headers;
4822
+ const key = Object.keys(plain).find((k) => k.toLowerCase() === name.toLowerCase());
4823
+ const value = key === undefined ? undefined : plain[key];
4824
+ return typeof value === "string" && value !== "" ? value : undefined;
4875
4825
  }
4876
- function normalizeSkillNameWithOptions(value, options) {
4877
- if (typeof value !== "string") {
4878
- return;
4826
+ function isHtmlDocument(body) {
4827
+ return /^\s*(<!doctype html|<html\b)/i.test(body);
4828
+ }
4829
+ function retryHintForRetryAfter(seconds) {
4830
+ if (seconds <= 1) {
4831
+ return "RetryAfter1Second";
4879
4832
  }
4880
- const normalized = value.trim().toLowerCase();
4881
- if (!normalized) {
4882
- return;
4833
+ if (seconds <= 10) {
4834
+ return "RetryAfter10Seconds";
4883
4835
  }
4884
- const hasLegacyNamespace = normalized.startsWith(LEGACY_SKILL_NAMESPACE);
4885
- if (hasLegacyNamespace && !options.allowLegacyNamespace) {
4886
- return;
4836
+ if (seconds <= 30) {
4837
+ return "RetryAfter30Seconds";
4887
4838
  }
4888
- const skillName = hasLegacyNamespace ? normalized.slice(LEGACY_SKILL_NAMESPACE.length) : normalized;
4889
- if (skillName.length > MAX_SKILL_NAME_LENGTH || !SKILL_NAME_PATTERN.test(skillName) || !KNOWN_SKILL_NAMES.has(skillName)) {
4890
- return;
4839
+ return "RetryAfter60Seconds";
4840
+ }
4841
+ function classifyError2(status, error) {
4842
+ const byStatus = classifyHttpStatus(status);
4843
+ if (byStatus)
4844
+ return byStatus;
4845
+ if (status === undefined && describePermissionError(error)) {
4846
+ return {
4847
+ errorCode: "local_permission_denied",
4848
+ retry: "RetryWillNotFix"
4849
+ };
4891
4850
  }
4892
- return skillName;
4851
+ const connectivity = describeConnectivityError(error);
4852
+ if (connectivity) {
4853
+ return {
4854
+ errorCode: "network_error",
4855
+ retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
4856
+ };
4857
+ }
4858
+ return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
4893
4859
  }
4894
- function normalizeSkillName(value) {
4895
- return normalizeSkillNameWithOptions(value, {
4896
- allowLegacyNamespace: false
4897
- });
4898
- }
4899
- function buildCommandTelemetryAttribution(commandPath, skillSource) {
4900
- const skillName = normalizeSkillName(skillSource);
4901
- return {
4902
- ...skillName ? { SkillName: skillName } : {},
4903
- ...getCommandProductModeAttribution(commandPath)
4904
- };
4905
- }
4906
- var AGENT_SESSION_ENV = {
4907
- [BaseDimensions.AgentModel]: "UIPATH_AGENT_MODEL",
4908
- [SkillsDimensions.PermissionMode]: "UIPATH_PERMISSION_MODE",
4909
- [SkillsDimensions.EffortLevel]: "UIPATH_EFFORT_LEVEL",
4910
- [SkillsDimensions.SkillsVersion]: "UIPATH_SKILLS_VERSION"
4911
- };
4912
- var MAX_TELEMETRY_TOKEN_LENGTH = 120;
4913
- function sanitizeTelemetryToken(value) {
4914
- return value.replace(/[^A-Za-z0-9:._/ -]/g, "_").slice(0, MAX_TELEMETRY_TOKEN_LENGTH);
4915
- }
4916
- function buildAgentSessionTelemetry(env) {
4917
- const dimensions = {};
4918
- for (const [key, variable] of Object.entries(AGENT_SESSION_ENV)) {
4919
- const value = env[variable]?.trim();
4920
- if (value) {
4921
- dimensions[key] = sanitizeTelemetryToken(value);
4922
- }
4923
- }
4924
- return dimensions;
4925
- }
4926
-
4927
- // ../common/src/telemetry/command-name.ts
4928
- var TELEMETRY_NAME_ROOT = "Cli";
4929
- var CLI_COMMAND_ROOT = "uip";
4930
- var TELEMETRY_NAME_BARE_ACTION = "Invoke";
4931
- function commandTelemetryName(parts) {
4932
- const action = vetCommandTokens(parts).map(pascalizeToken).join("");
4933
- return `${TELEMETRY_NAME_ROOT}.${action || TELEMETRY_NAME_BARE_ACTION}`;
4934
- }
4935
- function commandInvocationPath(parts) {
4936
- return [CLI_COMMAND_ROOT, ...vetCommandTokens(parts)].join(" ");
4937
- }
4938
- function vetCommandTokens(parts) {
4939
- const tokens = [];
4940
- for (const part of parts) {
4941
- const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== CLI_COMMAND_ROOT);
4942
- if (pieces.every(isCommandToken)) {
4943
- tokens.push(...pieces);
4944
- continue;
4945
- }
4946
- tokens.push(UNKNOWN_TOKEN);
4860
+ function withCarriedClass(inferred, error) {
4861
+ const errorCode = carriedErrorCode(error);
4862
+ const retry = carriedRetry(error);
4863
+ if (errorCode === undefined || errorCode === inferred.errorCode) {
4864
+ return {
4865
+ errorCode: inferred.errorCode,
4866
+ retry: retry ?? inferred.retry
4867
+ };
4947
4868
  }
4948
- return tokens;
4949
- }
4950
- function pascalizeToken(token) {
4951
- return token.split("-").filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
4952
- }
4953
- var COMMAND_TOKEN_PATTERN = /^[a-z][a-z0-9-]*$/;
4954
- var MAX_COMMAND_TOKEN_LENGTH = 32;
4955
- var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
4956
- function isCommandToken(token) {
4957
- return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token);
4958
- }
4959
- var UNKNOWN_TOKEN = "unknown";
4960
-
4961
- // ../common/src/telemetry/invocation-request.ts
4962
- var requestContextSlot = singleton("TelemetryInvocationRequestContext");
4963
- function activeContext() {
4964
- return telemetry.getActiveContext?.();
4869
+ return { errorCode, retry: retry ?? defaultRetryForErrorCode(errorCode) };
4965
4870
  }
4966
- function runWithInvocationRequest(fn) {
4967
- const context = telemetry.createRequestContext();
4968
- context.startedAt = invocationStartedAt();
4969
- requestContextSlot.set(context);
4970
- return telemetry.runWithContext(context, fn);
4971
- }
4972
- function ensureInvocationRequestScope(fn) {
4973
- if (activeContext() !== undefined) {
4974
- return fn();
4871
+ function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
4872
+ if (extractedMessage) {
4873
+ return `HTTP ${status}: ${extractedMessage}`;
4975
4874
  }
4976
- const kept = requestContextSlot.get();
4977
- return kept === undefined ? runWithInvocationRequest(fn) : telemetry.runWithContext(kept, fn);
4978
- }
4979
- function getInvocationRequestContext() {
4980
- return activeContext() ?? requestContextSlot.get();
4875
+ return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
4981
4876
  }
4982
- function emitInvocationRequest(name, success, properties) {
4983
- const context = getInvocationRequestContext();
4984
- telemetry.trackRequestResult(name, invocationElapsedMs(), success, properties, context);
4985
- if (context !== undefined && requestContextSlot.get() === context) {
4986
- requestContextSlot.clear();
4877
+ async function extractErrorDetails(error, options) {
4878
+ const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
4879
+ const response = err.response;
4880
+ const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
4881
+ const explicitStatus = err.status ?? response?.status;
4882
+ const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
4883
+ const status = explicitStatus ?? inferredStatus;
4884
+ const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
4885
+ let rawBody;
4886
+ let extractedMessage;
4887
+ let parsedBody;
4888
+ const textFn = response?.text?.bind(response);
4889
+ if (textFn) {
4890
+ const [bodyError, body] = await catchError((async () => textFn())());
4891
+ if (!bodyError && body) {
4892
+ rawBody = body;
4893
+ const [parseError, parsed] = catchError(() => JSON.parse(body));
4894
+ if (!parseError && parsed && typeof parsed === "object") {
4895
+ parsedBody = parsed;
4896
+ if (parsedBody.errors && typeof parsedBody.errors === "object") {
4897
+ for (const field of Object.values(parsedBody.errors)) {
4898
+ if (Array.isArray(field) && field.length > 0) {
4899
+ const first = field[0];
4900
+ if (first && typeof first.message === "string") {
4901
+ extractedMessage = first.message;
4902
+ break;
4903
+ }
4904
+ }
4905
+ }
4906
+ }
4907
+ if (!extractedMessage) {
4908
+ extractedMessage = typeof parsedBody.message === "string" ? parsedBody.message : typeof parsedBody.errorMessage === "string" ? parsedBody.errorMessage : typeof parsedBody.title === "string" ? parsedBody.title : undefined;
4909
+ }
4910
+ if (!extractedMessage) {
4911
+ extractedMessage = body;
4912
+ }
4913
+ if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
4914
+ extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
4915
+ }
4916
+ } else {
4917
+ extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
4918
+ }
4919
+ }
4987
4920
  }
4988
- }
4989
-
4990
- // ../common/src/trackedAction.ts
4991
- var pollSignalSlot = singleton("PollSignal");
4992
- var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
4993
- var processContext = {
4994
- exit: (code) => {
4995
- recordExitCode(code);
4996
- setExitCode(code);
4997
- },
4998
- get pollSignal() {
4999
- return pollSignalSlot.get();
4921
+ let message;
4922
+ let result = "Failure";
4923
+ const classificationStatus = status ?? findHttpStatusInGraph(error);
4924
+ const classification = classifyError2(classificationStatus, error);
4925
+ let retry = classification.retry;
4926
+ const htmlForbidden = status === 403 && rawBody !== undefined && isHtmlDocument(rawBody);
4927
+ const rayId = htmlForbidden ? readHeader(response, "cf-ray") : undefined;
4928
+ const cloudflareBlock = htmlForbidden && (rayId !== undefined || /\bcloudflare\b/i.test(readHeader(response, "server") ?? ""));
4929
+ if (status === 401) {
4930
+ message = DEFAULT_401;
4931
+ result = "AuthenticationError";
4932
+ } else if (cloudflareBlock) {
4933
+ message = rayId ? `${CLOUDFLARE_BLOCK_403} Cloudflare Ray ID: ${rayId}.` : CLOUDFLARE_BLOCK_403;
4934
+ } else if (status === 403) {
4935
+ message = options?.forbiddenMessage ?? DEFAULT_403;
4936
+ result = "AuthenticationError";
4937
+ } else if (status === 405) {
4938
+ message = DEFAULT_405;
4939
+ } else if (status === 413) {
4940
+ message = DEFAULT_413;
4941
+ } else if (status === 400 || status === 422) {
4942
+ message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
4943
+ result = "ValidationError";
4944
+ } else if (status === 429) {
4945
+ message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
4946
+ } else if (extractedMessage) {
4947
+ if (isSuccessfulResponse && rawMessage !== "Unknown error") {
4948
+ message = rawMessage;
4949
+ } else {
4950
+ message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
4951
+ }
4952
+ } else if (status) {
4953
+ if (inferredStatus !== undefined) {
4954
+ message = rawMessage;
4955
+ } else if (rawMessage === "Unknown error" && response) {
4956
+ const statusText = response.statusText;
4957
+ message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
4958
+ } else {
4959
+ message = `HTTP ${status}: ${rawMessage}`;
4960
+ }
4961
+ } else {
4962
+ message = rawMessage;
5000
4963
  }
5001
- };
5002
- var TELEMETRY_ARG_VALUE_WITHHELD = "<provided>";
5003
- var TELEMETRY_ARG_VALUE_DEFAULTED = "<default>";
5004
- function recordableArgValue(value, choices) {
5005
- if (typeof value === "boolean" || typeof value === "number") {
5006
- return value;
4964
+ if (status === undefined) {
4965
+ const connectivity = describeConnectivityError(error);
4966
+ if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
4967
+ message = `${message}: ${connectivity.message}`;
4968
+ }
5007
4969
  }
5008
- if (choices && choices.length > 0) {
5009
- if (typeof value === "string" && choices.includes(value)) {
5010
- return value;
4970
+ const permission = status === undefined ? describePermissionError(error) : undefined;
4971
+ if (permission) {
4972
+ if (permission.message !== message && !message.includes(permission.message)) {
4973
+ message = `${message}: ${permission.message}`;
5011
4974
  }
5012
- if (Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string" && choices.includes(entry))) {
5013
- return value.join(",");
4975
+ if (!message.includes(permission.instructions)) {
4976
+ const punctuated = message.endsWith(".") ? message : `${message}.`;
4977
+ message = `${punctuated} ${permission.instructions}`;
5014
4978
  }
5015
4979
  }
5016
- return TELEMETRY_ARG_VALUE_WITHHELD;
5017
- }
5018
- function extractCommandParams(cmd) {
5019
- const params = {};
5020
- forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
5021
- const recordable = recordableArgValue(value, choices);
5022
- params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
5023
- });
5024
- return params;
5025
- }
5026
- function isDefaultedOption(cmd, name) {
5027
- const source = cmd.getOptionValueSource?.(name);
5028
- return source === "default" || source === "implied";
5029
- }
5030
- function isDefaultedPositional(cmd, index) {
5031
- return index >= (cmd.args?.length ?? 0);
5032
- }
5033
- function forEachSuppliedArgument(cmd, visit) {
5034
- const registered = cmd.registeredArguments ?? [];
5035
- const processed = cmd.processedArgs ?? [];
5036
- for (let i = 0;i < registered.length; i++) {
5037
- const name = registered[i].name();
5038
- if (name && processed[i] !== undefined) {
5039
- visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
4980
+ let details = rawMessage;
4981
+ if (htmlForbidden) {
4982
+ details = cloudflareBlock ? CLOUDFLARE_BLOCK_403_INSTRUCTIONS : HTML_RESPONSE_MESSAGE;
4983
+ } else if (rawBody) {
4984
+ if (parsedBody) {
4985
+ const extra = {};
4986
+ if (parsedBody.errorCode)
4987
+ extra.errorCode = parsedBody.errorCode;
4988
+ if (parsedBody.detail)
4989
+ extra.detail = parsedBody.detail;
4990
+ if (parsedBody.details)
4991
+ extra.details = parsedBody.details;
4992
+ if (parsedBody.errors != null)
4993
+ extra.errors = parsedBody.errors;
4994
+ if (parsedBody.data && typeof parsedBody.data === "object" && Object.keys(parsedBody.data).length > 0) {
4995
+ extra.data = parsedBody.data;
4996
+ }
4997
+ details = Object.keys(extra).length > 0 ? JSON.stringify(extra) : rawBody;
4998
+ } else {
4999
+ details = rawBody;
5040
5000
  }
5001
+ } else if (typeof err.message === "string") {
5002
+ details = err.message;
5003
+ } else {
5004
+ details = describeThrownValue(error);
5041
5005
  }
5042
- const choicesByAttribute = new Map;
5043
- for (const option of cmd.options) {
5044
- choicesByAttribute.set(option.attributeName(), option.argChoices);
5006
+ const context = {};
5007
+ if (classificationStatus) {
5008
+ context.httpStatus = classificationStatus;
5045
5009
  }
5046
- for (const [key, value] of Object.entries(cmd.opts())) {
5047
- if (key && value !== undefined) {
5048
- visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
5049
- }
5010
+ if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
5011
+ context.errorCode = parsedBody.errorCode;
5012
+ } else if (parsedBody?.code && typeof parsedBody.code === "string") {
5013
+ context.errorCode = parsedBody.code;
5050
5014
  }
5051
- }
5052
- function withheldArgumentValues(cmd) {
5053
- const values = [];
5054
- forEachSuppliedArgument(cmd, (_name, value, choices, defaulted) => {
5055
- if (defaulted) {
5056
- return;
5057
- }
5058
- if (recordableArgValue(value, choices) === TELEMETRY_ARG_VALUE_WITHHELD) {
5059
- values.push(value);
5060
- }
5061
- });
5062
- return values;
5063
- }
5064
- function deriveCommandParts(cmd) {
5065
- const parts = [];
5066
- let current = cmd;
5067
- while (current) {
5068
- const name = current.name();
5069
- if (name) {
5070
- parts.unshift(name);
5071
- }
5072
- current = current.parent;
5015
+ if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
5016
+ context.requestId = parsedBody.requestId;
5017
+ } else if (cloudflareBlock && rayId) {
5018
+ context.requestId = rayId;
5073
5019
  }
5074
- if (parts.length > 1) {
5075
- parts.shift();
5020
+ if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
5021
+ context.traceId = parsedBody.traceId;
5076
5022
  }
5077
- return parts;
5078
- }
5079
- function isErrorContext(value) {
5080
- return value !== null && typeof value === "object";
5081
- }
5082
- function commandHelpHint(commandPath) {
5083
- return `An unexpected error occurred. Run '${commandPath} --help' to verify command syntax, or run with --log-level debug for details.`;
5084
- }
5085
- function isPromptCancellation(error) {
5086
- return error instanceof Error && error.name === "ExitPromptError";
5087
- }
5088
- function implicitLimitViolation(cmd) {
5089
- if (getOutputFilter() === undefined) {
5090
- return;
5023
+ if (permission?.path !== undefined) {
5024
+ context.path = permission.path;
5091
5025
  }
5092
- const hasLimit = cmd.options.some((o) => o.attributeName() === "limit");
5093
- if (!hasLimit || cmd.getOptionValueSource("limit") !== "default") {
5094
- return;
5026
+ if (status === 429) {
5027
+ const retryAfterValue = readHeader(response, "retry-after");
5028
+ if (retryAfterValue) {
5029
+ const seconds = Number(retryAfterValue);
5030
+ if (!Number.isNaN(seconds)) {
5031
+ context.retryAfter = seconds;
5032
+ retry = retryHintForRetryAfter(seconds);
5033
+ }
5034
+ }
5095
5035
  }
5096
- return new FilterImplicitLimitError(String(cmd.opts().limit));
5097
- }
5098
- function exitCodeFromProcess(fallback) {
5099
- return typeof process.exitCode === "number" ? process.exitCode : fallback;
5100
- }
5101
- Command.prototype.trackedAction = function(context, fn, properties) {
5102
- const command = this;
5103
- return this.action(async (...args) => {
5104
- await loadOutputCodecsAsync({
5105
- yaml: getOutputFormat() === "yaml",
5106
- filter: getOutputFilter() !== undefined
5107
- });
5108
- const commandParts = deriveCommandParts(command);
5109
- const telemetryName = commandTelemetryName(commandParts);
5110
- const commandPath = commandInvocationPath(commandParts);
5111
- const props = typeof properties === "function" ? properties(...args) : properties;
5112
- markCommandStart();
5113
- const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
5114
- try {
5115
- const startTime = performance.now();
5116
- let errorMessage;
5117
- let fallbackExitCode = EXIT_CODES.Success;
5118
- clearRecordedCommandFailureTelemetry();
5119
- const [error] = await catchError(ensureInvocationRequestScope(() => {
5120
- const violation = implicitLimitViolation(command);
5121
- if (violation) {
5122
- return Promise.reject(violation);
5123
- }
5124
- return fn(...args);
5125
- }));
5126
- if (error) {
5127
- errorMessage = error instanceof Error ? error.message : String(error);
5128
- logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
5129
- const typed = error;
5130
- const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
5131
- const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
5132
- const finalResult = customResult ?? RESULTS.Failure;
5133
- const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
5134
- const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
5135
- const typedRetry = typed.retry ?? typed.Retry;
5136
- const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
5137
- const typedContext = typed.context ?? typed.Context;
5138
- const customContext = isErrorContext(typedContext) ? typedContext : undefined;
5139
- const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
5140
- fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
5141
- OutputFormatter.error({
5142
- Result: finalResult,
5143
- ...customErrorCode ? { ErrorCode: customErrorCode } : {},
5144
- Message: errorMessage,
5145
- Instructions: customInstructions ?? commandHelpHint(commandPath),
5146
- ...customRetry ? { Retry: customRetry } : {},
5147
- ...customContext ? { Context: customContext } : {}
5148
- });
5149
- context.exit(fallbackExitCode);
5036
+ const hasContext = Object.keys(context).length > 0;
5037
+ let parsedErrors;
5038
+ if (parsedBody?.errors && typeof parsedBody.errors === "object") {
5039
+ const errors = {};
5040
+ for (const [field, raw] of Object.entries(parsedBody.errors)) {
5041
+ if (Array.isArray(raw)) {
5042
+ const messages = raw.map((entry) => {
5043
+ if (typeof entry === "string")
5044
+ return entry;
5045
+ if (entry && typeof entry === "object" && typeof entry.message === "string") {
5046
+ return entry.message;
5047
+ }
5048
+ return String(entry);
5049
+ }).filter(Boolean);
5050
+ if (messages.length > 0)
5051
+ errors[field] = messages;
5052
+ } else if (typeof raw === "string") {
5053
+ errors[field] = [raw];
5150
5054
  }
5151
- const durationMs = performance.now() - startTime;
5152
- recordCommandDuration(durationMs);
5153
- const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
5154
- const recordedFailure = takeRecordedCommandFailureTelemetry();
5155
- const success = !error && exitCode === 0;
5156
- const terminalTelemetry = buildCommandTerminalTelemetryProperties({
5157
- error,
5158
- exitCode,
5159
- recordedFailure,
5160
- pollSignal: context.pollSignal
5055
+ }
5056
+ if (Object.keys(errors).length > 0)
5057
+ parsedErrors = errors;
5058
+ }
5059
+ return {
5060
+ result,
5061
+ ...withCarriedClass({ errorCode: classification.errorCode, retry }, error),
5062
+ message,
5063
+ details,
5064
+ ...hasContext ? { context } : {},
5065
+ ...parsedErrors ? { parsedErrors } : {}
5066
+ };
5067
+ }
5068
+ async function extractErrorMessage(error, options) {
5069
+ const { message } = await extractErrorDetails(error, options);
5070
+ return message;
5071
+ }
5072
+
5073
+ // ../common/src/pass-through-tail.ts
5074
+ function maybeOption(arg) {
5075
+ return arg.length > 1 && arg[0] === "-";
5076
+ }
5077
+ function tokenizeTail(cmd, tail) {
5078
+ const find = (flag) => cmd.options.find((option) => option.long === flag || option.short === flag);
5079
+ const digitShort = cmd.options.some((option) => option.short !== undefined && /^-\d$/.test(option.short));
5080
+ const negativeNumber = (arg) => !digitShort && /^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg);
5081
+ const tokens = [];
5082
+ let firstUnknown = -1;
5083
+ let sentinel = -1;
5084
+ let variadic;
5085
+ let group;
5086
+ let groupIndex = 0;
5087
+ let i = 0;
5088
+ while (i < tail.length || group !== undefined) {
5089
+ const index = group === undefined ? i : groupIndex;
5090
+ const arg = group ?? tail[i++];
5091
+ group = undefined;
5092
+ if (arg === "--") {
5093
+ sentinel = index;
5094
+ tokens.push({ kind: "sentinel", index });
5095
+ for (let j = i;j < tail.length; j++) {
5096
+ tokens.push({
5097
+ kind: "operand",
5098
+ index: j,
5099
+ text: tail[j],
5100
+ literal: true
5101
+ });
5102
+ }
5103
+ break;
5104
+ }
5105
+ if (variadic && (!maybeOption(arg) || negativeNumber(arg))) {
5106
+ tokens.push({
5107
+ kind: "option",
5108
+ index,
5109
+ text: arg,
5110
+ option: variadic,
5111
+ value: arg
5161
5112
  });
5162
- if (terminalTelemetry[CommandDimensions.ErrorClass] === "internal" && error) {
5163
- telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { [CommandDimensions.CommandName]: commandPath }, getInvocationRequestContext());
5113
+ continue;
5114
+ }
5115
+ variadic = undefined;
5116
+ if (maybeOption(arg)) {
5117
+ const option = find(arg);
5118
+ if (option) {
5119
+ let value;
5120
+ if (option.required) {
5121
+ value = tail[i];
5122
+ if (value !== undefined)
5123
+ i++;
5124
+ } else if (option.optional) {
5125
+ const next = tail[i];
5126
+ if (next !== undefined && (!maybeOption(next) || negativeNumber(next))) {
5127
+ value = next;
5128
+ i++;
5129
+ }
5130
+ }
5131
+ tokens.push({
5132
+ kind: "option",
5133
+ index,
5134
+ text: arg,
5135
+ option,
5136
+ ...value === undefined ? {} : { value }
5137
+ });
5138
+ variadic = option.variadic ? option : undefined;
5139
+ continue;
5164
5140
  }
5165
- const commandParams = extractCommandParams(command);
5166
- if (props) {
5167
- for (const key of Object.keys(props)) {
5168
- delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
5141
+ }
5142
+ if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
5143
+ const option = find(`-${arg[1]}`);
5144
+ if (option) {
5145
+ if (option.required || option.optional) {
5146
+ tokens.push({
5147
+ kind: "option",
5148
+ index,
5149
+ text: arg,
5150
+ option,
5151
+ value: arg.slice(2)
5152
+ });
5153
+ } else {
5154
+ tokens.push({ kind: "option", index, text: arg, option });
5155
+ group = `-${arg.slice(2)}`;
5156
+ groupIndex = index;
5169
5157
  }
5158
+ continue;
5170
5159
  }
5171
- const baseProperties = redactProperties({
5172
- ...commandParams,
5173
- ...props,
5174
- ...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
5175
- ...buildAgentSessionTelemetry(process.env),
5176
- [CommandDimensions.CommandName]: commandPath,
5177
- [CommandDimensions.IsCommand]: "true",
5178
- ...terminalTelemetry,
5179
- ...errorMessage ? { [CommandDimensions.ErrorMessage]: errorMessage } : {}
5160
+ }
5161
+ if (/^--[^=]+=/.test(arg)) {
5162
+ const equals = arg.indexOf("=");
5163
+ const option = find(arg.slice(0, equals));
5164
+ if (option && (option.required || option.optional)) {
5165
+ tokens.push({
5166
+ kind: "option",
5167
+ index,
5168
+ text: arg,
5169
+ option,
5170
+ value: arg.slice(equals + 1)
5171
+ });
5172
+ continue;
5173
+ }
5174
+ }
5175
+ if (maybeOption(arg) && !negativeNumber(arg)) {
5176
+ const equals = arg.startsWith("--") ? arg.indexOf("=") : -1;
5177
+ if (firstUnknown === -1)
5178
+ firstUnknown = index;
5179
+ tokens.push({
5180
+ kind: "unknown",
5181
+ index,
5182
+ text: arg,
5183
+ flag: equals > 0 ? arg.slice(0, equals) : arg,
5184
+ ...equals > 0 ? { inlineValue: arg.slice(equals + 1) } : {}
5180
5185
  });
5181
- emitInvocationRequest(telemetryName, success, baseProperties);
5182
- } finally {
5183
- releaseSuppliedArgumentValues(supplied);
5186
+ continue;
5184
5187
  }
5185
- });
5186
- };
5187
-
5188
- // ../common/src/error-handler.ts
5189
- 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.";
5190
- 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.";
5191
- var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
5192
- 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.";
5193
- var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
5194
- var NETWORK_ERROR_CODES = new Set([
5195
- "ECONNREFUSED",
5196
- "ECONNRESET",
5197
- "ENOTFOUND",
5198
- "EAI_AGAIN",
5199
- "ETIMEDOUT",
5200
- "EPIPE",
5201
- "EHOSTUNREACH",
5202
- "ENETUNREACH",
5203
- "EAI_FAIL"
5204
- ]);
5205
- var TLS_ERROR_CODES2 = new Set([
5206
- "SELF_SIGNED_CERT_IN_CHAIN",
5207
- "DEPTH_ZERO_SELF_SIGNED_CERT",
5208
- "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
5209
- "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
5210
- "UNABLE_TO_GET_ISSUER_CERT",
5211
- "CERT_HAS_EXPIRED",
5212
- "CERT_UNTRUSTED",
5213
- "ERR_TLS_CERT_ALTNAME_INVALID"
5214
- ]);
5215
- 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.";
5216
- 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.";
5217
- var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
5218
- function localPermissionInstructions(code, path2) {
5219
- const target = path2 !== undefined ? `'${path2}'` : "a local file or resource";
5220
- if (code === "EROFS") {
5221
- 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.";
5188
+ tokens.push({ kind: "operand", index, text: arg, literal: false });
5222
5189
  }
5223
- const onWindows = typeof process !== "undefined" && process.platform === "win32";
5224
- 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.";
5225
- 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}`;
5190
+ return { tokens, firstUnknown, sentinel };
5226
5191
  }
5227
- function describeConnectivityError(error) {
5228
- for (const cur of walkErrorGraph(error)) {
5229
- const code = typeof cur.code === "string" ? cur.code : undefined;
5230
- const message = typeof cur.message === "string" ? cur.message : undefined;
5231
- if (code && TLS_ERROR_CODES2.has(code)) {
5232
- return {
5233
- code,
5234
- kind: "tls",
5235
- message: message ?? code,
5236
- instructions: TLS_INSTRUCTIONS
5237
- };
5238
- }
5239
- if (code && NETWORK_ERROR_CODES.has(code)) {
5192
+
5193
+ // ../common/src/project-telemetry.ts
5194
+ var RESOLVER = Symbol.for("@uipath/common/projectTelemetryResolver");
5195
+ var CAPTURE = Symbol.for("@uipath/common/projectTelemetryCapture");
5196
+ var CONTEXT_RESOLVER = Symbol.for("@uipath/common/projectContextTelemetryResolver");
5197
+ var RULES = Symbol.for("@uipath/common/projectTargetRules");
5198
+ function logSkipped(what, error) {
5199
+ logger.debug(`[project-telemetry] ${what} skipped: ${error instanceof Error ? error.message : String(error)}`);
5200
+ }
5201
+ function bounded(work, what) {
5202
+ return withinProjectIdentityBudget(work, () => logSkipped(what, `no answer within ${PROJECT_IDENTITY_LOOKUP_BUDGET_MS} ms`));
5203
+ }
5204
+ async function identityWithContext(command, identity) {
5205
+ const props = projectIdentityProperties(identity);
5206
+ if (!identity.projectDirectory || isProjectTelemetryDisabled())
5207
+ return props;
5208
+ for (let node = command;node; node = node.parent ?? undefined) {
5209
+ const resolver = node[CONTEXT_RESOLVER];
5210
+ if (typeof resolver !== "function")
5211
+ continue;
5212
+ try {
5240
5213
  return {
5241
- code,
5242
- kind: "network",
5243
- message: message ?? code,
5244
- instructions: NETWORK_INSTRUCTIONS
5214
+ ...await resolver(identity.projectDirectory),
5215
+ ...props
5245
5216
  };
5217
+ } catch (error) {
5218
+ logSkipped("solution context lookup", error);
5219
+ return props;
5246
5220
  }
5247
5221
  }
5248
- return;
5222
+ return props;
5249
5223
  }
5250
- function describePermissionError(error) {
5251
- for (const cur of walkErrorGraph(error)) {
5252
- const message = typeof cur.message === "string" ? cur.message : undefined;
5253
- const code = matchLocalPermissionCode(cur.code, message);
5254
- if (!code)
5255
- continue;
5256
- const path2 = localPermissionPath(cur.path, message);
5257
- return {
5258
- code,
5259
- message: message ?? code,
5260
- ...path2 !== undefined ? { path: path2 } : {},
5261
- instructions: localPermissionInstructions(code, path2)
5262
- };
5224
+ function getProjectTelemetryResolver(command) {
5225
+ for (let node = command;node; node = node.parent) {
5226
+ const resolver = node[RESOLVER];
5227
+ if (typeof resolver === "function")
5228
+ return resolver;
5263
5229
  }
5264
5230
  return;
5265
5231
  }
5266
- function matchLocalPermissionCode(code, message) {
5267
- if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
5268
- return code;
5232
+ function attachProjectTelemetryCapture(command, capture) {
5233
+ command[CAPTURE] = capture;
5234
+ }
5235
+ class ProjectTelemetrySession {
5236
+ resolver;
5237
+ command;
5238
+ target;
5239
+ props = {};
5240
+ explicit = false;
5241
+ input;
5242
+ constructor(resolver, command) {
5243
+ this.resolver = resolver;
5244
+ this.command = command;
5245
+ }
5246
+ async setTarget(path) {
5247
+ this.target = path;
5248
+ if (this.input) {
5249
+ await this.resolve({
5250
+ ...this.input,
5251
+ phase: "after",
5252
+ success: true
5253
+ });
5254
+ this.explicit = true;
5255
+ }
5269
5256
  }
5270
- const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
5271
- return match ? match[1] : undefined;
5272
- }
5273
- function localPermissionPath(path2, message) {
5274
- if (typeof path2 === "string")
5275
- return path2;
5276
- return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
5277
- }
5278
- function isHtmlDocument(body) {
5279
- return /^\s*(<!doctype html|<html\b)/i.test(body);
5280
- }
5281
- function retryHintForRetryAfter(seconds) {
5282
- if (seconds <= 1) {
5283
- return "RetryAfter1Second";
5257
+ async setIdentity(identity) {
5258
+ try {
5259
+ const props = await bounded(identityWithContext(this.command, identity), "project identity capture");
5260
+ if (props !== undefined)
5261
+ this.setProperties(props);
5262
+ } catch (error) {
5263
+ logSkipped("project identity capture", error);
5264
+ }
5284
5265
  }
5285
- if (seconds <= 10) {
5286
- return "RetryAfter10Seconds";
5266
+ setProperties(properties) {
5267
+ try {
5268
+ this.props = { ...properties };
5269
+ this.explicit = true;
5270
+ } catch (error) {
5271
+ logSkipped("project identity properties", error);
5272
+ }
5287
5273
  }
5288
- if (seconds <= 30) {
5289
- return "RetryAfter30Seconds";
5274
+ properties() {
5275
+ return { ...this.props };
5276
+ }
5277
+ async resolve(input) {
5278
+ this.input = input;
5279
+ if (this.explicit)
5280
+ return;
5281
+ try {
5282
+ const props = await bounded(this.resolver({
5283
+ ...input,
5284
+ target: this.target
5285
+ }), `project identity (${input.phase})`);
5286
+ if (props !== undefined) {
5287
+ this.props = props;
5288
+ }
5289
+ } catch (error) {
5290
+ logSkipped(`project identity (${input.phase})`, error);
5291
+ }
5290
5292
  }
5291
- return "RetryAfter60Seconds";
5292
5293
  }
5293
- function classifyError2(status, error) {
5294
- if (status === 400 || status === 409 || status === 422) {
5295
- return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
5294
+
5295
+ // ../common/src/telemetry/command-attribution.ts
5296
+ var LEGACY_SKILL_NAMESPACE = "uipath:";
5297
+ var MAX_SKILL_NAME_LENGTH = 80;
5298
+ var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
5299
+ function productMode(productArea, mode) {
5300
+ return { ProductArea: productArea, Mode: mode };
5301
+ }
5302
+ function attributionRecord(groups) {
5303
+ const record = {};
5304
+ for (const [productArea, mode, names] of groups) {
5305
+ const attribution = productMode(productArea, mode);
5306
+ for (const name of names) {
5307
+ record[name] = attribution;
5308
+ }
5296
5309
  }
5297
- if (status === 401) {
5298
- return {
5299
- errorCode: "authentication_required",
5300
- retry: "RetryWillNotFix"
5301
- };
5310
+ return record;
5311
+ }
5312
+ function commandAttribution(groups) {
5313
+ const entries = [];
5314
+ for (const [productArea, mode, prefixes] of groups) {
5315
+ const attribution = productMode(productArea, mode);
5316
+ for (const prefix of prefixes) {
5317
+ entries.push({ prefix, attribution });
5318
+ }
5319
+ }
5320
+ return entries;
5321
+ }
5322
+ var SKILL_ATTRIBUTION = attributionRecord([
5323
+ ["admin", "operate", ["uipath-admin"]],
5324
+ ["agents", "build", ["uipath-agents"]],
5325
+ ["api-workflow", "build", ["uipath-api-workflow"]],
5326
+ ["automation-discovery", "build", ["uipath-automation-discovery"]],
5327
+ ["coded-apps", "build", ["uipath-coded-apps"]],
5328
+ ["data-fabric", "operate", ["uipath-data-fabric"]],
5329
+ ["cli", "troubleshoot", ["uipath-feedback"]],
5330
+ ["governance", "operate", ["uipath-governance"]],
5331
+ ["action-center", "build", ["uipath-human-in-the-loop"]],
5332
+ ["document-understanding", "build", ["uipath-ixp"]],
5333
+ [
5334
+ "maestro",
5335
+ "build",
5336
+ ["uipath-maestro-bpmn", "uipath-maestro-case", "uipath-maestro-flow"]
5337
+ ],
5338
+ ["agenthub", "build", ["uipath-mcp-servers"]],
5339
+ ["solution", "build", ["uipath-planner", "uipath-solution"]],
5340
+ ["platform", "operate", ["uipath-platform"]],
5341
+ ["quality", "troubleshoot", ["uipath-review"]],
5342
+ ["rpa", "build", ["uipath-rpa"]],
5343
+ ["business-rules", "build", ["uipath-rules"]],
5344
+ ["cli", "operate", ["uipath-skill-catalog"]],
5345
+ ["action-center", "operate", ["uipath-tasks"]],
5346
+ ["test-manager", "operate", ["uipath-test"]],
5347
+ ["platform", "troubleshoot", ["uipath-troubleshoot"]]
5348
+ ]);
5349
+ var KNOWN_SKILL_NAMES = new Set(Object.keys(SKILL_ATTRIBUTION));
5350
+ var COMMAND_ATTRIBUTION = commandAttribution([
5351
+ ["cli", "troubleshoot", ["uip.feedback"]],
5352
+ ["llm-gateway", "operate", ["uip.llm-gateway"]],
5353
+ ["llm-gateway", "operate", ["uip.llm-configuration", "uip.model-hub"]],
5354
+ ["context-grounding", "build", ["uip.context-grounding"]],
5355
+ ["api-workflow", "build", ["uip.api-workflow"]],
5356
+ ["rpa", "build", ["uip.rpa-legacy"]],
5357
+ ["conversational", "operate", ["uip.conversational"]],
5358
+ ["agents", "build", ["uip.codedagent", "uip.agent"]],
5359
+ ["coding-agents", "build", ["uip.coder"]],
5360
+ ["agenthub", "build", ["uip.agenthub"]],
5361
+ ["coded-apps", "build", ["uip.codedapp"]],
5362
+ ["functions", "build", ["uip.function", "uip.functions"]],
5363
+ ["solution", "build", ["uip.solution"]],
5364
+ ["business-rules", "build", ["uip.rules"]],
5365
+ ["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
5366
+ ["llm-observability", "troubleshoot", ["uip.traces"]],
5367
+ ["platform", "operate", ["uip.platform"]],
5368
+ ["admin", "operate", ["uip.admin"]],
5369
+ ["automation-ops", "operate", ["uip.aops"]],
5370
+ ["documentation", "troubleshoot", ["uip.docsai"]],
5371
+ ["governance", "operate", ["uip.gov"]],
5372
+ ["insights", "operate", ["uip.insights"]],
5373
+ ["document-understanding", "build", ["uip.ixp"]],
5374
+ ["process-mining", "operate", ["uip.pm"]],
5375
+ ["action-center", "operate", ["uip.tasks"]],
5376
+ ["test-manager", "operate", ["uip.tm"]],
5377
+ ["vertical-solutions", "build", ["uip.vss"]],
5378
+ ["data-fabric", "operate", ["uip.df"]],
5379
+ ["integration-service", "build", ["uip.is"]],
5380
+ ["orchestrator", "operate", ["uip.or"]],
5381
+ [
5382
+ "cli",
5383
+ "operate",
5384
+ [
5385
+ "uip.login",
5386
+ "uip.logout",
5387
+ "uip.user",
5388
+ "uip.config",
5389
+ "uip.tools",
5390
+ "uip.skills",
5391
+ "uip.completion",
5392
+ "uip.update",
5393
+ "uip.mcp",
5394
+ "uip.track"
5395
+ ]
5396
+ ]
5397
+ ]).sort((a, b) => b.prefix.length - a.prefix.length);
5398
+ function normalizeCommandPath(value) {
5399
+ if (typeof value !== "string") {
5400
+ return;
5302
5401
  }
5303
- if (status === 403) {
5304
- return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
5402
+ const trimmed = value.trim().toLowerCase();
5403
+ if (!trimmed) {
5404
+ return;
5305
5405
  }
5306
- if (status === 404) {
5307
- return { errorCode: "not_found", retry: "RetryWillNotFix" };
5406
+ const tokens = trimmed.includes(" ") ? trimmed.split(/\s+/).filter((token) => token.length > 0).filter((token) => !token.startsWith("-")) : trimmed.split(".").filter((token) => token.length > 0);
5407
+ if (tokens.length === 0) {
5408
+ return;
5308
5409
  }
5309
- if (status === 405) {
5310
- return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
5410
+ const commandTokens = tokens[0] === "uip" ? tokens : ["uip", ...tokens];
5411
+ return commandTokens.join(".");
5412
+ }
5413
+ function getCommandProductModeAttribution(commandPath) {
5414
+ const normalized = normalizeCommandPath(commandPath);
5415
+ if (!normalized) {
5416
+ return;
5311
5417
  }
5312
- if (status === 413) {
5313
- return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
5418
+ return COMMAND_ATTRIBUTION.find(({ prefix }) => normalized === prefix || normalized.startsWith(`${prefix}.`))?.attribution;
5419
+ }
5420
+ function normalizeSkillNameWithOptions(value, options) {
5421
+ if (typeof value !== "string") {
5422
+ return;
5314
5423
  }
5315
- if (status === 408) {
5316
- return { errorCode: "timeout", retry: "RetryLater" };
5424
+ const normalized = value.trim().toLowerCase();
5425
+ if (!normalized) {
5426
+ return;
5317
5427
  }
5318
- if (status === 429) {
5319
- return { errorCode: "rate_limited", retry: "RetryLater" };
5428
+ const hasLegacyNamespace = normalized.startsWith(LEGACY_SKILL_NAMESPACE);
5429
+ if (hasLegacyNamespace && !options.allowLegacyNamespace) {
5430
+ return;
5320
5431
  }
5321
- if (status !== undefined && status >= 500 && status < 600) {
5322
- return { errorCode: "server_error", retry: "RetryLater" };
5432
+ const skillName = hasLegacyNamespace ? normalized.slice(LEGACY_SKILL_NAMESPACE.length) : normalized;
5433
+ if (skillName.length > MAX_SKILL_NAME_LENGTH || !SKILL_NAME_PATTERN.test(skillName) || !KNOWN_SKILL_NAMES.has(skillName)) {
5434
+ return;
5323
5435
  }
5324
- if (status === undefined && describePermissionError(error)) {
5325
- return {
5326
- errorCode: "local_permission_denied",
5327
- retry: "RetryWillNotFix"
5328
- };
5436
+ return skillName;
5437
+ }
5438
+ function normalizeSkillName(value) {
5439
+ return normalizeSkillNameWithOptions(value, {
5440
+ allowLegacyNamespace: false
5441
+ });
5442
+ }
5443
+ function buildCommandTelemetryAttribution(commandPath, skillSource) {
5444
+ const skillName = normalizeSkillName(skillSource);
5445
+ return {
5446
+ ...skillName ? { SkillName: skillName } : {},
5447
+ ...getCommandProductModeAttribution(commandPath)
5448
+ };
5449
+ }
5450
+ var AGENT_SESSION_ENV = {
5451
+ [BaseDimensions.AgentModel]: "UIPATH_AGENT_MODEL",
5452
+ [SkillsDimensions.PermissionMode]: "UIPATH_PERMISSION_MODE",
5453
+ [SkillsDimensions.EffortLevel]: "UIPATH_EFFORT_LEVEL",
5454
+ [SkillsDimensions.SkillsVersion]: "UIPATH_SKILLS_VERSION"
5455
+ };
5456
+ var MAX_TELEMETRY_TOKEN_LENGTH = 120;
5457
+ function sanitizeTelemetryToken(value) {
5458
+ return value.replace(/[^A-Za-z0-9:._/ -]/g, "_").slice(0, MAX_TELEMETRY_TOKEN_LENGTH);
5459
+ }
5460
+ function buildAgentSessionTelemetry(env) {
5461
+ const dimensions = {};
5462
+ for (const [key, variable] of Object.entries(AGENT_SESSION_ENV)) {
5463
+ const value = env[variable]?.trim();
5464
+ if (value) {
5465
+ dimensions[key] = sanitizeTelemetryToken(value);
5466
+ }
5329
5467
  }
5330
- const connectivity = describeConnectivityError(error);
5331
- if (connectivity) {
5332
- return {
5333
- errorCode: "network_error",
5334
- retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
5335
- };
5468
+ return dimensions;
5469
+ }
5470
+
5471
+ // ../common/src/telemetry/command-name.ts
5472
+ var TELEMETRY_NAME_ROOT = "Cli";
5473
+ var CLI_COMMAND_ROOT = "uip";
5474
+ var TELEMETRY_NAME_BARE_ACTION = "Invoke";
5475
+ function commandTelemetryName(parts) {
5476
+ const action = vetCommandTokens(parts).map(pascalizeToken).join("");
5477
+ return `${TELEMETRY_NAME_ROOT}.${action || TELEMETRY_NAME_BARE_ACTION}`;
5478
+ }
5479
+ function commandInvocationPath(parts) {
5480
+ return [CLI_COMMAND_ROOT, ...vetCommandTokens(parts)].join(" ");
5481
+ }
5482
+ function vetCommandTokens(parts) {
5483
+ const tokens = [];
5484
+ for (const part of parts) {
5485
+ const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== CLI_COMMAND_ROOT);
5486
+ if (pieces.every(isCommandToken)) {
5487
+ tokens.push(...pieces);
5488
+ continue;
5489
+ }
5490
+ tokens.push(UNKNOWN_TOKEN);
5336
5491
  }
5337
- return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
5492
+ return tokens;
5338
5493
  }
5339
- function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
5340
- if (extractedMessage) {
5341
- return `HTTP ${status}: ${extractedMessage}`;
5494
+ function pascalizeToken(token) {
5495
+ return token.split("-").filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
5496
+ }
5497
+ var COMMAND_TOKEN_PATTERN = /^[a-z][a-z0-9-]*$/;
5498
+ var MAX_COMMAND_TOKEN_LENGTH = 32;
5499
+ var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
5500
+ function isCommandToken(token) {
5501
+ return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token);
5502
+ }
5503
+ var UNKNOWN_TOKEN = "unknown";
5504
+
5505
+ // ../common/src/telemetry/invocation-request.ts
5506
+ var requestContextSlot = singleton("TelemetryInvocationRequestContext");
5507
+ function activeContext() {
5508
+ return telemetry.getActiveContext?.();
5509
+ }
5510
+ function runWithInvocationRequest(fn) {
5511
+ const context = telemetry.createRequestContext();
5512
+ context.startedAt = invocationStartedAt();
5513
+ requestContextSlot.set(context);
5514
+ return telemetry.runWithContext(context, fn);
5515
+ }
5516
+ function ensureInvocationRequestScope(fn) {
5517
+ if (activeContext() !== undefined) {
5518
+ return fn();
5342
5519
  }
5343
- return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
5520
+ const kept = requestContextSlot.get();
5521
+ return kept === undefined ? runWithInvocationRequest(fn) : telemetry.runWithContext(kept, fn);
5344
5522
  }
5345
- async function extractErrorDetails(error, options) {
5346
- const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
5347
- const response = err.response;
5348
- const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
5349
- const explicitStatus = err.status ?? response?.status;
5350
- const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
5351
- const status = explicitStatus ?? inferredStatus;
5352
- const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
5353
- let rawBody;
5354
- let extractedMessage;
5355
- let parsedBody;
5356
- const textFn = response?.text?.bind(response);
5357
- if (textFn) {
5358
- const [bodyError, body] = await catchError((async () => textFn())());
5359
- if (!bodyError && body) {
5360
- rawBody = body;
5361
- const [parseError, parsed] = catchError(() => JSON.parse(body));
5362
- if (!parseError && parsed && typeof parsed === "object") {
5363
- parsedBody = parsed;
5364
- if (parsedBody.errors && typeof parsedBody.errors === "object") {
5365
- for (const field of Object.values(parsedBody.errors)) {
5366
- if (Array.isArray(field) && field.length > 0) {
5367
- const first = field[0];
5368
- if (first && typeof first.message === "string") {
5369
- extractedMessage = first.message;
5370
- break;
5371
- }
5372
- }
5373
- }
5374
- }
5375
- if (!extractedMessage) {
5376
- extractedMessage = typeof parsedBody.message === "string" ? parsedBody.message : typeof parsedBody.errorMessage === "string" ? parsedBody.errorMessage : typeof parsedBody.title === "string" ? parsedBody.title : undefined;
5377
- }
5378
- if (!extractedMessage) {
5379
- extractedMessage = body;
5380
- }
5381
- if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
5382
- extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
5383
- }
5384
- } else {
5385
- extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
5386
- }
5387
- }
5523
+ function getInvocationRequestContext() {
5524
+ return activeContext() ?? requestContextSlot.get();
5525
+ }
5526
+ function emitInvocationRequest(name, success, properties) {
5527
+ const context = getInvocationRequestContext();
5528
+ telemetry.trackRequestResult(name, invocationElapsedMs(), success, properties, context);
5529
+ if (context !== undefined && requestContextSlot.get() === context) {
5530
+ requestContextSlot.clear();
5388
5531
  }
5389
- let message;
5390
- let result = "Failure";
5391
- const classificationStatus = status ?? findHttpStatusInGraph(error);
5392
- const classification = classifyError2(classificationStatus, error);
5393
- let retry = classification.retry;
5394
- if (status === 401) {
5395
- message = DEFAULT_401;
5396
- result = "AuthenticationError";
5397
- } else if (status === 403) {
5398
- message = options?.forbiddenMessage ?? DEFAULT_403;
5399
- result = "AuthenticationError";
5400
- } else if (status === 405) {
5401
- message = DEFAULT_405;
5402
- } else if (status === 413) {
5403
- message = DEFAULT_413;
5404
- } else if (status === 400 || status === 422) {
5405
- message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
5406
- result = "ValidationError";
5407
- } else if (status === 429) {
5408
- message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
5409
- } else if (extractedMessage) {
5410
- if (isSuccessfulResponse && rawMessage !== "Unknown error") {
5411
- message = rawMessage;
5412
- } else {
5413
- message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
5414
- }
5415
- } else if (status) {
5416
- if (inferredStatus !== undefined) {
5417
- message = rawMessage;
5418
- } else if (rawMessage === "Unknown error" && response) {
5419
- const statusText = response.statusText;
5420
- message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
5421
- } else {
5422
- message = `HTTP ${status}: ${rawMessage}`;
5423
- }
5424
- } else {
5425
- message = rawMessage;
5532
+ }
5533
+
5534
+ // ../common/src/trackedAction.ts
5535
+ var pollSignalSlot = singleton("PollSignal");
5536
+ var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
5537
+ var processContext = {
5538
+ exit: (code) => {
5539
+ recordCommandExit(code);
5540
+ },
5541
+ get pollSignal() {
5542
+ return pollSignalSlot.get();
5426
5543
  }
5427
- if (status === undefined) {
5428
- const connectivity = describeConnectivityError(error);
5429
- if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
5430
- message = `${message}: ${connectivity.message}`;
5431
- }
5544
+ };
5545
+ var TELEMETRY_ARG_VALUE_WITHHELD = "<provided>";
5546
+ var TELEMETRY_ARG_VALUE_DEFAULTED = "<default>";
5547
+ function recordableArgValue(value, choices) {
5548
+ if (typeof value === "boolean" || typeof value === "number") {
5549
+ return value;
5432
5550
  }
5433
- const permission = status === undefined ? describePermissionError(error) : undefined;
5434
- if (permission) {
5435
- if (permission.message !== message && !message.includes(permission.message)) {
5436
- message = `${message}: ${permission.message}`;
5551
+ if (choices && choices.length > 0) {
5552
+ if (typeof value === "string" && choices.includes(value)) {
5553
+ return value;
5437
5554
  }
5438
- if (!message.includes(permission.instructions)) {
5439
- const punctuated = message.endsWith(".") ? message : `${message}.`;
5440
- message = `${punctuated} ${permission.instructions}`;
5555
+ if (Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string" && choices.includes(entry))) {
5556
+ return value.join(",");
5441
5557
  }
5442
5558
  }
5443
- let details = rawMessage;
5444
- if (rawBody) {
5445
- if (parsedBody) {
5446
- const extra = {};
5447
- if (parsedBody.errorCode)
5448
- extra.errorCode = parsedBody.errorCode;
5449
- if (parsedBody.detail)
5450
- extra.detail = parsedBody.detail;
5451
- if (parsedBody.details)
5452
- extra.details = parsedBody.details;
5453
- if (parsedBody.errors != null)
5454
- extra.errors = parsedBody.errors;
5455
- if (parsedBody.data && typeof parsedBody.data === "object" && Object.keys(parsedBody.data).length > 0) {
5456
- extra.data = parsedBody.data;
5457
- }
5458
- details = Object.keys(extra).length > 0 ? JSON.stringify(extra) : rawBody;
5459
- } else {
5460
- details = rawBody;
5559
+ return TELEMETRY_ARG_VALUE_WITHHELD;
5560
+ }
5561
+ function extractCommandParams(cmd) {
5562
+ const params = {};
5563
+ forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
5564
+ if (name === undefined)
5565
+ return;
5566
+ const recordable = recordableArgValue(value, choices);
5567
+ params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
5568
+ });
5569
+ return params;
5570
+ }
5571
+ function isDefaultedOption(cmd, name) {
5572
+ const source = cmd.getOptionValueSource?.(name);
5573
+ return source === "default" || source === "implied";
5574
+ }
5575
+ function isDefaultedPositional(cmd, index) {
5576
+ return index >= (cmd.args?.length ?? 0);
5577
+ }
5578
+ function forEachSuppliedArgument(cmd, visit) {
5579
+ const registered = cmd.registeredArguments ?? [];
5580
+ const processed = cmd.processedArgs ?? [];
5581
+ const bound = boundPositionalCount(cmd);
5582
+ for (let i = 0;i < bound; i++) {
5583
+ const name = registered[i].name();
5584
+ if (name && processed[i] !== undefined) {
5585
+ visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
5461
5586
  }
5462
- } else if (typeof err.message === "string") {
5463
- details = err.message;
5464
- } else {
5465
- details = describeThrownValue(error);
5466
- }
5467
- const context = {};
5468
- if (classificationStatus) {
5469
- context.httpStatus = classificationStatus;
5470
5587
  }
5471
- if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
5472
- context.errorCode = parsedBody.errorCode;
5473
- } else if (parsedBody?.code && typeof parsedBody.code === "string") {
5474
- context.errorCode = parsedBody.code;
5588
+ const choicesByAttribute = new Map;
5589
+ for (const option of cmd.options) {
5590
+ choicesByAttribute.set(option.attributeName(), option.argChoices);
5475
5591
  }
5476
- if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
5477
- context.requestId = parsedBody.requestId;
5592
+ for (const [key, value] of Object.entries(cmd.opts())) {
5593
+ if (key && value !== undefined) {
5594
+ visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
5595
+ }
5478
5596
  }
5479
- if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
5480
- context.traceId = parsedBody.traceId;
5597
+ forEachPassThroughToken(cmd, bound, (name, value) => {
5598
+ visit(name, value, name === undefined ? undefined : choicesByAttribute.get(name), false);
5599
+ });
5600
+ }
5601
+ function boundPositionalCount(cmd) {
5602
+ const registered = cmd.registeredArguments ?? [];
5603
+ if (registered.some((argument) => argument.variadic)) {
5604
+ return registered.length;
5481
5605
  }
5482
- if (permission?.path !== undefined) {
5483
- context.path = permission.path;
5606
+ if ((cmd.args ?? []).length <= registered.length) {
5607
+ return registered.length;
5484
5608
  }
5485
- if (status === 429) {
5486
- const resp = response;
5487
- const headersObj = resp?.headers;
5488
- let retryAfterValue;
5489
- if (headersObj && typeof headersObj === "object" && typeof headersObj.get === "function") {
5490
- retryAfterValue = headersObj.get("retry-after") ?? undefined;
5491
- }
5492
- if (!retryAfterValue && headersObj && typeof headersObj === "object") {
5493
- const headers = headersObj;
5494
- retryAfterValue = headers["retry-after"] ?? headers["Retry-After"];
5609
+ const firstFlag = tokenizeTail(cmd, (cmd.args ?? []).slice(1)).tokens.find((token) => token.kind !== "operand")?.index ?? -1;
5610
+ return firstFlag === -1 ? registered.length : Math.min(registered.length, firstFlag + 1);
5611
+ }
5612
+ function forEachPassThroughToken(cmd, bound, visit) {
5613
+ const registered = cmd.registeredArguments ?? [];
5614
+ const fillsPositionals = !registered.some((argument) => argument.variadic);
5615
+ const { tokens, firstUnknown } = tokenizeTail(cmd, (cmd.args ?? []).slice(bound));
5616
+ const repeated = new Map;
5617
+ let nextPositional = bound;
5618
+ for (const token of tokens) {
5619
+ const pastUnknown = firstUnknown !== -1 && token.index > firstUnknown;
5620
+ if (token.kind === "sentinel")
5621
+ continue;
5622
+ if (token.kind === "operand") {
5623
+ const claimable = !pastUnknown && fillsPositionals && nextPositional < registered.length;
5624
+ const name = claimable ? registered[nextPositional++].name() : undefined;
5625
+ visit(name || undefined, token.text);
5626
+ continue;
5495
5627
  }
5496
- if (retryAfterValue) {
5497
- const seconds = Number(retryAfterValue);
5498
- if (!Number.isNaN(seconds)) {
5499
- context.retryAfter = seconds;
5500
- retry = retryHintForRetryAfter(seconds);
5628
+ if (token.kind === "unknown") {
5629
+ const bare = token.flag.replace(/^-+/, "");
5630
+ const key = bare.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
5631
+ const keyable = token.flag.startsWith("--") || token.flag.length === 2;
5632
+ if (!pastUnknown && keyable && /^[a-z][a-z0-9-]*$/i.test(bare) && key) {
5633
+ visit(key, token.inlineValue ?? true);
5634
+ } else {
5635
+ visit(undefined, token.text);
5636
+ if (token.inlineValue !== undefined) {
5637
+ visit(undefined, token.inlineValue);
5638
+ } else if (!token.flag.startsWith("--") && token.flag.length > 2) {
5639
+ visit(undefined, token.flag.slice(2));
5640
+ }
5501
5641
  }
5642
+ continue;
5643
+ }
5644
+ if (pastUnknown) {
5645
+ visit(undefined, token.text);
5646
+ if (token.value !== undefined)
5647
+ visit(undefined, token.value);
5648
+ continue;
5649
+ }
5650
+ const option = token.option;
5651
+ const name = option.attributeName();
5652
+ const value = option.negate ? false : option.required || option.optional ? token.value ?? true : true;
5653
+ const previous = repeated.get(name);
5654
+ if (previous) {
5655
+ previous.push(value);
5656
+ visit(name, previous);
5657
+ } else {
5658
+ repeated.set(name, [value]);
5659
+ visit(name, value);
5502
5660
  }
5503
5661
  }
5504
- const hasContext = Object.keys(context).length > 0;
5505
- let parsedErrors;
5506
- if (parsedBody?.errors && typeof parsedBody.errors === "object") {
5507
- const errors = {};
5508
- for (const [field, raw] of Object.entries(parsedBody.errors)) {
5509
- if (Array.isArray(raw)) {
5510
- const messages = raw.map((entry) => {
5511
- if (typeof entry === "string")
5512
- return entry;
5513
- if (entry && typeof entry === "object" && typeof entry.message === "string") {
5514
- return entry.message;
5515
- }
5516
- return String(entry);
5517
- }).filter(Boolean);
5518
- if (messages.length > 0)
5519
- errors[field] = messages;
5520
- } else if (typeof raw === "string") {
5521
- errors[field] = [raw];
5522
- }
5662
+ }
5663
+ function withheldArgumentValues(cmd) {
5664
+ const values = [];
5665
+ forEachSuppliedArgument(cmd, (_name, value, choices, defaulted) => {
5666
+ if (defaulted) {
5667
+ return;
5523
5668
  }
5524
- if (Object.keys(errors).length > 0)
5525
- parsedErrors = errors;
5669
+ if (recordableArgValue(value, choices) === TELEMETRY_ARG_VALUE_WITHHELD) {
5670
+ values.push(value);
5671
+ }
5672
+ });
5673
+ return values;
5674
+ }
5675
+ function deriveCommandParts(cmd) {
5676
+ const parts = [];
5677
+ let current = cmd;
5678
+ while (current) {
5679
+ const name = current.name();
5680
+ if (name) {
5681
+ parts.unshift(name);
5682
+ }
5683
+ current = current.parent;
5526
5684
  }
5527
- return {
5528
- result,
5529
- errorCode: classification.errorCode,
5530
- message,
5531
- retry,
5532
- details,
5533
- ...hasContext ? { context } : {},
5534
- ...parsedErrors ? { parsedErrors } : {}
5535
- };
5685
+ if (parts.length > 1) {
5686
+ parts.shift();
5687
+ }
5688
+ return parts;
5536
5689
  }
5537
- async function extractErrorMessage(error, options) {
5538
- const { message } = await extractErrorDetails(error, options);
5539
- return message;
5690
+ function isErrorContext(value) {
5691
+ return value !== null && typeof value === "object";
5692
+ }
5693
+ function commandHelpHint(commandPath) {
5694
+ return `An unexpected error occurred. Run '${commandPath} --help' to verify command syntax, or run with --log-level debug for details.`;
5695
+ }
5696
+ function isPromptCancellation(error) {
5697
+ return error instanceof Error && error.name === "ExitPromptError";
5698
+ }
5699
+ function implicitLimitViolation(cmd) {
5700
+ if (getOutputFilter() === undefined) {
5701
+ return;
5702
+ }
5703
+ const hasLimit = cmd.options.some((o) => o.attributeName() === "limit");
5704
+ if (!hasLimit || cmd.getOptionValueSource("limit") !== "default") {
5705
+ return;
5706
+ }
5707
+ return new FilterImplicitLimitError(String(cmd.opts().limit));
5708
+ }
5709
+ function exitCodeFromProcess(fallback) {
5710
+ return typeof process.exitCode === "number" ? process.exitCode : fallback;
5540
5711
  }
5712
+ Command.prototype.trackedAction = function(context, fn, properties) {
5713
+ const command = this;
5714
+ return this.action(async (...args) => {
5715
+ await loadOutputCodecsAsync({
5716
+ yaml: getOutputFormat() === "yaml",
5717
+ filter: getOutputFilter() !== undefined
5718
+ });
5719
+ const commandParts = deriveCommandParts(command);
5720
+ const telemetryName = commandTelemetryName(commandParts);
5721
+ const commandPath = commandInvocationPath(commandParts);
5722
+ const props = typeof properties === "function" ? properties(...args) : properties;
5723
+ const projectResolver = getProjectTelemetryResolver(command);
5724
+ const projectSession = projectResolver && !isProjectTelemetryDisabled() ? new ProjectTelemetrySession(projectResolver, command) : undefined;
5725
+ markCommandStart();
5726
+ const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
5727
+ try {
5728
+ const startTime = performance.now();
5729
+ let errorMessage;
5730
+ let fallbackExitCode = EXIT_CODES.Success;
5731
+ clearRecordedCommandFailureTelemetry();
5732
+ const [error] = await catchError(ensureInvocationRequestScope(() => {
5733
+ const violation = implicitLimitViolation(command);
5734
+ if (violation) {
5735
+ return Promise.reject(violation);
5736
+ }
5737
+ if (projectSession) {
5738
+ return projectSession.resolve({ command, args, phase: "before" }).then(() => {
5739
+ attachProjectTelemetryCapture(command, projectSession);
5740
+ return fn(...args);
5741
+ });
5742
+ }
5743
+ return fn(...args);
5744
+ }));
5745
+ if (error) {
5746
+ errorMessage = error instanceof Error ? error.message : String(error);
5747
+ logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
5748
+ const typed = error;
5749
+ const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
5750
+ const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
5751
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
5752
+ const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
5753
+ const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
5754
+ const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
5755
+ const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
5756
+ const typedRetry = typed.retry ?? typed.Retry;
5757
+ const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
5758
+ const typedContext = typed.context ?? typed.Context;
5759
+ const customContext = isErrorContext(typedContext) ? typedContext : undefined;
5760
+ fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
5761
+ const errorCode = customErrorCode ?? classified?.errorCode;
5762
+ const retry = customRetry ?? classified?.retry;
5763
+ const errorContext = customContext ?? classified?.context;
5764
+ OutputFormatter.error({
5765
+ Result: finalResult,
5766
+ ...errorCode ? { ErrorCode: errorCode } : {},
5767
+ Message: errorMessage,
5768
+ Instructions: customInstructions ?? commandHelpHint(commandPath),
5769
+ ...retry ? { Retry: retry } : {},
5770
+ ...errorContext ? { Context: errorContext } : {}
5771
+ });
5772
+ context.exit(fallbackExitCode);
5773
+ }
5774
+ const durationMs = performance.now() - startTime;
5775
+ recordCommandDuration(durationMs);
5776
+ const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
5777
+ const recordedFailure = takeRecordedCommandFailureTelemetry();
5778
+ const success = !error && exitCode === 0;
5779
+ if (projectSession) {
5780
+ await projectSession.resolve({
5781
+ command,
5782
+ args,
5783
+ phase: "after",
5784
+ success
5785
+ });
5786
+ }
5787
+ const terminalTelemetry = buildCommandTerminalTelemetryProperties({
5788
+ error,
5789
+ exitCode,
5790
+ recordedFailure,
5791
+ pollSignal: context.pollSignal
5792
+ });
5793
+ if (terminalTelemetry[CommandDimensions.ErrorClass] === "internal" && error) {
5794
+ telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { [CommandDimensions.CommandName]: commandPath }, getInvocationRequestContext());
5795
+ }
5796
+ const commandParams = extractCommandParams(command);
5797
+ if (props) {
5798
+ for (const key of Object.keys(props)) {
5799
+ delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
5800
+ }
5801
+ }
5802
+ const baseProperties = redactProperties({
5803
+ ...commandParams,
5804
+ ...projectSession?.properties(),
5805
+ ...props,
5806
+ ...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
5807
+ ...buildAgentSessionTelemetry(process.env),
5808
+ [CommandDimensions.CommandName]: commandPath,
5809
+ [CommandDimensions.IsCommand]: "true",
5810
+ ...terminalTelemetry,
5811
+ ...errorMessage ? { [CommandDimensions.ErrorMessage]: errorMessage } : {}
5812
+ });
5813
+ emitInvocationRequest(telemetryName, success, baseProperties);
5814
+ } finally {
5815
+ if (projectSession)
5816
+ attachProjectTelemetryCapture(command, undefined);
5817
+ releaseSuppliedArgumentValues(supplied);
5818
+ }
5819
+ });
5820
+ };
5541
5821
  // ../common/src/body-validators.ts
5542
5822
  function runChecks(checks) {
5543
5823
  for (const check of checks) {
@@ -5788,13 +6068,13 @@ async function readStdin() {
5788
6068
  if (process.stdin.isTTY) {
5789
6069
  return null;
5790
6070
  }
5791
- return new Promise((resolve2, reject) => {
6071
+ return new Promise((resolve, reject) => {
5792
6072
  let data = "";
5793
6073
  process.stdin.setEncoding("utf8");
5794
6074
  process.stdin.on("data", (chunk) => {
5795
6075
  data += chunk;
5796
6076
  });
5797
- process.stdin.on("end", () => resolve2(data.trim() || null));
6077
+ process.stdin.on("end", () => resolve(data.trim() || null));
5798
6078
  process.stdin.on("error", reject);
5799
6079
  });
5800
6080
  }
@@ -6135,35 +6415,35 @@ var FILTER_OPERATORS = new Set([
6135
6415
  var VALUELIST_OPERATORS = new Set(["in", "not in"]);
6136
6416
  var FILTER_FIELD_PATH_PATTERN = /^[a-zA-Z][a-zA-Z0-9_.]*$/;
6137
6417
  var FILTER_OPERATORS_LIST = [...FILTER_OPERATORS].map((o) => `'${o}'`).join(", ");
6138
- function validateFilterLeaf(leaf, path2) {
6418
+ function validateFilterLeaf(leaf, path) {
6139
6419
  if (typeof leaf !== "object" || leaf === null) {
6140
6420
  return {
6141
- message: `${path2} must be a filter object`,
6421
+ message: `${path} must be a filter object`,
6142
6422
  instructions: "Each queryFilters entry must be an object with fieldName, operator, and value (or valueList for 'in' / 'not in')."
6143
6423
  };
6144
6424
  }
6145
6425
  const rec = leaf;
6146
6426
  if (typeof rec.fieldName !== "string" || rec.fieldName.trim() === "") {
6147
6427
  return {
6148
- message: `${path2}.fieldName must be a non-empty string`,
6428
+ message: `${path}.fieldName must be a non-empty string`,
6149
6429
  instructions: 'Set fieldName to the column you want to filter, for example {"fieldName":"Status","operator":"=","value":"Active"}.'
6150
6430
  };
6151
6431
  }
6152
6432
  if (!FILTER_FIELD_PATH_PATTERN.test(rec.fieldName)) {
6153
6433
  return {
6154
- message: `${path2}.fieldName '${rec.fieldName}' is invalid`,
6434
+ message: `${path}.fieldName '${rec.fieldName}' is invalid`,
6155
6435
  instructions: "Filter field names must start with a letter and contain only letters, digits, underscores, and dots."
6156
6436
  };
6157
6437
  }
6158
6438
  if (typeof rec.operator !== "string") {
6159
6439
  return {
6160
- message: `${path2}.operator must be a string`,
6440
+ message: `${path}.operator must be a string`,
6161
6441
  instructions: `Supported operators: ${FILTER_OPERATORS_LIST}.`
6162
6442
  };
6163
6443
  }
6164
6444
  if (!FILTER_OPERATORS.has(rec.operator)) {
6165
6445
  return {
6166
- message: `${path2} uses unsupported operator '${rec.operator}'`,
6446
+ message: `${path} uses unsupported operator '${rec.operator}'`,
6167
6447
  instructions: `The server rejects operators outside the supported set. Supported: ${FILTER_OPERATORS_LIST}. Compose BETWEEN as '>=' + '<=' in one queryFilters group; use 'contains' / 'startswith' / 'endswith' in place of regex.`
6168
6448
  };
6169
6449
  }
@@ -6171,36 +6451,36 @@ function validateFilterLeaf(leaf, path2) {
6171
6451
  if (needsValueList) {
6172
6452
  if (!Array.isArray(rec.valueList)) {
6173
6453
  return {
6174
- message: `${path2} operator '${rec.operator}' requires 'valueList' array`,
6454
+ message: `${path} operator '${rec.operator}' requires 'valueList' array`,
6175
6455
  instructions: `'in' and 'not in' take a JSON array of values under 'valueList', for example {"fieldName":"Status","operator":"in","valueList":["A","B"]}.`
6176
6456
  };
6177
6457
  }
6178
6458
  if (rec.valueList.length === 0) {
6179
6459
  return {
6180
- message: `${path2} operator '${rec.operator}' requires a non-empty 'valueList'`,
6460
+ message: `${path} operator '${rec.operator}' requires a non-empty 'valueList'`,
6181
6461
  instructions: "Add at least one value to 'valueList', or remove this filter."
6182
6462
  };
6183
6463
  }
6184
6464
  } else {
6185
6465
  if (!("value" in rec)) {
6186
6466
  return {
6187
- message: `${path2} operator '${rec.operator}' requires 'value'`,
6467
+ message: `${path} operator '${rec.operator}' requires 'value'`,
6188
6468
  instructions: "Set 'value' to the JSON-string form of the compared value. Use null for is-empty ('=' with null) / is-not-empty ('!=' with null)."
6189
6469
  };
6190
6470
  }
6191
6471
  if (rec.value === null && rec.operator !== "=" && rec.operator !== "!=") {
6192
6472
  return {
6193
- message: `${path2} operator '${rec.operator}' cannot use a null value`,
6473
+ message: `${path} operator '${rec.operator}' cannot use a null value`,
6194
6474
  instructions: "A null filter value is supported only with '=' (is empty) or '!=' (is not empty)."
6195
6475
  };
6196
6476
  }
6197
6477
  }
6198
6478
  return null;
6199
6479
  }
6200
- function validateFilterGroup(group, path2) {
6480
+ function validateFilterGroup(group, path) {
6201
6481
  if (typeof group !== "object" || group === null || Array.isArray(group)) {
6202
6482
  return {
6203
- message: `${path2} must be an object`,
6483
+ message: `${path} must be an object`,
6204
6484
  instructions: "A filter group is {logicalOperator, queryFilters, filterGroups?}."
6205
6485
  };
6206
6486
  }
@@ -6211,7 +6491,7 @@ function validateFilterGroup(group, path2) {
6211
6491
  const okNumber = op === 0 || op === 1;
6212
6492
  if (!okString && !okNumber) {
6213
6493
  return {
6214
- message: `${path2}.logicalOperator must be 'AND' / 'OR' / 0 / 1`,
6494
+ message: `${path}.logicalOperator must be 'AND' / 'OR' / 0 / 1`,
6215
6495
  instructions: "Use the integer form (0 for AND, 1 for OR) or the string form ('AND' / 'OR', case-insensitive)."
6216
6496
  };
6217
6497
  }
@@ -6219,12 +6499,12 @@ function validateFilterGroup(group, path2) {
6219
6499
  if (rec.queryFilters !== undefined) {
6220
6500
  if (!Array.isArray(rec.queryFilters)) {
6221
6501
  return {
6222
- message: `${path2}.queryFilters must be an array`,
6502
+ message: `${path}.queryFilters must be an array`,
6223
6503
  instructions: "queryFilters is an array of {fieldName, operator, value|valueList} clauses."
6224
6504
  };
6225
6505
  }
6226
6506
  for (let i = 0;i < rec.queryFilters.length; i++) {
6227
- const err = validateFilterLeaf(rec.queryFilters[i], `${path2}.queryFilters[${i}]`);
6507
+ const err = validateFilterLeaf(rec.queryFilters[i], `${path}.queryFilters[${i}]`);
6228
6508
  if (err)
6229
6509
  return err;
6230
6510
  }
@@ -6232,12 +6512,12 @@ function validateFilterGroup(group, path2) {
6232
6512
  if (rec.filterGroups !== undefined) {
6233
6513
  if (!Array.isArray(rec.filterGroups)) {
6234
6514
  return {
6235
- message: `${path2}.filterGroups must be an array`,
6515
+ message: `${path}.filterGroups must be an array`,
6236
6516
  instructions: "filterGroups is an array of nested groups, each with the same shape as the parent."
6237
6517
  };
6238
6518
  }
6239
6519
  for (let i = 0;i < rec.filterGroups.length; i++) {
6240
- const err = validateFilterGroup(rec.filterGroups[i], `${path2}.filterGroups[${i}]`);
6520
+ const err = validateFilterGroup(rec.filterGroups[i], `${path}.filterGroups[${i}]`);
6241
6521
  if (err)
6242
6522
  return err;
6243
6523
  }
@@ -6405,6 +6685,6 @@ function validateFieldsPayload(fields, entityName, isNewEntity = false) {
6405
6685
  ]);
6406
6686
  }
6407
6687
 
6408
- export { getFileSystem, extractErrorMessage, runChecks, logger, RESULTS, OutputFormatter, Command, Option, processContext, requireConfirmation, warnDeprecatedOptionAlias, createHiddenDeprecatedTenantOption, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, quoteForShell, unsupportedSolutionProjectType, readStdin, validateSchemaMetadata, findInvalidFieldMetadata, validateChoiceValueName, validateChoiceValueDisplayName, validateQueryFilter, validateQueryAggregates, findFilePayloadKeys, findIsUniqueInUpdateFields, validateFieldsPayload };
6688
+ export { getFileSystem, extractErrorMessage, runChecks, RESULTS, Command, Option, logger, OutputFormatter, processContext, requireConfirmation, warnDeprecatedOptionAlias, createHiddenDeprecatedTenantOption, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, quoteForShell, unsupportedSolutionProjectType, readStdin, validateSchemaMetadata, findInvalidFieldMetadata, validateChoiceValueName, validateChoiceValueDisplayName, validateQueryFilter, validateQueryAggregates, findFilePayloadKeys, findIsUniqueInUpdateFields, validateFieldsPayload };
6409
6689
 
6410
- //# debugId=66961B0085E5331964756E2164756E21
6690
+ //# debugId=D431DD2EA80A840864756E2164756E21