@uipath/solution-tool 1.201.0-preview.133 → 1.202.0-preview.134

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 (47) hide show
  1. package/dist/deploy.d.ts +6 -1
  2. package/dist/deploy.js +15 -16
  3. package/dist/{index-2fj08e7n.js → index-gpd94m28.js} +27 -27
  4. package/dist/{index-w03qc9m8.js → index-sby22td6.js} +4 -4
  5. package/dist/index.js +16 -19
  6. package/dist/init.js +10 -13
  7. package/dist/{js-yaml-4ypbq2tt.js → js-yaml-b2jq67kn.js} +16 -16
  8. package/dist/{list-skbehtq2.js → list-3mrc9s3f.js} +7 -11
  9. package/dist/models/pack-command-types.d.ts +8 -0
  10. package/dist/pack.js +9 -12
  11. package/dist/{packager-tool-krd5v2r5.js → packager-tool-0qva0ebq.js} +129 -53
  12. package/dist/{packager-tool-0v6na3yp.js → packager-tool-1de529jm.js} +9 -7
  13. package/dist/{packager-tool-9vehmnke.js → packager-tool-3hbsdwjm.js} +6 -661
  14. package/dist/{packager-tool-fzwxq48d.js → packager-tool-3y92zbg2.js} +3 -3
  15. package/dist/{packager-tool-f7kj5fpa.js → packager-tool-5pfxgc8z.js} +19 -11
  16. package/dist/{packager-tool-9w3k4e77.js → packager-tool-b16qemg2.js} +494 -198
  17. package/dist/{packager-tool-zbp5p149.js → packager-tool-bahvrjbv.js} +592 -264
  18. package/dist/{packager-tool-129wn232.js → packager-tool-dfrk01gn.js} +198 -2
  19. package/dist/{packager-tool-67ssxgph.js → packager-tool-fh8pb2th.js} +3 -5
  20. package/dist/{packager-tool-c29pg93e.js → packager-tool-hc6ybtdw.js} +5 -5
  21. package/dist/{packager-tool-bcpknnr8.js → packager-tool-hgx66d1p.js} +1656 -558
  22. package/dist/{packager-tool-2yz7m5ny.js → packager-tool-nq2nq71y.js} +21282 -20197
  23. package/dist/{packager-tool-wjhn59ft.js → packager-tool-t89r1edr.js} +596 -180
  24. package/dist/{packager-tool-vpr77gre.js → packager-tool-x3ehbhsn.js} +3 -2
  25. package/dist/{packager-tool-yktm4v4r.js → packager-tool-xntjj1bt.js} +1 -1
  26. package/dist/packager-tool.d.ts +4 -3
  27. package/dist/packager-tool.js +4 -4
  28. package/dist/publish.js +8 -11
  29. package/dist/resource.js +7 -10
  30. package/dist/services/activation.d.ts +9 -1
  31. package/dist/services/deploy-run-service.d.ts +25 -1
  32. package/dist/services/deploy-uninstall-service.d.ts +20 -1
  33. package/dist/services/deploy-upgrade-service.d.ts +94 -0
  34. package/dist/services/deployment-feed-locator.d.ts +36 -0
  35. package/dist/services/deployment-search.d.ts +88 -7
  36. package/dist/services/pack-command-service.d.ts +15 -0
  37. package/dist/services/package-metadata-rewrite.d.ts +9 -5
  38. package/dist/services/publish-service.d.ts +11 -9
  39. package/dist/services/solution-path.d.ts +34 -0
  40. package/dist/templates/AGENTS.md +183 -16
  41. package/dist/tool.js +18 -21
  42. package/package.json +2 -2
  43. package/dist/browser-strategy-yccf8mtd.js +0 -99
  44. package/dist/node-strategy-12qfy0nv.js +0 -348
  45. package/dist/packager-tool-5arsyj36.js +0 -11
  46. package/dist/packager-tool-7eva0peq.js +0 -265
  47. package/dist/packager-tool-9qecd4wb.js +0 -14
@@ -1,23 +1,11 @@
1
- import {
2
- isBrowser
3
- } from "./packager-tool-9qecd4wb.js";
4
- import {
5
- catchError,
6
- getFileSystem
7
- } from "./packager-tool-7eva0peq.js";
8
- import {
9
- AUTH_FILENAME,
10
- DEFAULT_BASE_URL,
11
- UIPATH_HOME_DIR
12
- } from "./packager-tool-5arsyj36.js";
13
1
  import {
14
2
  __commonJS,
15
3
  __require,
16
4
  __toESM
17
- } from "./packager-tool-0v6na3yp.js";
5
+ } from "./packager-tool-1de529jm.js";
18
6
 
19
7
  // ../../node_modules/commander/lib/error.js
20
- var require_error = __commonJS((exports) => {
8
+ var require_error = __commonJS(function(exports) {
21
9
  class CommanderError extends Error {
22
10
  constructor(exitCode, code, message) {
23
11
  super(message);
@@ -41,7 +29,7 @@ var require_error = __commonJS((exports) => {
41
29
  });
42
30
 
43
31
  // ../../node_modules/commander/lib/argument.js
44
- var require_argument = __commonJS((exports) => {
32
+ var require_argument = __commonJS(function(exports) {
45
33
  var { InvalidArgumentError } = require_error();
46
34
 
47
35
  class Argument {
@@ -121,7 +109,7 @@ var require_argument = __commonJS((exports) => {
121
109
  });
122
110
 
123
111
  // ../../node_modules/commander/lib/help.js
124
- var require_help = __commonJS((exports) => {
112
+ var require_help = __commonJS(function(exports) {
125
113
  var { humanReadableArgName } = require_argument();
126
114
 
127
115
  class Help {
@@ -478,7 +466,7 @@ ${itemIndentStr}`);
478
466
  });
479
467
 
480
468
  // ../../node_modules/commander/lib/option.js
481
- var require_option = __commonJS((exports) => {
469
+ var require_option = __commonJS(function(exports) {
482
470
  var { InvalidArgumentError } = require_error();
483
471
 
484
472
  class Option {
@@ -662,7 +650,7 @@ var require_option = __commonJS((exports) => {
662
650
  });
663
651
 
664
652
  // ../../node_modules/commander/lib/suggestSimilar.js
665
- var require_suggestSimilar = __commonJS((exports) => {
653
+ var require_suggestSimilar = __commonJS(function(exports) {
666
654
  var maxDistance = 3;
667
655
  function editDistance(a, b) {
668
656
  if (Math.abs(a.length - b.length) > maxDistance)
@@ -735,11 +723,11 @@ var require_suggestSimilar = __commonJS((exports) => {
735
723
  });
736
724
 
737
725
  // ../../node_modules/commander/lib/command.js
738
- var require_command = __commonJS((exports) => {
726
+ var require_command = __commonJS(function(exports) {
739
727
  var EventEmitter = __require("node:events").EventEmitter;
740
728
  var childProcess = __require("node:child_process");
741
- var path = __require("node:path");
742
- var fs = __require("node:fs");
729
+ var path2 = __require("node:path");
730
+ var fs2 = __require("node:fs");
743
731
  var process2 = __require("node:process");
744
732
  var { Argument, humanReadableArgName } = require_argument();
745
733
  var { CommanderError } = require_error();
@@ -1274,7 +1262,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1274
1262
  this.processedArgs = [];
1275
1263
  }
1276
1264
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
1277
- if (fs.existsSync(executableFile))
1265
+ if (fs2.existsSync(executableFile))
1278
1266
  return;
1279
1267
  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";
1280
1268
  const executableMissing = `'${executableFile}' does not exist
@@ -1288,12 +1276,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
1288
1276
  let launchWithNode = false;
1289
1277
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1290
1278
  function findFile(baseDir, baseName) {
1291
- const localBin = path.resolve(baseDir, baseName);
1292
- if (fs.existsSync(localBin))
1279
+ const localBin = path2.resolve(baseDir, baseName);
1280
+ if (fs2.existsSync(localBin))
1293
1281
  return localBin;
1294
- if (sourceExt.includes(path.extname(baseName)))
1282
+ if (sourceExt.includes(path2.extname(baseName)))
1295
1283
  return;
1296
- const foundExt = sourceExt.find((ext) => fs.existsSync(`${localBin}${ext}`));
1284
+ const foundExt = sourceExt.find((ext) => fs2.existsSync(`${localBin}${ext}`));
1297
1285
  if (foundExt)
1298
1286
  return `${localBin}${foundExt}`;
1299
1287
  return;
@@ -1305,23 +1293,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
1305
1293
  if (this._scriptPath) {
1306
1294
  let resolvedScriptPath;
1307
1295
  try {
1308
- resolvedScriptPath = fs.realpathSync(this._scriptPath);
1296
+ resolvedScriptPath = fs2.realpathSync(this._scriptPath);
1309
1297
  } catch {
1310
1298
  resolvedScriptPath = this._scriptPath;
1311
1299
  }
1312
- executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
1300
+ executableDir = path2.resolve(path2.dirname(resolvedScriptPath), executableDir);
1313
1301
  }
1314
1302
  if (executableDir) {
1315
1303
  let localFile = findFile(executableDir, executableFile);
1316
1304
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1317
- const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
1305
+ const legacyName = path2.basename(this._scriptPath, path2.extname(this._scriptPath));
1318
1306
  if (legacyName !== this._name) {
1319
1307
  localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1320
1308
  }
1321
1309
  }
1322
1310
  executableFile = localFile || executableFile;
1323
1311
  }
1324
- launchWithNode = sourceExt.includes(path.extname(executableFile));
1312
+ launchWithNode = sourceExt.includes(path2.extname(executableFile));
1325
1313
  let proc;
1326
1314
  if (process2.platform !== "win32") {
1327
1315
  if (launchWithNode) {
@@ -1910,13 +1898,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
1910
1898
  cmd.helpGroup(this._defaultCommandGroup);
1911
1899
  }
1912
1900
  nameFromFilename(filename) {
1913
- this._name = path.basename(filename, path.extname(filename));
1901
+ this._name = path2.basename(filename, path2.extname(filename));
1914
1902
  return this;
1915
1903
  }
1916
- executableDir(path2) {
1917
- if (path2 === undefined)
1904
+ executableDir(path3) {
1905
+ if (path3 === undefined)
1918
1906
  return this._executableDir;
1919
- this._executableDir = path2;
1907
+ this._executableDir = path3;
1920
1908
  return this;
1921
1909
  }
1922
1910
  helpInformation(contextOptions) {
@@ -2090,7 +2078,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2090
2078
  });
2091
2079
 
2092
2080
  // ../../node_modules/commander/index.js
2093
- var require_commander = __commonJS((exports) => {
2081
+ var require_commander = __commonJS(function(exports) {
2094
2082
  var { Argument } = require_argument();
2095
2083
  var { Command } = require_command();
2096
2084
  var { CommanderError, InvalidArgumentError } = require_error();
@@ -2109,49 +2097,401 @@ var require_commander = __commonJS((exports) => {
2109
2097
  exports.InvalidOptionArgumentError = InvalidArgumentError;
2110
2098
  });
2111
2099
 
2112
- // ../common/src/catch-error.ts
2113
- function isPromiseLike(value) {
2114
- return value !== null && typeof value === "object" && typeof value.then === "function";
2100
+ // ../filesystem/src/node.ts
2101
+ import { randomUUID } from "node:crypto";
2102
+ import { existsSync } from "node:fs";
2103
+ import * as fs from "node:fs/promises";
2104
+ import * as os from "node:os";
2105
+ import * as path from "node:path";
2106
+ var LOCK_HEARTBEAT_MS = 5000;
2107
+ var LOCK_STALE_MS = 15000;
2108
+ var LOCK_MAX_WAIT_MS = 20000;
2109
+ var LOCK_MAX_HOLD_MS = 60000;
2110
+ var LOCK_RETRY_MIN_MS = 100;
2111
+ var LOCK_RETRY_JITTER_MS = 200;
2112
+
2113
+ class NodeFileSystem {
2114
+ path = {
2115
+ join: path.join,
2116
+ resolve: path.resolve,
2117
+ relative: path.relative,
2118
+ dirname: path.dirname,
2119
+ isAbsolute: path.isAbsolute,
2120
+ basename: path.basename
2121
+ };
2122
+ env = {
2123
+ cwd: process.cwd,
2124
+ homedir: os.homedir,
2125
+ tmpdir: os.tmpdir,
2126
+ getenv: (key) => process.env[key]
2127
+ };
2128
+ utils = {
2129
+ open: async (url) => {
2130
+ const { default: open } = await import("./index-sby22td6.js");
2131
+ await open(url);
2132
+ }
2133
+ };
2134
+ async readFile(path2, options) {
2135
+ try {
2136
+ if (options) {
2137
+ return await fs.readFile(path2, "utf-8");
2138
+ }
2139
+ return await fs.readFile(path2);
2140
+ } catch (error) {
2141
+ if (this.isEnoent(error))
2142
+ return null;
2143
+ throw error;
2144
+ }
2145
+ }
2146
+ async writeFile(filePath, data) {
2147
+ const dir = path.dirname(filePath);
2148
+ if (dir) {
2149
+ await fs.mkdir(dir, { recursive: true });
2150
+ }
2151
+ await fs.writeFile(filePath, data);
2152
+ }
2153
+ async appendFile(filePath, data) {
2154
+ const dir = path.dirname(filePath);
2155
+ if (dir) {
2156
+ await fs.mkdir(dir, { recursive: true });
2157
+ }
2158
+ await fs.appendFile(filePath, data);
2159
+ }
2160
+ async readdir(dirPath) {
2161
+ try {
2162
+ return await fs.readdir(dirPath);
2163
+ } catch (error) {
2164
+ if (this.isEnoent(error))
2165
+ return [];
2166
+ throw error;
2167
+ }
2168
+ }
2169
+ async stat(filePath) {
2170
+ try {
2171
+ const stats = await fs.stat(filePath);
2172
+ return {
2173
+ isFile: () => stats.isFile(),
2174
+ isDirectory: () => stats.isDirectory(),
2175
+ size: stats.size,
2176
+ mtimeMs: stats.mtimeMs
2177
+ };
2178
+ } catch (error) {
2179
+ if (this.isEnoent(error))
2180
+ return null;
2181
+ throw error;
2182
+ }
2183
+ }
2184
+ async exists(filePath) {
2185
+ return existsSync(filePath);
2186
+ }
2187
+ async mkdir(dirPath) {
2188
+ await fs.mkdir(dirPath, { recursive: true });
2189
+ }
2190
+ async acquireLock(lockPath) {
2191
+ const canonicalPath = await this.canonicalizeLockTarget(lockPath);
2192
+ const lockFile = `${canonicalPath}.lock`;
2193
+ const ownerId = randomUUID();
2194
+ const start = Date.now();
2195
+ while (true) {
2196
+ try {
2197
+ await fs.writeFile(lockFile, ownerId, { flag: "wx" });
2198
+ return this.createLockRelease(lockFile, ownerId);
2199
+ } catch (error) {
2200
+ if (!this.hasErrnoCode(error, "EEXIST")) {
2201
+ throw error;
2202
+ }
2203
+ const stats = await fs.stat(lockFile).catch(() => null);
2204
+ if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
2205
+ const reclaimed = await fs.rm(lockFile, { force: true }).then(() => true).catch(() => false);
2206
+ if (reclaimed)
2207
+ continue;
2208
+ }
2209
+ if (Date.now() - start > LOCK_MAX_WAIT_MS) {
2210
+ throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
2211
+ }
2212
+ await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
2213
+ }
2214
+ }
2215
+ }
2216
+ async canonicalizeLockTarget(lockPath) {
2217
+ const absolute = path.resolve(lockPath);
2218
+ const fullReal = await fs.realpath(absolute).catch(() => null);
2219
+ if (fullReal)
2220
+ return fullReal;
2221
+ const parent = path.dirname(absolute);
2222
+ const base = path.basename(absolute);
2223
+ const canonicalParent = await fs.realpath(parent).catch(() => parent);
2224
+ return path.join(canonicalParent, base);
2225
+ }
2226
+ createLockRelease(lockFile, ownerId) {
2227
+ const heartbeatStart = Date.now();
2228
+ let heartbeatTimer;
2229
+ let stopped = false;
2230
+ const stopHeartbeat = () => {
2231
+ stopped = true;
2232
+ if (heartbeatTimer)
2233
+ clearTimeout(heartbeatTimer);
2234
+ };
2235
+ const scheduleNextHeartbeat = () => {
2236
+ if (stopped)
2237
+ return;
2238
+ if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
2239
+ stopped = true;
2240
+ return;
2241
+ }
2242
+ heartbeatTimer = setTimeout(() => {
2243
+ runHeartbeat();
2244
+ }, LOCK_HEARTBEAT_MS);
2245
+ heartbeatTimer.unref?.();
2246
+ };
2247
+ const runHeartbeat = async () => {
2248
+ if (stopped)
2249
+ return;
2250
+ const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
2251
+ if (stopped)
2252
+ return;
2253
+ if (current !== ownerId) {
2254
+ stopped = true;
2255
+ return;
2256
+ }
2257
+ const now = Date.now() / 1000;
2258
+ await fs.utimes(lockFile, now, now).catch(() => {});
2259
+ scheduleNextHeartbeat();
2260
+ };
2261
+ scheduleNextHeartbeat();
2262
+ let released = false;
2263
+ return async () => {
2264
+ if (released)
2265
+ return;
2266
+ released = true;
2267
+ stopHeartbeat();
2268
+ const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
2269
+ if (current === ownerId) {
2270
+ await fs.rm(lockFile, { force: true });
2271
+ }
2272
+ };
2273
+ }
2274
+ async rm(filePath) {
2275
+ await fs.rm(filePath, { recursive: true, force: true });
2276
+ }
2277
+ async rename(oldPath, newPath) {
2278
+ await fs.rename(oldPath, newPath);
2279
+ }
2280
+ async realpath(filePath) {
2281
+ try {
2282
+ return await fs.realpath(filePath);
2283
+ } catch (error) {
2284
+ if (this.isEnoent(error))
2285
+ return filePath;
2286
+ throw error;
2287
+ }
2288
+ }
2289
+ async getTempDir() {
2290
+ return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
2291
+ }
2292
+ async copyDirectory(sourcePath, destPath) {
2293
+ const sourceStats = await this.stat(sourcePath);
2294
+ if (!sourceStats) {
2295
+ throw new Error(`Source directory does not exist: ${sourcePath}`);
2296
+ }
2297
+ if (!sourceStats.isDirectory()) {
2298
+ throw new Error(`Source path is not a directory: ${sourcePath}`);
2299
+ }
2300
+ await this.mkdir(destPath);
2301
+ const entries = await this.readdir(sourcePath);
2302
+ for (const entry of entries) {
2303
+ const srcEntry = path.join(sourcePath, entry);
2304
+ const destEntry = path.join(destPath, entry);
2305
+ const entryStats = await this.stat(srcEntry);
2306
+ if (!entryStats)
2307
+ continue;
2308
+ if (entryStats.isDirectory()) {
2309
+ await this.copyDirectory(srcEntry, destEntry);
2310
+ } else if (entryStats.isFile()) {
2311
+ const content = await this.readFile(srcEntry);
2312
+ if (content !== null) {
2313
+ await this.writeFile(destEntry, content);
2314
+ }
2315
+ }
2316
+ }
2317
+ }
2318
+ isEnoent(error) {
2319
+ return this.hasErrnoCode(error, "ENOENT");
2320
+ }
2321
+ hasErrnoCode(error, code) {
2322
+ return typeof error === "object" && error !== null && "code" in error && error.code === code;
2323
+ }
2115
2324
  }
2116
- function catchError2(fnOrPromise) {
2117
- if (isPromiseLike(fnOrPromise)) {
2118
- return settlePromiseLike(fnOrPromise);
2325
+
2326
+ // ../filesystem/src/index.ts
2327
+ var fsInstance = new NodeFileSystem;
2328
+ var getFileSystem = () => fsInstance;
2329
+
2330
+ // ../common/src/telemetry/pseudonymize.ts
2331
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2332
+ var PSEUDONYM_HEX_LENGTH = 32;
2333
+ var SHA256_K = new Uint32Array([
2334
+ 1116352408,
2335
+ 1899447441,
2336
+ 3049323471,
2337
+ 3921009573,
2338
+ 961987163,
2339
+ 1508970993,
2340
+ 2453635748,
2341
+ 2870763221,
2342
+ 3624381080,
2343
+ 310598401,
2344
+ 607225278,
2345
+ 1426881987,
2346
+ 1925078388,
2347
+ 2162078206,
2348
+ 2614888103,
2349
+ 3248222580,
2350
+ 3835390401,
2351
+ 4022224774,
2352
+ 264347078,
2353
+ 604807628,
2354
+ 770255983,
2355
+ 1249150122,
2356
+ 1555081692,
2357
+ 1996064986,
2358
+ 2554220882,
2359
+ 2821834349,
2360
+ 2952996808,
2361
+ 3210313671,
2362
+ 3336571891,
2363
+ 3584528711,
2364
+ 113926993,
2365
+ 338241895,
2366
+ 666307205,
2367
+ 773529912,
2368
+ 1294757372,
2369
+ 1396182291,
2370
+ 1695183700,
2371
+ 1986661051,
2372
+ 2177026350,
2373
+ 2456956037,
2374
+ 2730485921,
2375
+ 2820302411,
2376
+ 3259730800,
2377
+ 3345764771,
2378
+ 3516065817,
2379
+ 3600352804,
2380
+ 4094571909,
2381
+ 275423344,
2382
+ 430227734,
2383
+ 506948616,
2384
+ 659060556,
2385
+ 883997877,
2386
+ 958139571,
2387
+ 1322822218,
2388
+ 1537002063,
2389
+ 1747873779,
2390
+ 1955562222,
2391
+ 2024104815,
2392
+ 2227730452,
2393
+ 2361852424,
2394
+ 2428436474,
2395
+ 2756734187,
2396
+ 3204031479,
2397
+ 3329325298
2398
+ ]);
2399
+ var SHA256_INITIAL_STATE = new Uint32Array([
2400
+ 1779033703,
2401
+ 3144134277,
2402
+ 1013904242,
2403
+ 2773480762,
2404
+ 1359893119,
2405
+ 2600822924,
2406
+ 528734635,
2407
+ 1541459225
2408
+ ]);
2409
+ function rotr(value, bits) {
2410
+ return (value >>> bits | value << 32 - bits) >>> 0;
2411
+ }
2412
+ function sha256Hex(input) {
2413
+ const bytes = new TextEncoder().encode(input);
2414
+ const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
2415
+ const buffer = new Uint8Array(paddedLength);
2416
+ buffer.set(bytes);
2417
+ buffer[bytes.length] = 128;
2418
+ const view = new DataView(buffer.buffer);
2419
+ const bitLength = bytes.length * 8;
2420
+ view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
2421
+ view.setUint32(paddedLength - 4, bitLength >>> 0);
2422
+ const state = SHA256_INITIAL_STATE.slice();
2423
+ const schedule = new Uint32Array(64);
2424
+ for (let offset = 0;offset < paddedLength; offset += 64) {
2425
+ for (let i = 0;i < 16; i++) {
2426
+ schedule[i] = view.getUint32(offset + i * 4);
2427
+ }
2428
+ for (let i = 16;i < 64; i++) {
2429
+ const x = schedule[i - 15];
2430
+ const y = schedule[i - 2];
2431
+ const s0 = (rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3) >>> 0;
2432
+ const s1 = (rotr(y, 17) ^ rotr(y, 19) ^ y >>> 10) >>> 0;
2433
+ schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1 >>> 0;
2434
+ }
2435
+ let a = state[0];
2436
+ let b = state[1];
2437
+ let c = state[2];
2438
+ let d = state[3];
2439
+ let e = state[4];
2440
+ let f = state[5];
2441
+ let g = state[6];
2442
+ let h = state[7];
2443
+ for (let i = 0;i < 64; i++) {
2444
+ const s1 = (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) >>> 0;
2445
+ const ch = (e & f ^ ~e & g) >>> 0;
2446
+ const temp1 = h + s1 + ch + SHA256_K[i] + schedule[i] >>> 0;
2447
+ const s0 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) >>> 0;
2448
+ const maj = (a & b ^ a & c ^ b & c) >>> 0;
2449
+ const temp2 = s0 + maj >>> 0;
2450
+ h = g;
2451
+ g = f;
2452
+ f = e;
2453
+ e = d + temp1 >>> 0;
2454
+ d = c;
2455
+ c = b;
2456
+ b = a;
2457
+ a = temp1 + temp2 >>> 0;
2458
+ }
2459
+ state[0] = state[0] + a >>> 0;
2460
+ state[1] = state[1] + b >>> 0;
2461
+ state[2] = state[2] + c >>> 0;
2462
+ state[3] = state[3] + d >>> 0;
2463
+ state[4] = state[4] + e >>> 0;
2464
+ state[5] = state[5] + f >>> 0;
2465
+ state[6] = state[6] + g >>> 0;
2466
+ state[7] = state[7] + h >>> 0;
2119
2467
  }
2468
+ let hex = "";
2469
+ for (const word of state) {
2470
+ hex += word.toString(16).padStart(8, "0");
2471
+ }
2472
+ return hex;
2473
+ }
2474
+ function resolveSha256Hex() {
2120
2475
  try {
2121
- const result = fnOrPromise();
2122
- if (isPromiseLike(result)) {
2123
- return settlePromiseLike(result);
2476
+ const nodeCrypto = __require("node:crypto");
2477
+ const createHash = nodeCrypto?.createHash;
2478
+ if (typeof createHash !== "function") {
2479
+ return sha256Hex;
2124
2480
  }
2125
- return [undefined, result];
2126
- } catch (error) {
2127
- return [
2128
- error instanceof Error ? error : new Error(String(error)),
2129
- undefined
2130
- ];
2481
+ const native = (input) => createHash("sha256").update(input, "utf8").digest("hex");
2482
+ return native("abc") === sha256Hex("abc") ? native : sha256Hex;
2483
+ } catch {
2484
+ return sha256Hex;
2131
2485
  }
2132
2486
  }
2133
- function settlePromiseLike(thenable) {
2134
- return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
2135
- error instanceof Error ? error : new Error(String(error)),
2136
- undefined
2137
- ]);
2487
+ var cachedSha256Hex;
2488
+ function digest(input) {
2489
+ cachedSha256Hex ??= resolveSha256Hex();
2490
+ return cachedSha256Hex(input);
2491
+ }
2492
+ function pseudonymize(input) {
2493
+ return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
2138
2494
  }
2139
-
2140
- // ../../node_modules/commander/esm.mjs
2141
- var import__ = __toESM(require_commander(), 1);
2142
- var {
2143
- program,
2144
- createCommand,
2145
- createArgument,
2146
- createOption,
2147
- CommanderError,
2148
- InvalidArgumentError,
2149
- InvalidOptionArgumentError,
2150
- Command,
2151
- Argument,
2152
- Option,
2153
- Help
2154
- } = import__.default;
2155
2495
 
2156
2496
  // ../common/src/singleton.ts
2157
2497
  var PREFIX = "@uipath/common/";
@@ -2183,26 +2523,352 @@ function singleton(ctorOrName) {
2183
2523
  };
2184
2524
  }
2185
2525
 
2186
- // ../common/src/preview.ts
2187
- var previewSlot = singleton("PreviewBuild");
2188
- function isPreviewBuild() {
2189
- return previewSlot.get(false) ?? false;
2526
+ // ../common/src/telemetry/supplied-values.ts
2527
+ var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
2528
+ function activeEntries() {
2529
+ const existing = suppliedValuesSlot.get();
2530
+ return Array.isArray(existing) ? existing : [];
2531
+ }
2532
+ var MIN_SCRUBBABLE_LENGTH = 4;
2533
+ function recordSuppliedArgumentValues(values) {
2534
+ const flat = [];
2535
+ const push = (value) => {
2536
+ if (Array.isArray(value)) {
2537
+ for (const item of value) {
2538
+ push(item);
2539
+ }
2540
+ return;
2541
+ }
2542
+ if (typeof value === "string" && value.length >= MIN_SCRUBBABLE_LENGTH) {
2543
+ flat.push(value);
2544
+ }
2545
+ };
2546
+ push(values);
2547
+ const entry = { values: flat };
2548
+ suppliedValuesSlot.set([...activeEntries(), entry]);
2549
+ return entry;
2190
2550
  }
2191
- function previewOnly(register) {
2192
- if (isPreviewBuild()) {
2193
- register();
2551
+ function releaseSuppliedArgumentValues(entry) {
2552
+ suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
2553
+ }
2554
+ function getSuppliedArgumentValues() {
2555
+ const all = new Set;
2556
+ for (const entry of activeEntries()) {
2557
+ for (const value of entry.values) {
2558
+ all.add(value);
2559
+ }
2194
2560
  }
2561
+ return [...all].sort((a, b) => b.length - a.length);
2195
2562
  }
2196
- Command.prototype.previewCommand = function(nameAndArgs, opts) {
2197
- if (isPreviewBuild()) {
2198
- return this.command(nameAndArgs, opts);
2563
+
2564
+ // ../common/src/telemetry/pii-redactor.ts
2565
+ var REDACTED = "[REDACTED]";
2566
+ var MAX_VALUE_LENGTH = 280;
2567
+ var MAX_STACK_LENGTH = 4096;
2568
+ var MAX_SCAN_LENGTH = MAX_STACK_LENGTH;
2569
+ function truncate(value, maxLength) {
2570
+ return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;
2571
+ }
2572
+ var SENSITIVE_NAME_TOKENS = new Set([
2573
+ "token",
2574
+ "tokens",
2575
+ "secret",
2576
+ "secrets",
2577
+ "password",
2578
+ "passwords",
2579
+ "pwd",
2580
+ "credential",
2581
+ "credentials",
2582
+ "auth",
2583
+ "authentication",
2584
+ "authorization",
2585
+ "authority",
2586
+ "cert",
2587
+ "certificate",
2588
+ "certificates"
2589
+ ]);
2590
+ var SENSITIVE_KEY_PREFIXES = new Set([
2591
+ "api",
2592
+ "access",
2593
+ "client",
2594
+ "private",
2595
+ "public",
2596
+ "signing",
2597
+ "encryption",
2598
+ "session",
2599
+ "master",
2600
+ "shared",
2601
+ "root",
2602
+ "ssh",
2603
+ "rsa",
2604
+ "aes",
2605
+ "hmac",
2606
+ "oauth"
2607
+ ]);
2608
+ var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
2609
+ var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
2610
+ var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
2611
+ var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
2612
+ var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
2613
+ var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
2614
+ var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
2615
+ var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
2616
+ var HOST_PORT_PATTERN = /(?<![/@.\w-])(?!\d+\.\d+\.\d+\.\d+:)[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)+:\d{1,5}\b/g;
2617
+ var SOURCE_FILE_EXTENSIONS = new Set([
2618
+ "ts",
2619
+ "tsx",
2620
+ "js",
2621
+ "jsx",
2622
+ "mjs",
2623
+ "cjs",
2624
+ "cts",
2625
+ "mts",
2626
+ "py",
2627
+ "cs",
2628
+ "java",
2629
+ "go",
2630
+ "rs",
2631
+ "rb",
2632
+ "php",
2633
+ "sh",
2634
+ "ps1",
2635
+ "json",
2636
+ "jsonc",
2637
+ "yaml",
2638
+ "yml",
2639
+ "xml",
2640
+ "xaml",
2641
+ "md",
2642
+ "txt",
2643
+ "log",
2644
+ "css",
2645
+ "html",
2646
+ "htm",
2647
+ "csproj",
2648
+ "nuspec",
2649
+ "sql"
2650
+ ]);
2651
+ var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
2652
+ var QUOTED_LITERAL_MAX_SPAN = 200;
2653
+ var QUOTED_LITERAL_PATTERN = new RegExp([
2654
+ `(?<![A-Za-z0-9])'(?:[^\\
2655
+ ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
2656
+ `(?<![A-Za-z0-9])"(?:[^\\
2657
+ ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
2658
+ ].join("|"), "g");
2659
+ var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
2660
+ var COLLAPSED_BODY = "{…}";
2661
+ var COLLAPSED_BODY_MARKER = "\x01body\x01";
2662
+ var MAX_BODY_NESTING = 8;
2663
+ function collapseJsonBodies(text) {
2664
+ let out = text;
2665
+ for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
2666
+ const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
2667
+ if (next === out) {
2668
+ break;
2669
+ }
2670
+ out = next;
2199
2671
  }
2200
- return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
2201
- };
2672
+ return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
2673
+ }
2674
+ var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
2675
+ function peelTrailingPunctuation(match) {
2676
+ const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
2677
+ return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
2678
+ }
2679
+ function redactUrl(raw) {
2680
+ try {
2681
+ const url = new URL(raw);
2682
+ return `${url.protocol}//${url.host}`;
2683
+ } catch {
2684
+ return `url#${pseudonymize(raw)}`;
2685
+ }
2686
+ }
2687
+ function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
2688
+ let out = truncate(value, MAX_SCAN_LENGTH);
2689
+ out = out.replace(JWT_PATTERN, () => REDACTED);
2690
+ out = out.replace(URL_PATTERN, (match) => {
2691
+ const [core, trailing] = peelTrailingPunctuation(match);
2692
+ return `${redactUrl(core)}${trailing}`;
2693
+ });
2694
+ out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
2695
+ out = out.replace(UNC_PATH_PATTERN, (_match, before, path2) => {
2696
+ const [core, trailing] = peelTrailingPunctuation(path2);
2697
+ return `${before}unc#${pseudonymize(core)}${trailing}`;
2698
+ });
2699
+ out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
2700
+ out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
2701
+ out = out.replace(HOST_PORT_PATTERN, (match) => {
2702
+ const split = match.lastIndexOf(":");
2703
+ const host = match.slice(0, split);
2704
+ const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
2705
+ if (SOURCE_FILE_EXTENSIONS.has(extension)) {
2706
+ return match;
2707
+ }
2708
+ return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
2709
+ });
2710
+ out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
2711
+ out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
2712
+ out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
2713
+ return truncate(out, maxLength);
2714
+ }
2715
+ function redactSpanName(name) {
2716
+ return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
2717
+ }
2718
+ var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
2719
+ function redactHttpDependencyName(name) {
2720
+ const parts = HTTP_DEPENDENCY_NAME.exec(name);
2721
+ if (!parts) {
2722
+ return redactMessage(name);
2723
+ }
2724
+ return `${parts[1]} ${redactMessage(parts[2])}`;
2725
+ }
2726
+ function redactMessage(value) {
2727
+ let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
2728
+ for (const supplied of getSuppliedArgumentValues()) {
2729
+ out = out.split(supplied).join(REDACTED);
2730
+ }
2731
+ return redactValueDetectors(out);
2732
+ }
2733
+ var MESSAGE_NAMES = new Set([
2734
+ "message",
2735
+ "errormessage",
2736
+ "errmessage",
2737
+ "error_message",
2738
+ "msg",
2739
+ "detail",
2740
+ "details",
2741
+ "reason",
2742
+ "instructions",
2743
+ "warning"
2744
+ ]);
2745
+ function isFreeFormValue(name, value) {
2746
+ return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
2747
+ }
2748
+ function redactError(error) {
2749
+ const safe = new Error(redactMessage(error.message ?? ""));
2750
+ safe.name = error.name;
2751
+ safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
2752
+ return safe;
2753
+ }
2754
+ function redactStack(stack) {
2755
+ const bounded = truncate(stack, MAX_STACK_LENGTH);
2756
+ const firstBreak = bounded.indexOf(`
2757
+ `);
2758
+ if (firstBreak === -1) {
2759
+ return redactMessage(bounded);
2760
+ }
2761
+ return `${redactMessage(bounded.slice(0, firstBreak))}
2762
+ ${redactValueDetectors(bounded.slice(firstBreak + 1), MAX_STACK_LENGTH)}`;
2763
+ }
2764
+ function nameTokens(name) {
2765
+ return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[\s._-]+/).map((t) => t.toLowerCase()).filter(Boolean);
2766
+ }
2767
+ function isSensitiveName(name) {
2768
+ const tokens = nameTokens(name);
2769
+ for (let i = 0;i < tokens.length; i++) {
2770
+ const token = tokens[i];
2771
+ if (SENSITIVE_NAME_TOKENS.has(token)) {
2772
+ return true;
2773
+ }
2774
+ if (token === "key" || token === "keys") {
2775
+ const prev = tokens[i - 1];
2776
+ if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
2777
+ return true;
2778
+ }
2779
+ }
2780
+ }
2781
+ return false;
2782
+ }
2783
+ function redactProperty(name, value) {
2784
+ if (value === undefined || value === null) {
2785
+ return;
2786
+ }
2787
+ if (isSensitiveName(name)) {
2788
+ return REDACTED;
2789
+ }
2790
+ if (typeof value === "boolean" || typeof value === "number") {
2791
+ return value;
2792
+ }
2793
+ if (typeof value !== "string") {
2794
+ return "[OBJECT]";
2795
+ }
2796
+ return isFreeFormValue(name, value) ? redactMessage(value) : redactValueDetectors(value);
2797
+ }
2798
+ function redactProperties(properties) {
2799
+ const out = {};
2800
+ for (const [name, value] of Object.entries(properties)) {
2801
+ const redacted = redactProperty(name, value);
2802
+ if (redacted !== undefined) {
2803
+ out[name] = redacted;
2804
+ }
2805
+ }
2806
+ return out;
2807
+ }
2808
+
2809
+ // ../common/src/catch-error.ts
2810
+ var MAX_SERIALIZED_LENGTH = 500;
2811
+ var TRUNCATION_SUFFIX = "…(truncated)";
2812
+ var REDACTED2 = "[REDACTED]";
2813
+ function cap(text) {
2814
+ return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
2815
+ }
2816
+ function omitSensitive(key, value) {
2817
+ return key.length > 0 && isSensitiveName(key) ? REDACTED2 : value;
2818
+ }
2819
+ function describeThrownValue(value) {
2820
+ if (typeof value !== "object" || value === null) {
2821
+ return String(value);
2822
+ }
2823
+ let message;
2824
+ try {
2825
+ message = value.message;
2826
+ } catch {
2827
+ message = undefined;
2828
+ }
2829
+ if (typeof message === "string" && message.length > 0) {
2830
+ return cap(message);
2831
+ }
2832
+ try {
2833
+ const json = JSON.stringify(value, omitSensitive);
2834
+ if (json !== undefined) {
2835
+ return cap(json);
2836
+ }
2837
+ } catch {}
2838
+ return String(value);
2839
+ }
2840
+ function toError(error) {
2841
+ return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
2842
+ }
2843
+ function isPromiseLike(value) {
2844
+ return value !== null && typeof value === "object" && typeof value.then === "function";
2845
+ }
2846
+ function catchError(fnOrPromise) {
2847
+ if (isPromiseLike(fnOrPromise)) {
2848
+ return settlePromiseLike(fnOrPromise);
2849
+ }
2850
+ try {
2851
+ const result = fnOrPromise();
2852
+ if (isPromiseLike(result)) {
2853
+ return settlePromiseLike(result);
2854
+ }
2855
+ return [undefined, result];
2856
+ } catch (error) {
2857
+ return [toError(error), undefined];
2858
+ }
2859
+ }
2860
+ function settlePromiseLike(thenable) {
2861
+ return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
2862
+ }
2863
+
2864
+ // ../common/src/exit-code.ts
2865
+ function setExitCode(code) {
2866
+ process.exitCode = code;
2867
+ }
2202
2868
 
2203
2869
  // ../common/src/output-context.ts
2204
2870
  function createStorage() {
2205
- const [error, mod] = catchError2(() => __require("node:async_hooks"));
2871
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
2206
2872
  if (error || typeof mod?.AsyncLocalStorage !== "function") {
2207
2873
  return {
2208
2874
  getStore: () => {
@@ -2233,8 +2899,8 @@ function getOutputSink() {
2233
2899
 
2234
2900
  // ../common/src/logger.ts
2235
2901
  var logFilePathSlot = singleton("logFilePath");
2236
- function setGlobalLogFilePath(path) {
2237
- logFilePathSlot.set(path);
2902
+ function setGlobalLogFilePath(path2) {
2903
+ logFilePathSlot.set(path2);
2238
2904
  }
2239
2905
  function getGlobalLogFilePath() {
2240
2906
  return logFilePathSlot.get("");
@@ -2271,7 +2937,7 @@ class SimpleLogger {
2271
2937
  }
2272
2938
  return DEFAULT_LOG_LEVEL;
2273
2939
  }
2274
- const [localStorageError, hasDebug] = catchError2(() => typeof localStorage !== "undefined" && !!localStorage.getItem("debug"));
2940
+ const [localStorageError, hasDebug] = catchError(() => typeof localStorage !== "undefined" && !!localStorage.getItem("debug"));
2275
2941
  if (!localStorageError && hasDebug) {
2276
2942
  return 0 /* DEBUG */;
2277
2943
  }
@@ -2302,54 +2968,49 @@ class SimpleLogger {
2302
2968
  return this.fileLoggingEnabled || !!getGlobalLogFilePath();
2303
2969
  }
2304
2970
  writeToFile(formatted) {
2305
- const path = this.logFilePath || getGlobalLogFilePath();
2306
- if (!path)
2971
+ const path2 = this.logFilePath || getGlobalLogFilePath();
2972
+ if (!path2)
2307
2973
  return;
2308
2974
  const timestamp = new Date().toISOString();
2309
2975
  this.pendingWrites = Promise.all([
2310
2976
  this.pendingWrites,
2311
2977
  this.pendingInit
2312
- ]).then(() => getFileSystem().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
2978
+ ]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
2313
2979
  }
2314
- debug(message, ...args) {
2315
- if (this.level > 0 /* DEBUG */)
2316
- return;
2317
- const formatted = this.format(`[DEBUG] ${message}`, args);
2980
+ write(formatted) {
2318
2981
  if (this.isFileLoggingActive()) {
2319
2982
  this.writeToFile(formatted);
2320
2983
  } else {
2321
2984
  getOutputSink().writeErr(formatted);
2322
2985
  }
2323
2986
  }
2987
+ debug(message, ...args) {
2988
+ if (this.level > 0 /* DEBUG */)
2989
+ return;
2990
+ const formatted = this.format(`[DEBUG] ${message}`, args);
2991
+ this.write(formatted);
2992
+ }
2324
2993
  info(message, ...args) {
2325
2994
  if (this.level > 1 /* INFO */)
2326
2995
  return;
2327
2996
  const formatted = this.format(message, args);
2328
- if (this.isFileLoggingActive()) {
2329
- this.writeToFile(formatted);
2330
- } else {
2331
- getOutputSink().writeErr(formatted);
2332
- }
2997
+ this.write(formatted);
2333
2998
  }
2334
2999
  warn(message, ...args) {
2335
3000
  if (this.level > 2 /* WARN */)
2336
3001
  return;
2337
3002
  const formatted = this.format(`[WARN] ${message}`, args);
2338
- if (this.isFileLoggingActive()) {
2339
- this.writeToFile(formatted);
2340
- } else {
2341
- getOutputSink().writeErr(formatted);
2342
- }
3003
+ this.write(formatted);
2343
3004
  }
2344
3005
  error(message, ...args) {
2345
3006
  if (this.level > 3 /* ERROR */)
2346
3007
  return;
2347
3008
  const formatted = this.format(`[ERROR] ${message}`, args);
2348
- if (this.isFileLoggingActive()) {
2349
- this.writeToFile(formatted);
2350
- } else {
2351
- getOutputSink().writeErr(formatted);
2352
- }
3009
+ this.write(formatted);
3010
+ }
3011
+ report(message) {
3012
+ const formatted = this.format(message, []);
3013
+ this.write(formatted);
2353
3014
  }
2354
3015
  getLevel() {
2355
3016
  return this.level;
@@ -2364,17 +3025,17 @@ class SimpleLogger {
2364
3025
  setGlobalLogFilePath("");
2365
3026
  }
2366
3027
  }
2367
- setLogFile(path) {
2368
- this.logFilePath = path;
2369
- setGlobalLogFilePath(path);
2370
- if (!path)
3028
+ setLogFile(path2) {
3029
+ this.logFilePath = path2;
3030
+ setGlobalLogFilePath(path2);
3031
+ if (!path2)
2371
3032
  return;
2372
3033
  this.fileLoggingEnabled = true;
2373
- const fs = getFileSystem();
3034
+ const fs2 = getFileSystem();
2374
3035
  this.pendingInit = (async () => {
2375
- const [error] = await catchError2((async () => {
2376
- await fs.mkdir(fs.path.dirname(path));
2377
- await fs.writeFile(path, "");
3036
+ const [error] = await catchError((async () => {
3037
+ await fs2.mkdir(fs2.path.dirname(path2));
3038
+ await fs2.writeFile(path2, "");
2378
3039
  })());
2379
3040
  if (error)
2380
3041
  this.fileLoggingEnabled = false;
@@ -2428,12 +3089,12 @@ var jmespathSlot = singleton("JmespathCodec");
2428
3089
  async function loadOutputCodecsAsync(needed) {
2429
3090
  const loads = [];
2430
3091
  if (needed.yaml && yamlSlot.get() === undefined) {
2431
- loads.push(import("./js-yaml-4ypbq2tt.js").then((mod) => {
3092
+ loads.push(import("./js-yaml-b2jq67kn.js").then((mod) => {
2432
3093
  yamlSlot.set(mod);
2433
3094
  }));
2434
3095
  }
2435
3096
  if (needed.filter && jmespathSlot.get() === undefined) {
2436
- loads.push(import("./index-2fj08e7n.js").then((mod) => {
3097
+ loads.push(import("./index-gpd94m28.js").then((mod) => {
2437
3098
  jmespathSlot.set(mod);
2438
3099
  }));
2439
3100
  }
@@ -2688,7 +3349,7 @@ function readRegistryValue(keyPath, valueName) {
2688
3349
  if (process.platform !== "win32") {
2689
3350
  return "";
2690
3351
  }
2691
- const [error, output] = catchError2(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
3352
+ const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
2692
3353
  encoding: "utf-8",
2693
3354
  stdio: ["pipe", "pipe", "pipe"]
2694
3355
  }));
@@ -2711,27 +3372,41 @@ class LoggerTelemetryProvider {
2711
3372
  ...this.analyticsUniqueId ? { analyticsUniqueId: this.analyticsUniqueId } : {}
2712
3373
  };
2713
3374
  }
2714
- async trackEvent(eventName, properties) {
2715
- logger.debug(formatMessage("Event", eventName, this.enrich(properties)));
3375
+ async trackEvent({ name, properties }) {
3376
+ logger.debug(formatMessage("Event", name, this.enrich(properties)));
2716
3377
  }
2717
- async trackException(error, properties) {
3378
+ async trackException({
3379
+ error,
3380
+ properties
3381
+ }) {
2718
3382
  logger.error(formatMessage("Exception", error.message, this.enrich({
2719
3383
  ...properties,
2720
3384
  stack: error.stack
2721
3385
  })));
2722
3386
  }
2723
- async trackRequest(name, duration, success, properties) {
3387
+ async trackRequest({
3388
+ name,
3389
+ durationMs,
3390
+ success,
3391
+ properties
3392
+ }) {
2724
3393
  logger.debug(formatMessage("Request", name, this.enrich({
2725
3394
  ...properties,
2726
- duration: `${duration}ms`,
3395
+ duration: `${durationMs}ms`,
2727
3396
  success
2728
3397
  })));
2729
3398
  }
2730
- async trackDependency(name, type, duration, success, properties) {
3399
+ async trackDependency({
3400
+ name,
3401
+ type,
3402
+ durationMs,
3403
+ success,
3404
+ properties
3405
+ }) {
2731
3406
  logger.debug(formatMessage("Dependency", name, this.enrich({
2732
3407
  ...properties,
2733
3408
  type,
2734
- duration: `${duration}ms`,
3409
+ duration: `${durationMs}ms`,
2735
3410
  success
2736
3411
  })));
2737
3412
  }
@@ -2952,179 +3627,51 @@ function getInheritedSession(env) {
2952
3627
  function generateRandomSession() {
2953
3628
  const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
2954
3629
  crypto.getRandomValues(bytes);
2955
- let hex = "";
2956
- for (const byte of bytes) {
2957
- hex += byte.toString(16).padStart(2, "0");
2958
- }
2959
- return { id: hex, source: "random" };
2960
- }
2961
- function resolveTelemetrySession() {
2962
- const existing = telemetrySessionSlot.get();
2963
- if (existing) {
2964
- return existing;
2965
- }
2966
- const declaredHandle = getConfiguredTelemetrySessionId();
2967
- const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
2968
- telemetrySessionSlot.set(resolved);
2969
- return resolved;
2970
- }
2971
- function getTelemetrySessionSource() {
2972
- return resolveTelemetrySession().source;
2973
- }
2974
- function getTelemetryOperationId() {
2975
- const existing = telemetryOperationIdSlot.get();
2976
- if (existing) {
2977
- return existing;
2978
- }
2979
- const inboundTraceId = getInboundTraceContext()?.traceId;
2980
- const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
2981
- telemetryOperationIdSlot.set(generated);
2982
- return generated;
2983
- }
2984
- // ../common/src/telemetry/global-telemetry-properties.ts
2985
- var telemetryPropsSlot = singleton("TelemetryDefaultProps");
2986
- function getGlobalTelemetryProperties() {
2987
- return telemetryPropsSlot.get();
2988
- }
2989
-
2990
- // ../common/src/telemetry/pii-redactor.ts
2991
- var REDACTED = "[REDACTED]";
2992
- var MAX_VALUE_LENGTH = 200;
2993
- var SENSITIVE_NAME_TOKENS = new Set([
2994
- "token",
2995
- "tokens",
2996
- "secret",
2997
- "secrets",
2998
- "password",
2999
- "passwords",
3000
- "pwd",
3001
- "credential",
3002
- "credentials",
3003
- "auth",
3004
- "authentication",
3005
- "authorization",
3006
- "authority",
3007
- "cert",
3008
- "certificate",
3009
- "certificates"
3010
- ]);
3011
- var SENSITIVE_KEY_PREFIXES = new Set([
3012
- "api",
3013
- "access",
3014
- "client",
3015
- "private",
3016
- "public",
3017
- "signing",
3018
- "encryption",
3019
- "session",
3020
- "master",
3021
- "shared",
3022
- "root",
3023
- "ssh",
3024
- "rsa",
3025
- "aes",
3026
- "hmac",
3027
- "oauth"
3028
- ]);
3029
- var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
3030
- var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
3031
- var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
3032
- var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
3033
- var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
3034
- var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
3035
- var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
3036
- function shortHash(input) {
3037
- let hash = 2166136261;
3038
- for (let i = 0;i < input.length; i++) {
3039
- hash ^= input.charCodeAt(i);
3040
- hash = Math.imul(hash, 16777619);
3041
- }
3042
- return (hash >>> 0).toString(16).padStart(8, "0");
3043
- }
3044
- function redactUrl(raw) {
3045
- try {
3046
- const url = new URL(raw);
3047
- return `${url.protocol}//${url.host}`;
3048
- } catch {
3049
- return `url#${shortHash(raw)}`;
3050
- }
3051
- }
3052
- function redactValueDetectors(value) {
3053
- let out = value;
3054
- out = out.replace(JWT_PATTERN, () => REDACTED);
3055
- out = out.replace(URL_PATTERN, (match) => {
3056
- const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
3057
- const core = trailing ? match.slice(0, -trailing.length) : match;
3058
- return `${redactUrl(core)}${trailing}`;
3059
- });
3060
- out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
3061
- out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
3062
- out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
3063
- out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
3064
- if (out.length > MAX_VALUE_LENGTH) {
3065
- out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
3066
- }
3067
- return out;
3068
- }
3069
- function redactValue(value) {
3070
- return redactValueDetectors(value);
3071
- }
3072
- function redactError(error) {
3073
- const safe = new Error(redactValueDetectors(error.message ?? ""));
3074
- safe.name = error.name;
3075
- safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
3076
- return safe;
3077
- }
3078
- function nameTokens(name) {
3079
- return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[\s._-]+/).map((t) => t.toLowerCase()).filter(Boolean);
3080
- }
3081
- function isSensitiveName(name) {
3082
- const tokens = nameTokens(name);
3083
- for (let i = 0;i < tokens.length; i++) {
3084
- const token = tokens[i];
3085
- if (SENSITIVE_NAME_TOKENS.has(token)) {
3086
- return true;
3087
- }
3088
- if (token === "key" || token === "keys") {
3089
- const prev = tokens[i - 1];
3090
- if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
3091
- return true;
3092
- }
3093
- }
3094
- }
3095
- return false;
3096
- }
3097
- function redactProperty(name, value) {
3098
- if (value === undefined || value === null) {
3099
- return;
3100
- }
3101
- if (isSensitiveName(name)) {
3102
- return REDACTED;
3103
- }
3104
- if (typeof value === "boolean" || typeof value === "number") {
3105
- return value;
3630
+ let hex = "";
3631
+ for (const byte of bytes) {
3632
+ hex += byte.toString(16).padStart(2, "0");
3106
3633
  }
3107
- if (typeof value !== "string") {
3108
- return "[OBJECT]";
3634
+ return { id: hex, source: "random" };
3635
+ }
3636
+ function resolveTelemetrySession() {
3637
+ const existing = telemetrySessionSlot.get();
3638
+ if (existing) {
3639
+ return existing;
3109
3640
  }
3110
- return redactValueDetectors(value);
3641
+ const declaredHandle = getConfiguredTelemetrySessionId();
3642
+ const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
3643
+ telemetrySessionSlot.set(resolved);
3644
+ return resolved;
3111
3645
  }
3112
- function redactProperties(properties) {
3113
- const out = {};
3114
- for (const [name, value] of Object.entries(properties)) {
3115
- const redacted = redactProperty(name, value);
3116
- if (redacted !== undefined) {
3117
- out[name] = redacted;
3118
- }
3646
+ function getTelemetrySessionSource() {
3647
+ return resolveTelemetrySession().source;
3648
+ }
3649
+ function getTelemetryOperationId() {
3650
+ const existing = telemetryOperationIdSlot.get();
3651
+ if (existing) {
3652
+ return existing;
3119
3653
  }
3120
- return out;
3654
+ const inboundTraceId = getInboundTraceContext()?.traceId;
3655
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
3656
+ telemetryOperationIdSlot.set(generated);
3657
+ return generated;
3658
+ }
3659
+ // ../common/src/telemetry/global-telemetry-properties.ts
3660
+ var telemetryPropsSlot = singleton("TelemetryDefaultProps");
3661
+ function getGlobalTelemetryProperties() {
3662
+ return telemetryPropsSlot.get();
3121
3663
  }
3122
3664
 
3123
- // ../common/src/telemetry/telemetry-service.ts
3124
- var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
3125
- var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
3126
- var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
3665
+ // ../common/src/telemetry/span-clock.ts
3666
+ function startSpanClock() {
3667
+ const started = performance.now();
3668
+ return {
3669
+ startedAt: new Date(performance.timeOrigin + started),
3670
+ elapsedMs: () => performance.now() - started
3671
+ };
3672
+ }
3127
3673
 
3674
+ // ../common/src/telemetry/telemetry-service.ts
3128
3675
  class TelemetryService {
3129
3676
  telemetryProvider;
3130
3677
  contextStorage;
@@ -3144,36 +3691,39 @@ class TelemetryService {
3144
3691
  this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
3145
3692
  }
3146
3693
  trackEvent(name, properties) {
3147
- const context = this.getCurrentContext();
3148
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3149
- this.telemetryProvider.trackEvent(name, enrichedProperties);
3694
+ this.telemetryProvider.trackEvent({
3695
+ name: redactSpanName(name),
3696
+ properties: this.enrichProperties(properties),
3697
+ ...this.leafCorrelation()
3698
+ });
3150
3699
  }
3151
- trackException(error, properties) {
3152
- const context = this.getCurrentContext();
3153
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3154
- this.telemetryProvider.trackException(redactError(error), enrichedProperties);
3700
+ trackException(error, properties, context) {
3701
+ this.telemetryProvider.trackException({
3702
+ error: redactError(error),
3703
+ properties: this.enrichProperties(properties),
3704
+ ...this.leafCorrelation(context)
3705
+ });
3155
3706
  }
3156
3707
  async trackRequest(name, fn, properties) {
3157
- const parentContext = this.getCurrentContext();
3708
+ const parentContext = this.getActiveContext();
3158
3709
  const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
3159
3710
  const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
3711
+ const clock = startSpanClock();
3160
3712
  const context = {
3161
3713
  operationId,
3162
3714
  ...parentId !== undefined ? { parentId } : {},
3163
- id: this.generateId()
3715
+ id: this.generateId(),
3716
+ startedAt: clock.startedAt
3164
3717
  };
3165
- const startTime = performance.now();
3166
3718
  try {
3167
3719
  const result = await this.contextStorage.run(context, fn);
3168
- const durationMs = performance.now() - startTime;
3169
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3170
- await this.telemetryProvider.trackRequest(name, durationMs, true, enrichedProperties);
3720
+ const durationMs = clock.elapsedMs();
3721
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, true, properties, context));
3171
3722
  return result;
3172
3723
  } catch (error) {
3173
- const durationMs = performance.now() - startTime;
3724
+ const durationMs = clock.elapsedMs();
3174
3725
  const err = error instanceof Error ? error : new Error(String(error));
3175
- const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, context);
3176
- await this.telemetryProvider.trackRequest(name, durationMs, false, enrichedProperties);
3726
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, context));
3177
3727
  throw error;
3178
3728
  }
3179
3729
  }
@@ -3182,8 +3732,7 @@ class TelemetryService {
3182
3732
  operationId: this.operationId ?? getTelemetryOperationId(),
3183
3733
  id: this.generateId()
3184
3734
  };
3185
- const enrichedProperties = this.enrichPropertiesWithContext(properties, requestContext);
3186
- this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
3735
+ this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, success, properties, requestContext));
3187
3736
  }
3188
3737
  createRequestContext() {
3189
3738
  const operationId = this.operationId ?? getTelemetryOperationId();
@@ -3191,7 +3740,8 @@ class TelemetryService {
3191
3740
  return {
3192
3741
  operationId,
3193
3742
  ...parentId !== undefined ? { parentId } : {},
3194
- id: this.generateId()
3743
+ id: this.generateId(),
3744
+ startedAt: startSpanClock().startedAt
3195
3745
  };
3196
3746
  }
3197
3747
  inboundParentIdFor(operationId) {
@@ -3202,58 +3752,84 @@ class TelemetryService {
3202
3752
  return this.contextStorage.run(context, fn);
3203
3753
  }
3204
3754
  createDependencyContext() {
3205
- const parentContext = this.getCurrentContext();
3755
+ const parentContext = this.getActiveContext();
3206
3756
  if (!parentContext) {
3207
3757
  return;
3208
3758
  }
3209
3759
  return {
3210
3760
  operationId: parentContext.operationId,
3211
3761
  parentId: parentContext.id,
3212
- id: this.generateId()
3762
+ id: this.generateId(),
3763
+ startedAt: startSpanClock().startedAt
3213
3764
  };
3214
3765
  }
3215
3766
  trackDependencyResult(name, type, durationMs, success, properties, context, resultCode) {
3216
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3217
- this.telemetryProvider.trackDependency(redactValue(name), type, durationMs, success, enrichedProperties, resultCode);
3767
+ this.telemetryProvider.trackDependency({
3768
+ ...this.spanFor(redactHttpDependencyName(name), durationMs, success, properties, context),
3769
+ type,
3770
+ ...resultCode !== undefined ? { resultCode } : {}
3771
+ });
3218
3772
  }
3219
3773
  async trackDependencyOperation(name, type, fn, properties) {
3220
- const parentContext = this.getCurrentContext();
3774
+ const clock = startSpanClock();
3775
+ const parentContext = this.getActiveContext();
3221
3776
  const childContext = parentContext !== undefined ? {
3222
3777
  operationId: parentContext.operationId,
3223
3778
  parentId: parentContext.id,
3224
- id: this.generateId()
3225
- } : this.createRequestContext();
3226
- const startTime = performance.now();
3779
+ id: this.generateId(),
3780
+ startedAt: clock.startedAt
3781
+ } : {
3782
+ ...this.createRequestContext(),
3783
+ startedAt: clock.startedAt
3784
+ };
3227
3785
  try {
3228
3786
  const result = await this.contextStorage.run(childContext, fn);
3229
- const durationMs = performance.now() - startTime;
3230
- const enrichedProperties = this.enrichPropertiesWithContext(properties, childContext);
3231
- await this.telemetryProvider.trackDependency(name, type, durationMs, true, enrichedProperties);
3787
+ const durationMs = clock.elapsedMs();
3788
+ await this.telemetryProvider.trackDependency({
3789
+ ...this.spanFor(name, durationMs, true, properties, childContext),
3790
+ type
3791
+ });
3232
3792
  return result;
3233
3793
  } catch (error) {
3234
- const durationMs = performance.now() - startTime;
3794
+ const durationMs = clock.elapsedMs();
3235
3795
  const err = error instanceof Error ? error : new Error(String(error));
3236
- const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, childContext);
3237
- await this.telemetryProvider.trackDependency(name, type, durationMs, false, enrichedProperties);
3796
+ await this.telemetryProvider.trackDependency({
3797
+ ...this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, childContext),
3798
+ type
3799
+ });
3238
3800
  throw error;
3239
3801
  }
3240
3802
  }
3241
- getCurrentContext() {
3803
+ getActiveContext() {
3242
3804
  return this.contextStorage.getContext();
3243
3805
  }
3244
- enrichPropertiesWithContext(properties, context) {
3806
+ leafCorrelation(explicit) {
3807
+ const context = explicit ?? this.getActiveContext();
3808
+ return {
3809
+ operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
3810
+ ...context !== undefined ? { parentId: context.id } : {}
3811
+ };
3812
+ }
3813
+ spanFor(name, durationMs, success, properties, context) {
3814
+ return {
3815
+ name: redactSpanName(name),
3816
+ durationMs,
3817
+ success,
3818
+ properties: this.enrichProperties(properties),
3819
+ operationId: context.operationId,
3820
+ ...context.parentId !== undefined ? { parentId: context.parentId } : {},
3821
+ id: context.id,
3822
+ ...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
3823
+ };
3824
+ }
3825
+ enrichProperties(properties) {
3245
3826
  const globalProperties = getGlobalTelemetryProperties();
3246
3827
  const enriched = {
3247
3828
  ...getExecutionContextTelemetryProperties(),
3248
3829
  ...globalProperties,
3249
3830
  ...this.defaultProperties,
3250
3831
  ...redactProperties(properties ?? {}),
3251
- [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
3252
- ...context ? {
3253
- [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
3254
- ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
3255
- [TELEMETRY_SPAN_ID_PROPERTY]: context.id
3256
- } : {}
3832
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
3257
3833
  };
3258
3834
  return enriched;
3259
3835
  }
@@ -3270,6 +3846,81 @@ class TelemetryService {
3270
3846
  return hex;
3271
3847
  }
3272
3848
  }
3849
+ // ../common/src/timings.ts
3850
+ var TIMINGS_ENV_VAR = "UIP_TIMINGS";
3851
+ function createStorage2() {
3852
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
3853
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
3854
+ return {
3855
+ getStore: () => {
3856
+ return;
3857
+ },
3858
+ run: (_store, fn) => fn()
3859
+ };
3860
+ }
3861
+ return new mod.AsyncLocalStorage;
3862
+ }
3863
+ var storageSlot = singleton("TimingStorage");
3864
+ var stateSlot = singleton("Timings");
3865
+ var rootStartedSlot = singleton("TimingsRootStarted");
3866
+ var longLivedHostSlot = singleton("TimingsLongLivedHost");
3867
+ var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
3868
+ function newState(baseline) {
3869
+ return { baseline, httpMs: 0, httpCalls: 0 };
3870
+ }
3871
+ function getState() {
3872
+ const scoped = storage.getStore();
3873
+ if (scoped) {
3874
+ return scoped;
3875
+ }
3876
+ const pinned = livePinnedState();
3877
+ if (pinned !== undefined) {
3878
+ return pinned;
3879
+ }
3880
+ return newState(processStartIsInvocationStart() ? 0 : performance.now());
3881
+ }
3882
+ function livePinnedState() {
3883
+ const pinned = stateSlot.get();
3884
+ return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
3885
+ }
3886
+ function processStartIsInvocationStart() {
3887
+ return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
3888
+ }
3889
+ function timingsEnabled() {
3890
+ if (typeof process === "undefined") {
3891
+ return false;
3892
+ }
3893
+ const value = process.env?.[TIMINGS_ENV_VAR];
3894
+ if (value === undefined) {
3895
+ return false;
3896
+ }
3897
+ const normalized = value.trim().toLowerCase();
3898
+ return normalized === "1" || normalized === "true";
3899
+ }
3900
+ function recordExitCode(exitCode) {
3901
+ if (!timingsEnabled()) {
3902
+ return;
3903
+ }
3904
+ getState().exitCode = exitCode;
3905
+ }
3906
+ function invocationStartedAt() {
3907
+ return new Date(performance.timeOrigin + getState().baseline);
3908
+ }
3909
+ function invocationElapsedMs() {
3910
+ return performance.now() - getState().baseline;
3911
+ }
3912
+ function markCommandStart() {
3913
+ if (!timingsEnabled()) {
3914
+ return;
3915
+ }
3916
+ getState().commandStart = performance.now();
3917
+ }
3918
+ function recordCommandDuration(durationMs) {
3919
+ if (!timingsEnabled()) {
3920
+ return;
3921
+ }
3922
+ getState().commandMs = durationMs;
3923
+ }
3273
3924
  // ../common/src/telemetry/proxy-http-agent.ts
3274
3925
  var slot = singleton("ProxyAuthHttpsAgent");
3275
3926
 
@@ -3290,6 +3941,9 @@ function getGlobalTelemetryInstance() {
3290
3941
  }
3291
3942
  return;
3292
3943
  }
3944
+ function setGlobalTelemetryInstance(instance) {
3945
+ telemetryInstanceSlot.set(instance);
3946
+ }
3293
3947
  var _localTelemetryInstance;
3294
3948
  function getTelemetryInstance() {
3295
3949
  const global = getGlobalTelemetryInstance();
@@ -3297,6 +3951,7 @@ function getTelemetryInstance() {
3297
3951
  return global;
3298
3952
  if (!_localTelemetryInstance) {
3299
3953
  _localTelemetryInstance = new TelemetryService(new LoggerTelemetryProvider, new NodeContextStorage);
3954
+ setGlobalTelemetryInstance(_localTelemetryInstance);
3300
3955
  }
3301
3956
  return _localTelemetryInstance;
3302
3957
  }
@@ -3309,6 +3964,14 @@ var telemetry = new Proxy({}, {
3309
3964
  });
3310
3965
 
3311
3966
  // ../common/src/formatter.ts
3967
+ var ANSI_STYLES = {
3968
+ red: "\x1B[31m",
3969
+ dim: "\x1B[2m"
3970
+ };
3971
+ var ANSI_RESET = "\x1B[0m";
3972
+ function styleLine(line, style) {
3973
+ return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
3974
+ }
3312
3975
  var CLI_ERROR_CODES = [
3313
3976
  "invalid_argument",
3314
3977
  "authentication_required",
@@ -3380,23 +4043,6 @@ function derivePaginationHasMore(returned, limit, offset, total, nextPage) {
3380
4043
  }
3381
4044
  return (offset ?? 0) + returned < total;
3382
4045
  }
3383
-
3384
- class SuccessOutput {
3385
- Result = RESULTS.Success;
3386
- Code;
3387
- Data;
3388
- Pagination;
3389
- Instructions;
3390
- Log;
3391
- constructor(code, data) {
3392
- this.Code = code;
3393
- this.Data = data;
3394
- const logPath = getLogFilePath();
3395
- if (logPath) {
3396
- this.Log = logPath;
3397
- }
3398
- }
3399
- }
3400
4046
  function escapeNonAscii(jsonText) {
3401
4047
  return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
3402
4048
  const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
@@ -3461,19 +4107,45 @@ function toPascalCaseKey(key) {
3461
4107
  const lowerCamelKey = toLowerCamelCaseKey(key);
3462
4108
  return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
3463
4109
  }
3464
- function toPascalCaseData(value) {
4110
+ function collectVerbatimRefs(value, into) {
4111
+ if (typeof value !== "object" || value === null)
4112
+ return;
4113
+ if (into.has(value))
4114
+ return;
4115
+ into.add(value);
4116
+ for (const nested of Array.isArray(value) ? value : Object.values(value)) {
4117
+ collectVerbatimRefs(nested, into);
4118
+ }
4119
+ }
4120
+ function toPascalCaseData(value, verbatimKeys, subtrees) {
4121
+ if (subtrees?.mode === "skip" && typeof value === "object" && value !== null && subtrees.refs.has(value)) {
4122
+ return value;
4123
+ }
3465
4124
  if (Array.isArray(value))
3466
- return value.map(toPascalCaseData);
4125
+ return value.map((entry) => toPascalCaseData(entry, verbatimKeys, subtrees));
3467
4126
  if (!isPlainRecord(value))
3468
4127
  return value;
3469
4128
  const result = {};
3470
4129
  for (const [key, nestedValue] of Object.entries(value)) {
3471
- result[toPascalCaseKey(key)] = toPascalCaseData(nestedValue);
4130
+ const pascalKey = toPascalCaseKey(key);
4131
+ if (verbatimKeys?.has(pascalKey)) {
4132
+ result[pascalKey] = nestedValue;
4133
+ if (subtrees?.mode === "collect") {
4134
+ collectVerbatimRefs(nestedValue, subtrees.refs);
4135
+ }
4136
+ continue;
4137
+ }
4138
+ result[pascalKey] = toPascalCaseData(nestedValue, verbatimKeys, subtrees);
3472
4139
  }
3473
4140
  return result;
3474
4141
  }
3475
- function normalizeDataKeys(data) {
3476
- return toPascalCaseData(data);
4142
+ function normalizeDataKeys(data, verbatimKeys, subtrees) {
4143
+ return toPascalCaseData(data, verbatimKeys, subtrees);
4144
+ }
4145
+ function toVerbatimKeySet(preserve) {
4146
+ if (!Array.isArray(preserve))
4147
+ return;
4148
+ return new Set(preserve.map(toPascalCaseKey));
3477
4149
  }
3478
4150
  function normalizeOutputKeys(data) {
3479
4151
  const result = {};
@@ -3483,7 +4155,7 @@ function normalizeOutputKeys(data) {
3483
4155
  }
3484
4156
  return result;
3485
4157
  }
3486
- function printOutput(data, format = "json", logFn, asciiSafe = false) {
4158
+ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowStyle) {
3487
4159
  if (!data) {
3488
4160
  logFn("Empty response object. No data to display.");
3489
4161
  return;
@@ -3518,7 +4190,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
3518
4190
  if (hasData && !(rows !== null && rows.length === 0)) {
3519
4191
  const logValue = data.Log;
3520
4192
  if (rows !== null) {
3521
- printResizableTable(rows, logFn, logValue);
4193
+ printResizableTable(rows, logFn, logValue, undefined, tableRowStyle);
3522
4194
  } else {
3523
4195
  printVerticalTable(data.Data, logFn, logValue);
3524
4196
  }
@@ -3529,10 +4201,11 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
3529
4201
  }
3530
4202
  }
3531
4203
  }
3532
- function logOutput(data, format = "json") {
4204
+ function logOutput(data, format = "json", tableRowStyle) {
3533
4205
  const sink = getOutputSink();
4206
+ const styleFn = sink.capabilities.isInteractive && sink.capabilities.supportsColor ? tableRowStyle : undefined;
3534
4207
  printOutput(data, format, (msg) => sink.writeOut(`${msg}
3535
- `), needsAsciiSafeJson(sink));
4208
+ `), needsAsciiSafeJson(sink), styleFn);
3536
4209
  }
3537
4210
  function cellToString(val) {
3538
4211
  return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
@@ -3546,7 +4219,7 @@ function wrapText(text, width) {
3546
4219
  }
3547
4220
  return lines;
3548
4221
  }
3549
- function printTable(data, logFn, externalLogValue) {
4222
+ function printTable(data, logFn, externalLogValue, tableRowStyle) {
3550
4223
  if (data.length === 0)
3551
4224
  return;
3552
4225
  const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
@@ -3556,7 +4229,7 @@ function printTable(data, logFn, externalLogValue) {
3556
4229
  logFn(keys.map((_, i) => "-".repeat(maxWidths[i])).join("-|-"));
3557
4230
  data.forEach((item) => {
3558
4231
  const row = keys.map((key, i) => cellToString(item[key]).padEnd(maxWidths[i])).join(" | ");
3559
- logFn(row);
4232
+ logFn(styleLine(row, tableRowStyle?.(item)));
3560
4233
  });
3561
4234
  if (externalLogValue) {
3562
4235
  logFn("");
@@ -3599,14 +4272,14 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
3599
4272
  logFn(`Log: ${externalLogValue}`);
3600
4273
  }
3601
4274
  }
3602
- function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth) {
4275
+ function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
3603
4276
  if (data.length === 0)
3604
4277
  return;
3605
4278
  const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
3606
4279
  if (keys.length === 0)
3607
4280
  return;
3608
4281
  if (!process.stdout.isTTY) {
3609
- printTable(data, logFn, externalLogValue);
4282
+ printTable(data, logFn, externalLogValue, tableRowStyle);
3610
4283
  return;
3611
4284
  }
3612
4285
  const naturalWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
@@ -3614,7 +4287,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
3614
4287
  const totalWidth = naturalWidths.reduce((a, b) => a + b, 0) + separatorTotal;
3615
4288
  const termWidth = availableWidth ?? (process.stdout.columns || 120);
3616
4289
  if (totalWidth <= termWidth) {
3617
- printTable(data, logFn, externalLogValue);
4290
+ printTable(data, logFn, externalLogValue, tableRowStyle);
3618
4291
  return;
3619
4292
  }
3620
4293
  const overflow = totalWidth - termWidth;
@@ -3660,6 +4333,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
3660
4333
  logFn(header);
3661
4334
  logFn(keys.map((_, i) => "-".repeat(finalWidths[i])).join("-|-"));
3662
4335
  data.forEach((item) => {
4336
+ const style = tableRowStyle?.(item);
3663
4337
  const cellLines = keys.map((key, i) => wrapText(cellToString(item[key]), finalWidths[i]));
3664
4338
  const lineCount = Math.max(...cellLines.map((l) => l.length));
3665
4339
  for (let line = 0;line < lineCount; line++) {
@@ -3667,7 +4341,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
3667
4341
  const val = line < cellLines[i].length ? cellLines[i][line] : "";
3668
4342
  return val.padEnd(finalWidths[i]);
3669
4343
  }).join(" | ");
3670
- logFn(row);
4344
+ logFn(styleLine(row, style));
3671
4345
  }
3672
4346
  });
3673
4347
  if (externalLogValue) {
@@ -3811,30 +4485,36 @@ var OutputFormatter;
3811
4485
  ((OutputFormatter) => {
3812
4486
  function success(data, options) {
3813
4487
  data.Log ??= getLogFilePath() || undefined;
3814
- const normalize = !options?.preserveDataKeys;
4488
+ const normalize = options?.preserveDataKeys !== true;
4489
+ const verbatim = toVerbatimKeySet(options?.preserveDataKeys);
4490
+ const subtrees = verbatim && {
4491
+ refs: new Set,
4492
+ mode: "collect"
4493
+ };
3815
4494
  if (normalize) {
3816
- data.Data = normalizeDataKeys(data.Data);
4495
+ data.Data = normalizeDataKeys(data.Data, verbatim, subtrees);
3817
4496
  }
3818
4497
  const filter = getOutputFilter();
3819
4498
  if (filter) {
3820
4499
  const filtered = applyFilter(data.Data, filter);
3821
- data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
4500
+ data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
3822
4501
  }
3823
- logOutput(normalizeOutputKeys(data), getOutputFormat());
4502
+ logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
3824
4503
  }
3825
4504
  OutputFormatter.success = success;
3826
4505
  function error(data) {
3827
4506
  data.Log ??= getLogFilePath() || undefined;
3828
4507
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
3829
4508
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
3830
- process.exitCode = EXIT_CODES[data.Result] ?? 1;
4509
+ const exitCode = EXIT_CODES[data.Result] ?? 1;
4510
+ setExitCode(exitCode);
3831
4511
  recordCommandFailureTelemetry({
3832
4512
  result: data.Result,
3833
4513
  errorCode: data.ErrorCode,
3834
4514
  retry: data.Retry,
3835
4515
  message: data.Message,
3836
4516
  context: data.Context,
3837
- exitCode: process.exitCode,
4517
+ exitCode,
3838
4518
  errorClass: data.TelemetryErrorClass,
3839
4519
  terminalOutcome: data.TelemetryTerminalOutcome,
3840
4520
  terminalSignal: data.TelemetryTerminalSignal
@@ -3911,6 +4591,34 @@ var OutputFormatter;
3911
4591
  OutputFormatter.formatToString = formatToString;
3912
4592
  })(OutputFormatter ||= {});
3913
4593
 
4594
+ // ../../node_modules/commander/esm.mjs
4595
+ var import__ = __toESM(require_commander(), 1);
4596
+ var {
4597
+ program,
4598
+ createCommand,
4599
+ createArgument,
4600
+ createOption,
4601
+ CommanderError,
4602
+ InvalidArgumentError,
4603
+ InvalidOptionArgumentError,
4604
+ Command,
4605
+ Argument,
4606
+ Option,
4607
+ Help
4608
+ } = import__.default;
4609
+
4610
+ // ../common/src/preview.ts
4611
+ var previewSlot = singleton("PreviewBuild");
4612
+ function isPreviewBuild() {
4613
+ return previewSlot.get(false) ?? false;
4614
+ }
4615
+ Command.prototype.previewCommand = function(nameAndArgs, opts) {
4616
+ if (isPreviewBuild()) {
4617
+ return this.command(nameAndArgs, opts);
4618
+ }
4619
+ return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
4620
+ };
4621
+
3914
4622
  // ../common/src/telemetry/command-attribution.ts
3915
4623
  var LEGACY_SKILL_NAMESPACE = "uipath:";
3916
4624
  var MAX_SKILL_NAME_LENGTH = 80;
@@ -4064,6 +4772,57 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
4064
4772
  };
4065
4773
  }
4066
4774
 
4775
+ // ../common/src/telemetry/command-name.ts
4776
+ var TELEMETRY_COMMAND_ROOT = "uip";
4777
+ function commandTelemetryName(parts) {
4778
+ const tokens = [];
4779
+ for (const part of parts) {
4780
+ const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== TELEMETRY_COMMAND_ROOT);
4781
+ if (pieces.every(isCommandToken)) {
4782
+ tokens.push(...pieces);
4783
+ continue;
4784
+ }
4785
+ tokens.push(UNKNOWN_TOKEN);
4786
+ }
4787
+ return [TELEMETRY_COMMAND_ROOT, ...tokens].join(".");
4788
+ }
4789
+ var COMMAND_TOKEN_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
4790
+ var MAX_COMMAND_TOKEN_LENGTH = 32;
4791
+ var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
4792
+ function isCommandToken(token) {
4793
+ return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token) && !/^\d+$/.test(token);
4794
+ }
4795
+ var UNKNOWN_TOKEN = "<unknown>";
4796
+
4797
+ // ../common/src/telemetry/invocation-request.ts
4798
+ var requestContextSlot = singleton("TelemetryInvocationRequestContext");
4799
+ function activeContext() {
4800
+ return telemetry.getActiveContext?.();
4801
+ }
4802
+ function runWithInvocationRequest(fn) {
4803
+ const context = telemetry.createRequestContext();
4804
+ context.startedAt = invocationStartedAt();
4805
+ requestContextSlot.set(context);
4806
+ return telemetry.runWithContext(context, fn);
4807
+ }
4808
+ function ensureInvocationRequestScope(fn) {
4809
+ if (activeContext() !== undefined) {
4810
+ return fn();
4811
+ }
4812
+ const kept = requestContextSlot.get();
4813
+ return kept === undefined ? runWithInvocationRequest(fn) : telemetry.runWithContext(kept, fn);
4814
+ }
4815
+ function getInvocationRequestContext() {
4816
+ return activeContext() ?? requestContextSlot.get();
4817
+ }
4818
+ function emitInvocationRequest(name, success, properties) {
4819
+ const context = getInvocationRequestContext();
4820
+ telemetry.trackRequestResult(name, invocationElapsedMs(), success, properties, context);
4821
+ if (context !== undefined && requestContextSlot.get() === context) {
4822
+ requestContextSlot.clear();
4823
+ }
4824
+ }
4825
+
4067
4826
  // ../common/src/trackedAction.ts
4068
4827
  var pollSignalSlot = singleton("PollSignal");
4069
4828
  var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
@@ -4071,28 +4830,74 @@ var retryHintValues = new Set(RETRY_HINTS);
4071
4830
  var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
4072
4831
  var processContext = {
4073
4832
  exit: (code) => {
4074
- process.exitCode = code;
4833
+ recordExitCode(code);
4834
+ setExitCode(code);
4075
4835
  },
4076
4836
  get pollSignal() {
4077
4837
  return pollSignalSlot.get();
4078
4838
  }
4079
4839
  };
4840
+ var TELEMETRY_ARG_VALUE_WITHHELD = "<provided>";
4841
+ var TELEMETRY_ARG_VALUE_DEFAULTED = "<default>";
4842
+ function recordableArgValue(value, choices) {
4843
+ if (typeof value === "boolean" || typeof value === "number") {
4844
+ return value;
4845
+ }
4846
+ if (choices && choices.length > 0) {
4847
+ if (typeof value === "string" && choices.includes(value)) {
4848
+ return value;
4849
+ }
4850
+ if (Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string" && choices.includes(entry))) {
4851
+ return value.join(",");
4852
+ }
4853
+ }
4854
+ return TELEMETRY_ARG_VALUE_WITHHELD;
4855
+ }
4080
4856
  function extractCommandParams(cmd) {
4081
4857
  const params = {};
4082
- const add = (name, value) => {
4083
- if (name && value !== undefined) {
4084
- params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = value;
4085
- }
4086
- };
4858
+ forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
4859
+ const recordable = recordableArgValue(value, choices);
4860
+ params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
4861
+ });
4862
+ return params;
4863
+ }
4864
+ function isDefaultedOption(cmd, name) {
4865
+ const source = cmd.getOptionValueSource?.(name);
4866
+ return source === "default" || source === "implied";
4867
+ }
4868
+ function isDefaultedPositional(cmd, index) {
4869
+ return index >= (cmd.args?.length ?? 0);
4870
+ }
4871
+ function forEachSuppliedArgument(cmd, visit) {
4087
4872
  const registered = cmd.registeredArguments ?? [];
4088
4873
  const processed = cmd.processedArgs ?? [];
4089
4874
  for (let i = 0;i < registered.length; i++) {
4090
- add(registered[i].name(), processed[i]);
4875
+ const name = registered[i].name();
4876
+ if (name && processed[i] !== undefined) {
4877
+ visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
4878
+ }
4879
+ }
4880
+ const choicesByAttribute = new Map;
4881
+ for (const option of cmd.options) {
4882
+ choicesByAttribute.set(option.attributeName(), option.argChoices);
4091
4883
  }
4092
4884
  for (const [key, value] of Object.entries(cmd.opts())) {
4093
- add(key, value);
4885
+ if (key && value !== undefined) {
4886
+ visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
4887
+ }
4094
4888
  }
4095
- return params;
4889
+ }
4890
+ function withheldArgumentValues(cmd) {
4891
+ const values = [];
4892
+ forEachSuppliedArgument(cmd, (_name, value, choices, defaulted) => {
4893
+ if (defaulted) {
4894
+ return;
4895
+ }
4896
+ if (recordableArgValue(value, choices) === TELEMETRY_ARG_VALUE_WITHHELD) {
4897
+ values.push(value);
4898
+ }
4899
+ });
4900
+ return values;
4096
4901
  }
4097
4902
  function deriveCommandPath(cmd) {
4098
4903
  const parts = [];
@@ -4107,7 +4912,7 @@ function deriveCommandPath(cmd) {
4107
4912
  if (parts.length > 1) {
4108
4913
  parts.shift();
4109
4914
  }
4110
- return ["uip", ...parts.filter((p) => p !== "uip")].join(".");
4915
+ return commandTelemetryName(parts);
4111
4916
  }
4112
4917
  function isCliErrorCode(value) {
4113
4918
  return typeof value === "string" && cliErrorCodeValues.has(value);
@@ -4147,68 +4952,77 @@ Command.prototype.trackedAction = function(context, fn, properties) {
4147
4952
  });
4148
4953
  const telemetryName = deriveCommandPath(command);
4149
4954
  const props = typeof properties === "function" ? properties(...args) : properties;
4150
- const requestContext = telemetry.createRequestContext();
4151
- const startTime = performance.now();
4152
- let errorMessage;
4153
- let fallbackExitCode = EXIT_CODES.Success;
4154
- clearRecordedCommandFailureTelemetry();
4155
- const [error] = await catchError2(telemetry.runWithContext(requestContext, () => {
4156
- const violation = implicitLimitViolation(command);
4157
- if (violation) {
4158
- return Promise.reject(violation);
4159
- }
4160
- return fn(...args);
4161
- }));
4162
- if (error) {
4163
- errorMessage = error instanceof Error ? error.message : String(error);
4164
- logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
4165
- const typed = error;
4166
- const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
4167
- const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
4168
- const finalResult = customResult ?? RESULTS.Failure;
4169
- const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
4170
- const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
4171
- const typedRetry = typed.retry ?? typed.Retry;
4172
- const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
4173
- const typedContext = typed.context ?? typed.Context;
4174
- const customContext = isErrorContext(typedContext) ? typedContext : undefined;
4175
- const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
4176
- fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
4177
- OutputFormatter.error({
4178
- Result: finalResult,
4179
- ...customErrorCode ? { ErrorCode: customErrorCode } : {},
4180
- Message: errorMessage,
4181
- Instructions: customInstructions ?? commandHelpHint(telemetryName),
4182
- ...customRetry ? { Retry: customRetry } : {},
4183
- ...customContext ? { Context: customContext } : {}
4955
+ markCommandStart();
4956
+ const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
4957
+ try {
4958
+ const startTime = performance.now();
4959
+ let errorMessage;
4960
+ let fallbackExitCode = EXIT_CODES.Success;
4961
+ clearRecordedCommandFailureTelemetry();
4962
+ const [error] = await catchError(ensureInvocationRequestScope(() => {
4963
+ const violation = implicitLimitViolation(command);
4964
+ if (violation) {
4965
+ return Promise.reject(violation);
4966
+ }
4967
+ return fn(...args);
4968
+ }));
4969
+ if (error) {
4970
+ errorMessage = error instanceof Error ? error.message : String(error);
4971
+ logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
4972
+ const typed = error;
4973
+ const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
4974
+ const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
4975
+ const finalResult = customResult ?? RESULTS.Failure;
4976
+ const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
4977
+ const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
4978
+ const typedRetry = typed.retry ?? typed.Retry;
4979
+ const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
4980
+ const typedContext = typed.context ?? typed.Context;
4981
+ const customContext = isErrorContext(typedContext) ? typedContext : undefined;
4982
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
4983
+ fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
4984
+ OutputFormatter.error({
4985
+ Result: finalResult,
4986
+ ...customErrorCode ? { ErrorCode: customErrorCode } : {},
4987
+ Message: errorMessage,
4988
+ Instructions: customInstructions ?? commandHelpHint(telemetryName),
4989
+ ...customRetry ? { Retry: customRetry } : {},
4990
+ ...customContext ? { Context: customContext } : {}
4991
+ });
4992
+ context.exit(fallbackExitCode);
4993
+ }
4994
+ const durationMs = performance.now() - startTime;
4995
+ recordCommandDuration(durationMs);
4996
+ const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
4997
+ const recordedFailure = takeRecordedCommandFailureTelemetry();
4998
+ const success = !error && exitCode === 0;
4999
+ const terminalTelemetry = buildCommandTerminalTelemetryProperties({
5000
+ error,
5001
+ exitCode,
5002
+ recordedFailure,
5003
+ pollSignal: context.pollSignal
4184
5004
  });
4185
- context.exit(fallbackExitCode);
4186
- }
4187
- const durationMs = performance.now() - startTime;
4188
- const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
4189
- const recordedFailure = takeRecordedCommandFailureTelemetry();
4190
- const success = !error && exitCode === 0;
4191
- const terminalTelemetry = buildCommandTerminalTelemetryProperties({
4192
- error,
4193
- exitCode,
4194
- recordedFailure,
4195
- pollSignal: context.pollSignal
4196
- });
4197
- const commandParams = extractCommandParams(command);
4198
- if (props) {
4199
- for (const key of Object.keys(props)) {
4200
- delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
4201
- }
4202
- }
4203
- const baseProperties = redactProperties({
4204
- ...commandParams,
4205
- ...props,
4206
- ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
4207
- command: "true",
4208
- ...terminalTelemetry,
4209
- ...errorMessage ? { errorMessage } : {}
4210
- });
4211
- telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
5005
+ if (terminalTelemetry.error_class === "internal" && error) {
5006
+ telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { command_name: telemetryName }, getInvocationRequestContext());
5007
+ }
5008
+ const commandParams = extractCommandParams(command);
5009
+ if (props) {
5010
+ for (const key of Object.keys(props)) {
5011
+ delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
5012
+ }
5013
+ }
5014
+ const baseProperties = redactProperties({
5015
+ ...commandParams,
5016
+ ...props,
5017
+ ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
5018
+ command: "true",
5019
+ ...terminalTelemetry,
5020
+ ...errorMessage ? { errorMessage } : {}
5021
+ });
5022
+ emitInvocationRequest(telemetryName, success, baseProperties);
5023
+ } finally {
5024
+ releaseSuppliedArgumentValues(supplied);
5025
+ }
4212
5026
  });
4213
5027
  };
4214
5028
 
@@ -4269,14 +5083,20 @@ var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most
4269
5083
  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.";
4270
5084
  var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
4271
5085
  var LOCAL_PERMISSION_MESSAGE_PATTERN = /\b(EACCES|EPERM|EROFS)\b/;
4272
- function localPermissionInstructions(code, path) {
4273
- const target = path !== undefined ? `'${path}'` : "a local file or resource";
5086
+ function localPermissionInstructions(code, path2) {
5087
+ const target = path2 !== undefined ? `'${path2}'` : "a local file or resource";
4274
5088
  if (code === "EROFS") {
4275
5089
  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.";
4276
5090
  }
4277
5091
  const remedy = process.platform === "win32" ? "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.";
4278
5092
  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}`;
4279
5093
  }
5094
+ function carriedInstructions(error) {
5095
+ if (!error || typeof error !== "object")
5096
+ return;
5097
+ const e = error;
5098
+ return typeof e.instructions === "string" ? e.instructions : undefined;
5099
+ }
4280
5100
  function describeConnectivityError(error) {
4281
5101
  for (const cur of walkErrorGraph(error)) {
4282
5102
  const code = typeof cur.code === "string" ? cur.code : undefined;
@@ -4306,12 +5126,12 @@ function describePermissionError(error) {
4306
5126
  const code = matchLocalPermissionCode(cur.code, message);
4307
5127
  if (!code)
4308
5128
  continue;
4309
- const path = localPermissionPath(cur.path, message);
5129
+ const path2 = localPermissionPath(cur.path, message);
4310
5130
  return {
4311
5131
  code,
4312
5132
  message: message ?? code,
4313
- ...path !== undefined ? { path } : {},
4314
- instructions: localPermissionInstructions(code, path)
5133
+ ...path2 !== undefined ? { path: path2 } : {},
5134
+ instructions: localPermissionInstructions(code, path2)
4315
5135
  };
4316
5136
  }
4317
5137
  return;
@@ -4323,9 +5143,9 @@ function matchLocalPermissionCode(code, message) {
4323
5143
  const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
4324
5144
  return match ? match[1] : undefined;
4325
5145
  }
4326
- function localPermissionPath(path, message) {
4327
- if (typeof path === "string")
4328
- return path;
5146
+ function localPermissionPath(path2, message) {
5147
+ if (typeof path2 === "string")
5148
+ return path2;
4329
5149
  return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
4330
5150
  }
4331
5151
  function* walkErrorGraph(error) {
@@ -4434,10 +5254,10 @@ async function extractErrorDetails(error, options) {
4434
5254
  let parsedBody;
4435
5255
  const textFn = response?.text?.bind(response);
4436
5256
  if (textFn) {
4437
- const [bodyError, body] = await catchError2((async () => textFn())());
5257
+ const [bodyError, body] = await catchError((async () => textFn())());
4438
5258
  if (!bodyError && body) {
4439
5259
  rawBody = body;
4440
- const [parseError, parsed] = catchError2(() => JSON.parse(body));
5260
+ const [parseError, parsed] = catchError(() => JSON.parse(body));
4441
5261
  if (!parseError && parsed && typeof parsed === "object") {
4442
5262
  parsedBody = parsed;
4443
5263
  if (parsedBody.errors && typeof parsedBody.errors === "object") {
@@ -4540,7 +5360,7 @@ async function extractErrorDetails(error, options) {
4540
5360
  } else if (typeof err.message === "string") {
4541
5361
  details = err.message;
4542
5362
  } else {
4543
- details = String(error);
5363
+ details = describeThrownValue(error);
4544
5364
  }
4545
5365
  const context = {};
4546
5366
  if (status) {
@@ -4644,6 +5464,204 @@ function requireConfirmation(flags, operation) {
4644
5464
  // ../common/src/console-guard.ts
4645
5465
  var guardInstalledSlot = singleton("ConsoleGuardInstalled");
4646
5466
  var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
5467
+ // ../common/src/entity-name-rules.ts
5468
+ var RESERVED_SQL_KEYWORDS_LOWER = new Set(["group", "order"]);
5469
+ var RESERVED_FIELD_NAMES_LOWER = new Set([
5470
+ "id",
5471
+ "createdby",
5472
+ "createtime",
5473
+ "updatedby",
5474
+ "updatetime",
5475
+ "recordowner",
5476
+ "version"
5477
+ ]);
5478
+ var RESERVED_KEYWORDS_LOWER = new Set([
5479
+ "abstract",
5480
+ "as",
5481
+ "base",
5482
+ "bool",
5483
+ "break",
5484
+ "byte",
5485
+ "case",
5486
+ "catch",
5487
+ "char",
5488
+ "checked",
5489
+ "class",
5490
+ "const",
5491
+ "continue",
5492
+ "decimal",
5493
+ "default",
5494
+ "delegate",
5495
+ "do",
5496
+ "double",
5497
+ "else",
5498
+ "enum",
5499
+ "event",
5500
+ "explicit",
5501
+ "extern",
5502
+ "false",
5503
+ "finally",
5504
+ "fixed",
5505
+ "float",
5506
+ "for",
5507
+ "foreach",
5508
+ "goto",
5509
+ "if",
5510
+ "implicit",
5511
+ "in",
5512
+ "int",
5513
+ "interface",
5514
+ "internal",
5515
+ "is",
5516
+ "lock",
5517
+ "long",
5518
+ "namespace",
5519
+ "new",
5520
+ "null",
5521
+ "object",
5522
+ "operator",
5523
+ "out",
5524
+ "override",
5525
+ "params",
5526
+ "private",
5527
+ "protected",
5528
+ "public",
5529
+ "readonly",
5530
+ "ref",
5531
+ "return",
5532
+ "sbyte",
5533
+ "sealed",
5534
+ "short",
5535
+ "sizeof",
5536
+ "stackalloc",
5537
+ "static",
5538
+ "string",
5539
+ "struct",
5540
+ "switch",
5541
+ "this",
5542
+ "throw",
5543
+ "true",
5544
+ "try",
5545
+ "typeof",
5546
+ "uint",
5547
+ "ulong",
5548
+ "unchecked",
5549
+ "unsafe",
5550
+ "ushort",
5551
+ "using",
5552
+ "virtual",
5553
+ "void",
5554
+ "volatile",
5555
+ "while",
5556
+ "addhandler",
5557
+ "addressof",
5558
+ "alias",
5559
+ "and",
5560
+ "andalso",
5561
+ "boolean",
5562
+ "byref",
5563
+ "byval",
5564
+ "call",
5565
+ "cbool",
5566
+ "cbyte",
5567
+ "cchar",
5568
+ "cdate",
5569
+ "cdbl",
5570
+ "cdec",
5571
+ "cint",
5572
+ "clng",
5573
+ "cobj",
5574
+ "csbyte",
5575
+ "cshort",
5576
+ "csng",
5577
+ "cstr",
5578
+ "ctype",
5579
+ "cuint",
5580
+ "culng",
5581
+ "cushort",
5582
+ "date",
5583
+ "declare",
5584
+ "dim",
5585
+ "directcast",
5586
+ "each",
5587
+ "elseif",
5588
+ "end",
5589
+ "endif",
5590
+ "erase",
5591
+ "error",
5592
+ "exit",
5593
+ "friend",
5594
+ "function",
5595
+ "get",
5596
+ "gettype",
5597
+ "getxmlnamespace",
5598
+ "global",
5599
+ "gosub",
5600
+ "goto",
5601
+ "handles",
5602
+ "implements",
5603
+ "imports",
5604
+ "inherits",
5605
+ "integer",
5606
+ "isnot",
5607
+ "let",
5608
+ "lib",
5609
+ "like",
5610
+ "loop",
5611
+ "me",
5612
+ "mod",
5613
+ "module",
5614
+ "mustinherit",
5615
+ "mustoverride",
5616
+ "mybase",
5617
+ "myclass",
5618
+ "narrowing",
5619
+ "next",
5620
+ "not",
5621
+ "nothing",
5622
+ "notinheritable",
5623
+ "notoverridable",
5624
+ "of",
5625
+ "on",
5626
+ "option",
5627
+ "optional",
5628
+ "or",
5629
+ "orelse",
5630
+ "overloads",
5631
+ "overridable",
5632
+ "overrides",
5633
+ "paramarray",
5634
+ "partial",
5635
+ "property",
5636
+ "raiseevent",
5637
+ "redim",
5638
+ "rem",
5639
+ "removehandler",
5640
+ "resume",
5641
+ "select",
5642
+ "set",
5643
+ "shadows",
5644
+ "shared",
5645
+ "single",
5646
+ "step",
5647
+ "stop",
5648
+ "structure",
5649
+ "sub",
5650
+ "synclock",
5651
+ "then",
5652
+ "to",
5653
+ "trycast",
5654
+ "uinteger",
5655
+ "ushort",
5656
+ "variant",
5657
+ "wend",
5658
+ "when",
5659
+ "widening",
5660
+ "with",
5661
+ "withevents",
5662
+ "writeonly",
5663
+ "xor"
5664
+ ]);
4647
5665
  // ../common/src/env-reference.ts
4648
5666
  function resolveEnvReference(value) {
4649
5667
  if (value == null)
@@ -4728,7 +5746,7 @@ function mapPackageMetadataOptions(opts) {
4728
5746
  // ../common/src/packager-tool-import.ts
4729
5747
  var REGISTER_EXPORT = "registerPackagerFactories";
4730
5748
  async function importPackagerTool(specifier) {
4731
- const [importError, mod] = await catchError2(import(specifier));
5749
+ const [importError, mod] = await catchError(import(specifier));
4732
5750
  if (importError)
4733
5751
  return importError;
4734
5752
  const register = mod?.[REGISTER_EXPORT];
@@ -4736,7 +5754,7 @@ async function importPackagerTool(specifier) {
4736
5754
  logger.debug(`'${specifier}' has no '${REGISTER_EXPORT}' export — treating it as a ` + "legacy entry point that registered its factories at import.");
4737
5755
  return;
4738
5756
  }
4739
- const [registerError] = catchError2(() => {
5757
+ const [registerError] = catchError(() => {
4740
5758
  register();
4741
5759
  });
4742
5760
  return registerError;
@@ -4794,10 +5812,13 @@ function mapPollFailure(pollResult, label) {
4794
5812
  [PollOutcome.Interrupted]: `${label} polling was interrupted`,
4795
5813
  [PollOutcome.Aborted]: `${label} polling was aborted`
4796
5814
  };
5815
+ const timedOut = outcome === PollOutcome.Timeout;
4797
5816
  return {
4798
5817
  reason: REASON_BY_OUTCOME[outcome],
4799
5818
  message: messageByOutcome[outcome],
4800
- exitCode: outcome === PollOutcome.Timeout ? 2 : 1
5819
+ exitCode: timedOut ? 2 : 1,
5820
+ errorCode: timedOut ? "timeout" : undefined,
5821
+ retry: timedOut ? "RetryLater" : undefined
4801
5822
  };
4802
5823
  }
4803
5824
  // ../common/src/polling/poll-until.ts
@@ -4853,7 +5874,7 @@ function abortError(signal) {
4853
5874
  return err;
4854
5875
  }
4855
5876
  function interruptibleSleep(ms, signal) {
4856
- return new Promise((resolve, reject) => {
5877
+ return new Promise((resolve2, reject) => {
4857
5878
  if (signal?.aborted) {
4858
5879
  reject(abortError(signal));
4859
5880
  return;
@@ -4866,7 +5887,7 @@ function interruptibleSleep(ms, signal) {
4866
5887
  };
4867
5888
  const timer = setTimeout(() => {
4868
5889
  cleanup();
4869
- resolve();
5890
+ resolve2();
4870
5891
  }, ms);
4871
5892
  if (signal) {
4872
5893
  onAbort = () => {
@@ -4932,7 +5953,7 @@ async function handlePollError(error, errorSource, cfg, state) {
4932
5953
  state.consecutiveErrors++;
4933
5954
  const onError = cfg.onError;
4934
5955
  if (onError) {
4935
- const [callbackErr, decision] = await catchError2(Promise.resolve().then(() => onError(error, state.consecutiveErrors)));
5956
+ const [callbackErr, decision] = await catchError(Promise.resolve().then(() => onError(error, state.consecutiveErrors)));
4936
5957
  if (callbackErr) {
4937
5958
  if (cfg.label) {
4938
5959
  logger.warn(`[${cfg.logPrefix}] ${cfg.label} — onError callback threw: ${callbackErr.message}`);
@@ -4969,7 +5990,7 @@ function computeErrorSleepMs(cfg, state, ctx) {
4969
5990
  }
4970
5991
  async function doSleep(ms, cfg) {
4971
5992
  if (ms > 0) {
4972
- const [err] = await catchError2(interruptibleSleep(ms, cfg.signal));
5993
+ const [err] = await catchError(interruptibleSleep(ms, cfg.signal));
4973
5994
  if (err) {
4974
5995
  if (isAbortError(err))
4975
5996
  return;
@@ -4983,7 +6004,7 @@ function isAbortError(err) {
4983
6004
  return err.name === "AbortError";
4984
6005
  }
4985
6006
  async function safeCallback(label, name, fn, prefix) {
4986
- const [err] = await catchError2(Promise.resolve().then(() => fn()));
6007
+ const [err] = await catchError(Promise.resolve().then(() => fn()));
4987
6008
  if (err && label) {
4988
6009
  logger.warn(`[${prefix}] ${label} — ${name} callback threw: ${err.message}`);
4989
6010
  }
@@ -4995,7 +6016,7 @@ async function processSuccessfulPoll(result, cfg, state) {
4995
6016
  }
4996
6017
  if (cfg.getStatus) {
4997
6018
  const getStatus = cfg.getStatus;
4998
- const [statusErr, newStatus] = catchError2(() => getStatus(result));
6019
+ const [statusErr, newStatus] = catchError(() => getStatus(result));
4999
6020
  if (statusErr) {
5000
6021
  if (cfg.label) {
5001
6022
  logger.warn(`[${cfg.logPrefix}] ${cfg.label} — getStatus threw: ${statusErr.message}`);
@@ -5034,7 +6055,7 @@ async function handleCompleted(result, cfg) {
5034
6055
  let statusStr = "";
5035
6056
  if (cfg.getStatus) {
5036
6057
  const getStatus = cfg.getStatus;
5037
- const [, status] = catchError2(() => getStatus(result));
6058
+ const [, status] = catchError(() => getStatus(result));
5038
6059
  if (status != null)
5039
6060
  statusStr = ` ${status}`;
5040
6061
  }
@@ -5097,7 +6118,7 @@ function logStart(options, cfg) {
5097
6118
  if (typeof options.intervalMs === "function") {
5098
6119
  intervalDesc = "dynamic";
5099
6120
  } else {
5100
- const [intervalErr, intervalVal] = catchError2(() => cfg.getInterval({ pollCount: 0, elapsedMs: 0 }));
6121
+ const [intervalErr, intervalVal] = catchError(() => cfg.getInterval({ pollCount: 0, elapsedMs: 0 }));
5101
6122
  intervalDesc = intervalErr ? "dynamic" : `${intervalVal}ms`;
5102
6123
  }
5103
6124
  const backoffDesc = options.backoff ? ", error backoff enabled" : "";
@@ -5135,7 +6156,7 @@ async function runPollLoop(cfg, state) {
5135
6156
  }
5136
6157
  const ctx = buildContext(cfg, state);
5137
6158
  if (cfg.beforePoll) {
5138
- const [beforePollErr] = await catchError2(Promise.resolve().then(() => cfg.beforePoll?.(ctx)));
6159
+ const [beforePollErr] = await catchError(Promise.resolve().then(() => cfg.beforePoll?.(ctx)));
5139
6160
  if (beforePollErr) {
5140
6161
  const outcome = await handleErrorAndSleep(beforePollErr, "beforePoll", cfg, state, ctx);
5141
6162
  if (outcome)
@@ -5143,7 +6164,7 @@ async function runPollLoop(cfg, state) {
5143
6164
  continue;
5144
6165
  }
5145
6166
  }
5146
- const [pollErr, result] = await catchError2(cfg.fn());
6167
+ const [pollErr, result] = await catchError(cfg.fn());
5147
6168
  if (pollErr) {
5148
6169
  const outcome = await handleErrorAndSleep(pollErr, "poll", cfg, state, ctx);
5149
6170
  if (outcome)
@@ -5151,7 +6172,7 @@ async function runPollLoop(cfg, state) {
5151
6172
  continue;
5152
6173
  }
5153
6174
  await processSuccessfulPoll(result, cfg, state);
5154
- const [untilErr, isTerminal] = catchError2(() => cfg.until(result));
6175
+ const [untilErr, isTerminal] = catchError(() => cfg.until(result));
5155
6176
  if (untilErr) {
5156
6177
  const outcome = await handleErrorAndSleep(untilErr, "until", cfg, state, ctx);
5157
6178
  if (outcome)
@@ -5309,6 +6330,17 @@ function dedupeKey(payload) {
5309
6330
  payload.artifact_correlation_key ?? payload.package_version_key ?? payload.deployment_key ?? payload.solution_id ?? payload.package_name ?? ""
5310
6331
  ].join("|");
5311
6332
  }
6333
+ function withPseudonymizedIdentifiers(payload) {
6334
+ return {
6335
+ ...payload,
6336
+ ...payload.package_name === undefined ? {} : {
6337
+ package_name: `package#${pseudonymize(payload.package_name)}`
6338
+ },
6339
+ ...payload.artifact_correlation_key === undefined ? {} : {
6340
+ artifact_correlation_key: `artifact#${pseudonymize(payload.artifact_correlation_key)}`
6341
+ }
6342
+ };
6343
+ }
5312
6344
  function trackShipSucceeded(payload) {
5313
6345
  const keys = getShippedKeys();
5314
6346
  const key = dedupeKey(payload);
@@ -5316,7 +6348,7 @@ function trackShipSucceeded(payload) {
5316
6348
  return false;
5317
6349
  }
5318
6350
  keys.add(key);
5319
- telemetry.trackEvent(CommonTelemetryEvents.ShipSucceeded, redactProperties({ ...payload }));
6351
+ telemetry.trackEvent(CommonTelemetryEvents.ShipSucceeded, redactProperties(withPseudonymizedIdentifiers(payload)));
5320
6352
  return true;
5321
6353
  }
5322
6354
  // ../common/src/tool-provider.ts
@@ -5341,6 +6373,40 @@ async function loadPackagerTool(specifier) {
5341
6373
  logger.debug(`No packager factory provider registered; loaded '${specifier}' directly.`);
5342
6374
  return;
5343
6375
  }
6376
+ // ../auth/src/catch-error.ts
6377
+ function isPromiseLike2(value) {
6378
+ return value !== null && typeof value === "object" && typeof value.then === "function";
6379
+ }
6380
+ function catchError2(fnOrPromise) {
6381
+ if (isPromiseLike2(fnOrPromise)) {
6382
+ return settlePromiseLike2(fnOrPromise);
6383
+ }
6384
+ try {
6385
+ const result = fnOrPromise();
6386
+ if (isPromiseLike2(result)) {
6387
+ return settlePromiseLike2(result);
6388
+ }
6389
+ return [undefined, result];
6390
+ } catch (error) {
6391
+ return [
6392
+ error instanceof Error ? error : new Error(String(error)),
6393
+ undefined
6394
+ ];
6395
+ }
6396
+ }
6397
+ function settlePromiseLike2(thenable) {
6398
+ return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
6399
+ error instanceof Error ? error : new Error(String(error)),
6400
+ undefined
6401
+ ]);
6402
+ }
6403
+
6404
+ // ../auth/src/constants.ts
6405
+ var UIPATH_HOME_DIR = ".uipath";
6406
+ var AUTH_FILENAME = ".auth";
6407
+ var DEFAULT_BASE_URL = "https://cloud.uipath.com";
6408
+ var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
6409
+
5344
6410
  // ../auth/src/authProfile.ts
5345
6411
  var DEFAULT_AUTH_PROFILE = "default";
5346
6412
  var PROFILE_DIR = "profiles";
@@ -5352,7 +6418,7 @@ function isAuthProfileStorage(value) {
5352
6418
  return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
5353
6419
  }
5354
6420
  function createProfileStorage() {
5355
- const [error, mod] = catchError(() => __require("node:async_hooks"));
6421
+ const [error, mod] = catchError2(() => __require("node:async_hooks"));
5356
6422
  if (error || typeof mod?.AsyncLocalStorage !== "function") {
5357
6423
  return {
5358
6424
  getStore: () => {
@@ -5368,9 +6434,9 @@ function getProfileStorage() {
5368
6434
  if (isAuthProfileStorage(existing)) {
5369
6435
  return existing;
5370
6436
  }
5371
- const storage = createProfileStorage();
5372
- globalSlot[AUTH_PROFILE_STORAGE_KEY] = storage;
5373
- return storage;
6437
+ const storage2 = createProfileStorage();
6438
+ globalSlot[AUTH_PROFILE_STORAGE_KEY] = storage2;
6439
+ return storage2;
5374
6440
  }
5375
6441
  var profileStorage = getProfileStorage();
5376
6442
 
@@ -5401,8 +6467,8 @@ function resolveAuthProfileFilePath(profile) {
5401
6467
  if (normalized === undefined) {
5402
6468
  throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
5403
6469
  }
5404
- const fs = getFileSystem();
5405
- return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
6470
+ const fs2 = getFileSystem();
6471
+ return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
5406
6472
  }
5407
6473
  function getActiveAuthProfileFilePath() {
5408
6474
  const profile = getActiveAuthProfile();
@@ -5422,7 +6488,7 @@ class InvalidBaseUrlError extends Error {
5422
6488
  super(`Invalid base URL: "${url}"
5423
6489
  ` + `Reason: ${reason}
5424
6490
 
5425
- ` + `Expected format: an https:// URL, e.g. https://cloud.uipath.com (commercial), https://govcloud.uipath.us (Public Sector), or your Automation Suite host (https://<your-host>).
6491
+ ` + `Expected format: an https:// URL (or bare host — https:// is assumed), e.g. https://cloud.uipath.com (commercial), https://govcloud.uipath.us (Public Sector), or your Automation Suite host (https://<your-host>).
5426
6492
  ` + `You can specify the URL via:
5427
6493
  ` + ` • --authority flag
5428
6494
  ` + ` • UIPATH_URL environment variable
@@ -5443,10 +6509,16 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
5443
6509
  while (baseUrl.endsWith("/")) {
5444
6510
  baseUrl = baseUrl.slice(0, -1);
5445
6511
  }
6512
+ const hasScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(baseUrl);
6513
+ const [hostCandidate] = baseUrl.split(/[/?#]/, 1);
6514
+ if (!hasScheme && hostCandidate.includes(".")) {
6515
+ baseUrl = `https://${baseUrl}`;
6516
+ }
5446
6517
  const resolvedBaseUrl = baseUrl;
5447
- const [urlError, url] = catchError(() => new URL(resolvedBaseUrl));
6518
+ const [urlError, url] = catchError2(() => new URL(resolvedBaseUrl));
5448
6519
  if (urlError) {
5449
- throw new InvalidBaseUrlError(baseUrl, `Malformed URL. ${urlError instanceof Error ? urlError.message : "Unknown error"}`);
6520
+ const shapeHint = !hasScheme && !hostCandidate.includes(".") ? ` "${rawUrl.trim()}" is not a URL or a host name. Pass the full authority URL — https://<host>, or just <host> (https:// is assumed).` : ` ${urlError instanceof Error ? urlError.message : "Unknown error"}`;
6521
+ throw new InvalidBaseUrlError(baseUrl, `Malformed URL.${shapeHint}`);
5450
6522
  }
5451
6523
  if (url.protocol !== "https:") {
5452
6524
  throw new InvalidBaseUrlError(baseUrl, `Authority must use https:// scheme, got ${url.protocol}//. OIDC token exchange requires TLS end-to-end.`);
@@ -5501,6 +6573,11 @@ var resolveConfigAsync = async ({
5501
6573
  };
5502
6574
  };
5503
6575
 
6576
+ // ../auth/src/utils/platform.ts
6577
+ function isBrowser() {
6578
+ return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
6579
+ }
6580
+
5504
6581
  // ../auth/src/utils/jwt.ts
5505
6582
  class InvalidIssuerError extends Error {
5506
6583
  expected;
@@ -5575,7 +6652,7 @@ var getTokenExpiration = (accessToken) => {
5575
6652
  // ../auth/src/sessionIdentity.ts
5576
6653
  var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
5577
6654
  var decodeClaims = (accessToken) => {
5578
- const [error, claims] = catchError(() => parseJWT(accessToken));
6655
+ const [error, claims] = catchError2(() => parseJWT(accessToken));
5579
6656
  return error ? undefined : claims;
5580
6657
  };
5581
6658
  var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
@@ -5659,27 +6736,48 @@ var requireEnv = (name) => {
5659
6736
  }
5660
6737
  return value;
5661
6738
  };
6739
+ var OPAQUE_TOKEN_BASE_URL_VAR = "UIPATH_URL";
6740
+ var resolveBaseUrl = (rawUrl, failureContext) => {
6741
+ const [baseUrlError, baseUrl] = catchError2(() => normalizeAndValidateBaseUrl(rawUrl));
6742
+ if (baseUrlError) {
6743
+ if (baseUrlError instanceof InvalidBaseUrlError) {
6744
+ throw baseUrlError;
6745
+ }
6746
+ throw new EnvAuthConfigError(`${failureContext}: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
6747
+ }
6748
+ return baseUrl;
6749
+ };
5662
6750
  var readAuthFromEnv = () => {
5663
6751
  const accessToken = requireEnv(ENV_AUTH_VARS.token);
5664
6752
  const organizationName = requireEnv(ENV_AUTH_VARS.organizationName);
5665
6753
  const organizationId = requireEnv(ENV_AUTH_VARS.organizationId);
5666
6754
  const tenantName = requireEnv(ENV_AUTH_VARS.tenantName);
5667
6755
  const tenantId = requireEnv(ENV_AUTH_VARS.tenantId);
5668
- const [parseError, payload] = catchError(() => parseJWT(accessToken));
6756
+ const [parseError, payload] = catchError2(() => parseJWT(accessToken));
5669
6757
  if (parseError) {
5670
- throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} is not a valid JWT: ` + `${parseError instanceof Error ? parseError.message : String(parseError)}`);
6758
+ const parseErrorMessage = parseError instanceof Error ? parseError.message : String(parseError);
6759
+ const rawUrl = process.env[OPAQUE_TOKEN_BASE_URL_VAR];
6760
+ if (!rawUrl) {
6761
+ throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} is not a JWT (treating it as an opaque token, ` + `e.g. a Personal Access Token). Set ${OPAQUE_TOKEN_BASE_URL_VAR} to the ` + `UiPath base URL if this is a PAT, or fix the token if it was meant to ` + `be a JWT (parse error: ${parseErrorMessage}).`);
6762
+ }
6763
+ const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
6764
+ return {
6765
+ loginStatus: "Logged in",
6766
+ accessToken,
6767
+ baseUrl: baseUrl2,
6768
+ organizationName,
6769
+ organizationId,
6770
+ tenantName,
6771
+ tenantId,
6772
+ source: "env-vars" /* EnvironmentVariables */,
6773
+ hint: "Token is opaque (not a JWT) - expiration and identity cannot be " + "determined locally. Commands will fail with 401 once it is revoked or " + `expired. If this was meant to be a JWT instead of a PAT, note: ${parseErrorMessage}`
6774
+ };
5671
6775
  }
5672
6776
  const iss = payload.iss;
5673
6777
  if (typeof iss !== "string" || iss.length === 0) {
5674
6778
  throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} has no 'iss' claim; cannot determine ` + `the UiPath server. Ensure the token was issued by a UiPath identity server.`);
5675
6779
  }
5676
- const [baseUrlError, baseUrl] = catchError(() => normalizeAndValidateBaseUrl(iss));
5677
- if (baseUrlError) {
5678
- if (baseUrlError instanceof InvalidBaseUrlError) {
5679
- throw baseUrlError;
5680
- }
5681
- throw new EnvAuthConfigError(`Failed to derive server URL from token 'iss' claim: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
5682
- }
6780
+ const baseUrl = resolveBaseUrl(iss, "Failed to derive server URL from token 'iss' claim");
5683
6781
  const expiration = getTokenExpiration(accessToken);
5684
6782
  const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
5685
6783
  const identity = resolveSessionIdentity(accessToken);
@@ -5705,8 +6803,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
5705
6803
  async function refreshTokenFingerprint(refreshToken) {
5706
6804
  const bytes = new TextEncoder().encode(refreshToken);
5707
6805
  if (globalThis.crypto?.subtle) {
5708
- const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
5709
- return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
6806
+ const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
6807
+ return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
5710
6808
  }
5711
6809
  const { createHash } = await import("node:crypto");
5712
6810
  return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
@@ -5715,9 +6813,9 @@ function breakerPathFor(authPath) {
5715
6813
  return `${authPath}${BREAKER_SUFFIX}`;
5716
6814
  }
5717
6815
  async function loadRefreshBreaker(authPath) {
5718
- const fs = getFileSystem();
6816
+ const fs2 = getFileSystem();
5719
6817
  try {
5720
- const content = await fs.readFile(breakerPathFor(authPath), "utf-8");
6818
+ const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
5721
6819
  if (!content)
5722
6820
  return {};
5723
6821
  const parsed = JSON.parse(content);
@@ -5728,20 +6826,20 @@ async function loadRefreshBreaker(authPath) {
5728
6826
  }
5729
6827
  async function saveRefreshBreaker(authPath, state) {
5730
6828
  try {
5731
- const fs = getFileSystem();
5732
- const path = breakerPathFor(authPath);
5733
- await fs.mkdir(fs.path.dirname(path));
5734
- const tempPath = `${path}.tmp`;
5735
- await fs.writeFile(tempPath, JSON.stringify(state));
5736
- await fs.rename(tempPath, path);
6829
+ const fs2 = getFileSystem();
6830
+ const path2 = breakerPathFor(authPath);
6831
+ await fs2.mkdir(fs2.path.dirname(path2));
6832
+ const tempPath = `${path2}.tmp`;
6833
+ await fs2.writeFile(tempPath, JSON.stringify(state));
6834
+ await fs2.rename(tempPath, path2);
5737
6835
  } catch {}
5738
6836
  }
5739
6837
  async function clearRefreshBreaker(authPath) {
5740
- const fs = getFileSystem();
5741
- const path = breakerPathFor(authPath);
6838
+ const fs2 = getFileSystem();
6839
+ const path2 = breakerPathFor(authPath);
5742
6840
  try {
5743
- if (await fs.exists(path)) {
5744
- await fs.rm(path);
6841
+ if (await fs2.exists(path2)) {
6842
+ await fs2.rm(path2);
5745
6843
  }
5746
6844
  } catch {}
5747
6845
  }
@@ -5762,43 +6860,43 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
5762
6860
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
5763
6861
  var PIPE_NAME_MAX_LENGTH = 103;
5764
6862
  var getRobotIpcPipeNames = async () => {
5765
- const fs = getFileSystem();
5766
- const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
6863
+ const fs2 = getFileSystem();
6864
+ const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
5767
6865
  if (!username) {
5768
6866
  throw new Error("Unable to determine current username");
5769
6867
  }
5770
- const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
5771
- return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
6868
+ const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
6869
+ return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
5772
6870
  };
5773
6871
  var defaultIsRobotIpcAvailable = async () => {
5774
6872
  if (process.platform === "win32") {
5775
6873
  return true;
5776
6874
  }
5777
- const [pipeNamesError, pipeNames] = await catchError(getRobotIpcPipeNames());
6875
+ const [pipeNamesError, pipeNames] = await catchError2(getRobotIpcPipeNames());
5778
6876
  if (pipeNamesError || !pipeNames) {
5779
6877
  return false;
5780
6878
  }
5781
- const fs = getFileSystem();
6879
+ const fs2 = getFileSystem();
5782
6880
  for (const pipeName of pipeNames) {
5783
- const [existsError, exists] = await catchError(fs.exists(pipeName));
6881
+ const [existsError, exists] = await catchError2(fs2.exists(pipeName));
5784
6882
  if (!existsError && exists === true) {
5785
6883
  return true;
5786
6884
  }
5787
6885
  }
5788
6886
  return false;
5789
6887
  };
5790
- var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
6888
+ var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
5791
6889
  const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
5792
6890
  promise.then((value) => {
5793
6891
  clearTimeout(timer);
5794
- resolve(value);
6892
+ resolve2(value);
5795
6893
  }, (error) => {
5796
6894
  clearTimeout(timer);
5797
6895
  reject(error);
5798
6896
  });
5799
6897
  });
5800
6898
  var parseResourceUrl = (url) => {
5801
- const [error, parsed] = catchError(() => new URL(url));
6899
+ const [error, parsed] = catchError2(() => new URL(url));
5802
6900
  if (error || !parsed)
5803
6901
  return;
5804
6902
  const segments = parsed.pathname.split("/").filter(Boolean);
@@ -5818,7 +6916,7 @@ var defaultLoadModule = async () => {
5818
6916
  if (!hostLoader) {
5819
6917
  return;
5820
6918
  }
5821
- const [error, mod] = await catchError(() => hostLoader());
6919
+ const [error, mod] = await catchError2(() => hostLoader());
5822
6920
  if (error || !mod) {
5823
6921
  return;
5824
6922
  }
@@ -5844,7 +6942,7 @@ var tryRobotClientFallback = async (options = {}) => {
5844
6942
  const mod = await loadModule();
5845
6943
  if (!mod)
5846
6944
  return;
5847
- const [ctorError, proxy] = catchError(() => new mod.RobotProxyConstructor);
6945
+ const [ctorError, proxy] = catchError2(() => new mod.RobotProxyConstructor);
5848
6946
  if (ctorError || !proxy) {
5849
6947
  return;
5850
6948
  }
@@ -5867,7 +6965,7 @@ var tryRobotClientFallback = async (options = {}) => {
5867
6965
  let organizationIdFromToken;
5868
6966
  let tenantIdFromToken;
5869
6967
  let issuerFromToken;
5870
- const [jwtError, claims] = catchError(() => parseJWT(accessToken));
6968
+ const [jwtError, claims] = catchError2(() => parseJWT(accessToken));
5871
6969
  if (!jwtError && claims) {
5872
6970
  const rawOrgId = claims.prtId ?? claims.organizationId ?? claims.prt_id;
5873
6971
  if (typeof rawOrgId === "string" && rawOrgId.length > 0) {
@@ -5894,7 +6992,7 @@ var tryRobotClientFallback = async (options = {}) => {
5894
6992
  } catch {
5895
6993
  return;
5896
6994
  } finally {
5897
- await catchError(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
6995
+ await catchError2(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
5898
6996
  }
5899
6997
  };
5900
6998
 
@@ -5964,9 +7062,9 @@ var errorCode = (err) => {
5964
7062
  }
5965
7063
  return "EUNKNOWN";
5966
7064
  };
5967
- var probeAsync = async (fs, candidate) => {
7065
+ var probeAsync = async (fs2, candidate) => {
5968
7066
  try {
5969
- const stats = await fs.stat(candidate);
7067
+ const stats = await fs2.stat(candidate);
5970
7068
  if (stats === null) {
5971
7069
  return { exists: false };
5972
7070
  }
@@ -5993,9 +7091,9 @@ var probeAsync = async (fs, candidate) => {
5993
7091
  }
5994
7092
  };
5995
7093
  var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
5996
- const fs = getFileSystem();
5997
- if (fs.path.isAbsolute(envFilePath)) {
5998
- const probe2 = await probeAsync(fs, envFilePath);
7094
+ const fs2 = getFileSystem();
7095
+ if (fs2.path.isAbsolute(envFilePath)) {
7096
+ const probe2 = await probeAsync(fs2, envFilePath);
5999
7097
  return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
6000
7098
  exists: false,
6001
7099
  absolutePath: envFilePath,
@@ -6003,11 +7101,11 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
6003
7101
  ...probe2.unusable ? { unusable: probe2.unusable } : {}
6004
7102
  };
6005
7103
  }
6006
- const cwd = opts?.cwd ?? fs.env.cwd();
7104
+ const cwd = opts?.cwd ?? fs2.env.cwd();
6007
7105
  let searchDir = cwd;
6008
7106
  while (true) {
6009
- const candidate = fs.path.join(searchDir, envFilePath);
6010
- const probe2 = await probeAsync(fs, candidate);
7107
+ const candidate = fs2.path.join(searchDir, envFilePath);
7108
+ const probe2 = await probeAsync(fs2, candidate);
6011
7109
  if (probe2.exists) {
6012
7110
  return {
6013
7111
  exists: true,
@@ -6015,14 +7113,14 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
6015
7113
  source: searchDir === cwd ? "cwd" : "ancestor"
6016
7114
  };
6017
7115
  }
6018
- const parentDir = fs.path.dirname(searchDir);
7116
+ const parentDir = fs2.path.dirname(searchDir);
6019
7117
  if (parentDir === searchDir) {
6020
7118
  break;
6021
7119
  }
6022
7120
  searchDir = parentDir;
6023
7121
  }
6024
- const homePath = fs.path.join(fs.env.homedir(), envFilePath);
6025
- const probe = await probeAsync(fs, homePath);
7122
+ const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
7123
+ const probe = await probeAsync(fs2, homePath);
6026
7124
  if (probe.exists) {
6027
7125
  return { exists: true, absolutePath: homePath, source: "home" };
6028
7126
  }
@@ -6044,12 +7142,12 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
6044
7142
  };
6045
7143
  };
6046
7144
  var loadEnvFileAsync = async ({ envPath }) => {
6047
- const fs = getFileSystem();
6048
- const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
6049
- if (!await fs.exists(absolutePath)) {
7145
+ const fs2 = getFileSystem();
7146
+ const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
7147
+ if (!await fs2.exists(absolutePath)) {
6050
7148
  throw new Error(`Environment file not found: ${envPath}`);
6051
7149
  }
6052
- const content = await fs.readFile(absolutePath, "utf-8");
7150
+ const content = await fs2.readFile(absolutePath, "utf-8");
6053
7151
  if (content === null) {
6054
7152
  throw new Error(`Environment file not found: ${envPath}`);
6055
7153
  }
@@ -6078,10 +7176,10 @@ var saveEnvFileAsync = async ({
6078
7176
  data,
6079
7177
  merge = true
6080
7178
  }) => {
6081
- const fs = getFileSystem();
6082
- const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
7179
+ const fs2 = getFileSystem();
7180
+ const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
6083
7181
  let existingData = {};
6084
- if (merge && await fs.exists(absolutePath)) {
7182
+ if (merge && await fs2.exists(absolutePath)) {
6085
7183
  try {
6086
7184
  existingData = await loadEnvFileAsync({ envPath: absolutePath });
6087
7185
  } catch {}
@@ -6099,11 +7197,11 @@ var saveEnvFileAsync = async ({
6099
7197
  const content = `${lines.join(`
6100
7198
  `)}
6101
7199
  `;
6102
- const dir = fs.path.dirname(absolutePath);
6103
- await fs.mkdir(dir);
7200
+ const dir = fs2.path.dirname(absolutePath);
7201
+ await fs2.mkdir(dir);
6104
7202
  const tempPath = `${absolutePath}.tmp`;
6105
- await fs.writeFile(tempPath, content);
6106
- await fs.rename(tempPath, absolutePath);
7203
+ await fs2.writeFile(tempPath, content);
7204
+ await fs2.rename(tempPath, absolutePath);
6107
7205
  };
6108
7206
 
6109
7207
  // ../auth/src/loginStatus.ts
@@ -6217,11 +7315,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
6217
7315
  return { credentials };
6218
7316
  }
6219
7317
  async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
6220
- const fs = getFs();
6221
- const globalPath = fs.path.join(fs.env.homedir(), envFilePath);
7318
+ const fs2 = getFs();
7319
+ const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
6222
7320
  if (absolutePath === globalPath)
6223
7321
  return;
6224
- if (!await fs.exists(globalPath))
7322
+ if (!await fs2.exists(globalPath))
6225
7323
  return;
6226
7324
  try {
6227
7325
  const globalCreds = await loadEnvFile({ envPath: globalPath });
@@ -6633,17 +7731,17 @@ function normalizeProjectType(projectType) {
6633
7731
  function toPortableRelativePath(relativePath) {
6634
7732
  return relativePath.replace(/\\/g, "/");
6635
7733
  }
6636
- async function readUipxFile(fs, solutionDir) {
6637
- const dirEntries = await fs.readdir(solutionDir);
7734
+ async function readUipxFile(fs2, solutionDir) {
7735
+ const dirEntries = await fs2.readdir(solutionDir);
6638
7736
  const uipxFileName = dirEntries.find((f) => f.endsWith(".uipx"));
6639
7737
  if (!uipxFileName) {
6640
7738
  throw new Error(`No .uipx file found in ${solutionDir}. Run 'uip solution init' first.`);
6641
7739
  }
6642
- const uipxContent = await fs.readFile(fs.path.join(solutionDir, uipxFileName), "utf-8");
7740
+ const uipxContent = await fs2.readFile(fs2.path.join(solutionDir, uipxFileName), "utf-8");
6643
7741
  if (!uipxContent) {
6644
7742
  throw new Error(`Could not read .uipx file: ${uipxFileName} is empty or missing.`);
6645
7743
  }
6646
- const [parseError, parsed] = catchError2(() => JSON.parse(uipxContent));
7744
+ const [parseError, parsed] = catchError(() => JSON.parse(uipxContent));
6647
7745
  if (parseError) {
6648
7746
  throw new Error(`Invalid .uipx file: could not parse JSON in ${uipxFileName}.`);
6649
7747
  }
@@ -6674,44 +7772,44 @@ function validateUipxFile(parsed, uipxFileName) {
6674
7772
  function isRecord2(value) {
6675
7773
  return typeof value === "object" && value !== null && !Array.isArray(value);
6676
7774
  }
6677
- function resolveSolutionDir(fs, inputPath) {
6678
- const resolved = fs.path.resolve(inputPath);
7775
+ function resolveSolutionDir(fs2, inputPath) {
7776
+ const resolved = fs2.path.resolve(inputPath);
6679
7777
  if (resolved.endsWith(".uipx")) {
6680
- return fs.path.dirname(resolved);
7778
+ return fs2.path.dirname(resolved);
6681
7779
  }
6682
7780
  return resolved;
6683
7781
  }
6684
- async function updateUipxSolutionId(fs, uipxPath, newSolutionId) {
6685
- const [readError, content] = await catchError2(fs.readFile(uipxPath, "utf-8"));
7782
+ async function updateUipxSolutionId(fs2, uipxPath, newSolutionId) {
7783
+ const [readError, content] = await catchError(fs2.readFile(uipxPath, "utf-8"));
6686
7784
  if (readError || !content) {
6687
7785
  logger.error(`Could not read .uipx file for update: ${readError?.message ?? "empty file"}`);
6688
7786
  return;
6689
7787
  }
6690
- const [parseError, parsed] = catchError2(() => JSON.parse(content));
7788
+ const [parseError, parsed] = catchError(() => JSON.parse(content));
6691
7789
  if (parseError) {
6692
7790
  logger.error(`Could not parse .uipx file for update: ${parseError.message}`);
6693
7791
  return;
6694
7792
  }
6695
7793
  parsed.SolutionId = newSolutionId;
6696
- const [writeError] = await catchError2(fs.writeFile(uipxPath, JSON.stringify(parsed, null, 4)));
7794
+ const [writeError] = await catchError(fs2.writeFile(uipxPath, JSON.stringify(parsed, null, 4)));
6697
7795
  if (writeError) {
6698
7796
  logger.error(`Could not update .uipx with new SolutionId: ${writeError.message}`);
6699
7797
  } else {
6700
7798
  logger.info(`Updated .uipx with Studio Web SolutionId: ${newSolutionId}`);
6701
7799
  }
6702
7800
  }
6703
- async function findSolutionFileUpward(fs, startDir) {
7801
+ async function findSolutionFileUpward(fs2, startDir) {
6704
7802
  let dir = startDir;
6705
7803
  while (true) {
6706
- const entries = await fs.readdir(dir);
7804
+ const entries = await fs2.readdir(dir);
6707
7805
  const files = entries.filter((f) => f.endsWith(".uipx"));
6708
7806
  if (files.length === 1) {
6709
- return fs.path.join(dir, files[0]);
7807
+ return fs2.path.join(dir, files[0]);
6710
7808
  }
6711
7809
  if (files.length > 1) {
6712
7810
  throw new Error(`Multiple .uipx files found in ${dir}. Please specify which solution file to use.`);
6713
7811
  }
6714
- const parent = fs.path.dirname(dir);
7812
+ const parent = fs2.path.dirname(dir);
6715
7813
  if (parent === dir) {
6716
7814
  throw new Error(`No .uipx solution file found (searched from ${startDir} to filesystem root)`);
6717
7815
  }
@@ -6719,6 +7817,6 @@ async function findSolutionFileUpward(fs, startDir) {
6719
7817
  }
6720
7818
  }
6721
7819
 
6722
- export { catchError2 as catchError, extractErrorDetails, extractErrorMessage, Command, Option, isPreviewBuild, previewOnly, logger, telemetry, RESULTS, Pagination, OutputFormatter, processContext, withCompleter, requireConfirmation, DEFAULT_PAGE_SIZE, resolveEnvReference, isGuid, createHiddenDeprecatedTenantOption, parseLimit, parseOffset, parseBoundedInt, registerPackageMetadataOptions, mapPackageMetadataOptions, PollOutcome, mapPollFailure, pollUntil, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, unsupportedSolutionProjectType, trackShipSucceeded, ensurePackagerFactory, getLoginStatusAsync, getAuthContext, normalizeProjectType, toPortableRelativePath, readUipxFile, resolveSolutionDir, updateUipxSolutionId, findSolutionFileUpward };
7820
+ export { getFileSystem, catchError, carriedInstructions, extractErrorDetails, extractErrorMessage, logger, telemetry, RESULTS, Pagination, OutputFormatter, Command, Option, isPreviewBuild, processContext, withCompleter, requireConfirmation, DEFAULT_PAGE_SIZE, resolveEnvReference, isGuid, createHiddenDeprecatedTenantOption, parseLimit, parseOffset, parseBoundedInt, registerPackageMetadataOptions, mapPackageMetadataOptions, PollOutcome, mapPollFailure, pollUntil, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, unsupportedSolutionProjectType, trackShipSucceeded, ensurePackagerFactory, getLoginStatusAsync, getAuthContext, normalizeProjectType, toPortableRelativePath, readUipxFile, resolveSolutionDir, updateUipxSolutionId, findSolutionFileUpward };
6723
7821
 
6724
- //# debugId=2E08117FE8D9447364756E2164756E21
7822
+ //# debugId=59C0F4CE1FDC114C64756E2164756E21