@uipath/guardrails-tool 1.201.0 → 1.202.0-preview.136

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.
package/dist/tool.js CHANGED
@@ -1,23 +1,11 @@
1
- import {
2
- isBrowser
3
- } from "./tool-eb3gcj08.js";
4
- import {
5
- catchError,
6
- getFileSystem
7
- } from "./tool-31j9b09f.js";
8
- import {
9
- AUTH_FILENAME,
10
- DEFAULT_BASE_URL,
11
- UIPATH_HOME_DIR
12
- } from "./tool-yy8n2117.js";
13
1
  import {
14
2
  __commonJS,
15
3
  __require,
16
4
  __toESM
17
- } from "./tool-0v6na3yp.js";
5
+ } from "./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();
@@ -2112,7 +2100,7 @@ var require_commander = __commonJS((exports) => {
2112
2100
  var package_default = {
2113
2101
  name: "@uipath/guardrails-tool",
2114
2102
  license: "MIT",
2115
- version: "1.201.0",
2103
+ version: "1.202.0-preview.136",
2116
2104
  description: "CLI plugin for UiPath AI Trust Layer guardrail configurations.",
2117
2105
  private: false,
2118
2106
  repository: {
@@ -2150,81 +2138,402 @@ var package_default = {
2150
2138
  }
2151
2139
  };
2152
2140
 
2153
- // ../../common/src/catch-error.ts
2154
- function isPromiseLike(value) {
2155
- return value !== null && typeof value === "object" && typeof value.then === "function";
2156
- }
2157
- function catchError2(fnOrPromise) {
2158
- if (isPromiseLike(fnOrPromise)) {
2159
- return settlePromiseLike(fnOrPromise);
2141
+ // ../../filesystem/src/node.ts
2142
+ import { randomUUID } from "node:crypto";
2143
+ import { existsSync } from "node:fs";
2144
+ import * as fs from "node:fs/promises";
2145
+ import * as os from "node:os";
2146
+ import * as path from "node:path";
2147
+ var LOCK_HEARTBEAT_MS = 5000;
2148
+ var LOCK_STALE_MS = 15000;
2149
+ var LOCK_MAX_WAIT_MS = 20000;
2150
+ var LOCK_MAX_HOLD_MS = 60000;
2151
+ var LOCK_RETRY_MIN_MS = 100;
2152
+ var LOCK_RETRY_JITTER_MS = 200;
2153
+
2154
+ class NodeFileSystem {
2155
+ path = {
2156
+ join: path.join,
2157
+ resolve: path.resolve,
2158
+ relative: path.relative,
2159
+ dirname: path.dirname,
2160
+ isAbsolute: path.isAbsolute,
2161
+ basename: path.basename
2162
+ };
2163
+ env = {
2164
+ cwd: process.cwd,
2165
+ homedir: os.homedir,
2166
+ tmpdir: os.tmpdir,
2167
+ getenv: (key) => process.env[key]
2168
+ };
2169
+ utils = {
2170
+ open: async (url) => {
2171
+ const { default: open } = await import("./index-xnzgkhtg.js");
2172
+ await open(url);
2173
+ }
2174
+ };
2175
+ async readFile(path2, options) {
2176
+ try {
2177
+ if (options) {
2178
+ return await fs.readFile(path2, "utf-8");
2179
+ }
2180
+ return await fs.readFile(path2);
2181
+ } catch (error) {
2182
+ if (this.isEnoent(error))
2183
+ return null;
2184
+ throw error;
2185
+ }
2160
2186
  }
2161
- try {
2162
- const result = fnOrPromise();
2163
- if (isPromiseLike(result)) {
2164
- return settlePromiseLike(result);
2187
+ async writeFile(filePath, data) {
2188
+ const dir = path.dirname(filePath);
2189
+ if (dir) {
2190
+ await fs.mkdir(dir, { recursive: true });
2165
2191
  }
2166
- return [undefined, result];
2167
- } catch (error) {
2168
- return [
2169
- error instanceof Error ? error : new Error(String(error)),
2170
- undefined
2171
- ];
2192
+ await fs.writeFile(filePath, data);
2193
+ }
2194
+ async appendFile(filePath, data) {
2195
+ const dir = path.dirname(filePath);
2196
+ if (dir) {
2197
+ await fs.mkdir(dir, { recursive: true });
2198
+ }
2199
+ await fs.appendFile(filePath, data);
2200
+ }
2201
+ async readdir(dirPath) {
2202
+ try {
2203
+ return await fs.readdir(dirPath);
2204
+ } catch (error) {
2205
+ if (this.isEnoent(error))
2206
+ return [];
2207
+ throw error;
2208
+ }
2209
+ }
2210
+ async stat(filePath) {
2211
+ try {
2212
+ const stats = await fs.stat(filePath);
2213
+ return {
2214
+ isFile: () => stats.isFile(),
2215
+ isDirectory: () => stats.isDirectory(),
2216
+ size: stats.size,
2217
+ mtimeMs: stats.mtimeMs
2218
+ };
2219
+ } catch (error) {
2220
+ if (this.isEnoent(error))
2221
+ return null;
2222
+ throw error;
2223
+ }
2224
+ }
2225
+ async exists(filePath) {
2226
+ return existsSync(filePath);
2227
+ }
2228
+ async mkdir(dirPath) {
2229
+ await fs.mkdir(dirPath, { recursive: true });
2230
+ }
2231
+ async acquireLock(lockPath) {
2232
+ const canonicalPath = await this.canonicalizeLockTarget(lockPath);
2233
+ const lockFile = `${canonicalPath}.lock`;
2234
+ const ownerId = randomUUID();
2235
+ const start = Date.now();
2236
+ while (true) {
2237
+ try {
2238
+ await fs.writeFile(lockFile, ownerId, { flag: "wx" });
2239
+ return this.createLockRelease(lockFile, ownerId);
2240
+ } catch (error) {
2241
+ if (!this.hasErrnoCode(error, "EEXIST")) {
2242
+ throw error;
2243
+ }
2244
+ const stats = await fs.stat(lockFile).catch(() => null);
2245
+ if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
2246
+ const reclaimed = await fs.rm(lockFile, { force: true }).then(() => true).catch(() => false);
2247
+ if (reclaimed)
2248
+ continue;
2249
+ }
2250
+ if (Date.now() - start > LOCK_MAX_WAIT_MS) {
2251
+ throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
2252
+ }
2253
+ await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
2254
+ }
2255
+ }
2256
+ }
2257
+ async canonicalizeLockTarget(lockPath) {
2258
+ const absolute = path.resolve(lockPath);
2259
+ const fullReal = await fs.realpath(absolute).catch(() => null);
2260
+ if (fullReal)
2261
+ return fullReal;
2262
+ const parent = path.dirname(absolute);
2263
+ const base = path.basename(absolute);
2264
+ const canonicalParent = await fs.realpath(parent).catch(() => parent);
2265
+ return path.join(canonicalParent, base);
2266
+ }
2267
+ createLockRelease(lockFile, ownerId) {
2268
+ const heartbeatStart = Date.now();
2269
+ let heartbeatTimer;
2270
+ let stopped = false;
2271
+ const stopHeartbeat = () => {
2272
+ stopped = true;
2273
+ if (heartbeatTimer)
2274
+ clearTimeout(heartbeatTimer);
2275
+ };
2276
+ const scheduleNextHeartbeat = () => {
2277
+ if (stopped)
2278
+ return;
2279
+ if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
2280
+ stopped = true;
2281
+ return;
2282
+ }
2283
+ heartbeatTimer = setTimeout(() => {
2284
+ runHeartbeat();
2285
+ }, LOCK_HEARTBEAT_MS);
2286
+ heartbeatTimer.unref?.();
2287
+ };
2288
+ const runHeartbeat = async () => {
2289
+ if (stopped)
2290
+ return;
2291
+ const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
2292
+ if (stopped)
2293
+ return;
2294
+ if (current !== ownerId) {
2295
+ stopped = true;
2296
+ return;
2297
+ }
2298
+ const now = Date.now() / 1000;
2299
+ await fs.utimes(lockFile, now, now).catch(() => {});
2300
+ scheduleNextHeartbeat();
2301
+ };
2302
+ scheduleNextHeartbeat();
2303
+ let released = false;
2304
+ return async () => {
2305
+ if (released)
2306
+ return;
2307
+ released = true;
2308
+ stopHeartbeat();
2309
+ const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
2310
+ if (current === ownerId) {
2311
+ await fs.rm(lockFile, { force: true });
2312
+ }
2313
+ };
2314
+ }
2315
+ async rm(filePath) {
2316
+ await fs.rm(filePath, { recursive: true, force: true });
2317
+ }
2318
+ async rename(oldPath, newPath) {
2319
+ await fs.rename(oldPath, newPath);
2320
+ }
2321
+ async realpath(filePath) {
2322
+ try {
2323
+ return await fs.realpath(filePath);
2324
+ } catch (error) {
2325
+ if (this.isEnoent(error))
2326
+ return filePath;
2327
+ throw error;
2328
+ }
2329
+ }
2330
+ async getTempDir() {
2331
+ return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
2332
+ }
2333
+ async copyDirectory(sourcePath, destPath) {
2334
+ const sourceStats = await this.stat(sourcePath);
2335
+ if (!sourceStats) {
2336
+ throw new Error(`Source directory does not exist: ${sourcePath}`);
2337
+ }
2338
+ if (!sourceStats.isDirectory()) {
2339
+ throw new Error(`Source path is not a directory: ${sourcePath}`);
2340
+ }
2341
+ await this.mkdir(destPath);
2342
+ const entries = await this.readdir(sourcePath);
2343
+ for (const entry of entries) {
2344
+ const srcEntry = path.join(sourcePath, entry);
2345
+ const destEntry = path.join(destPath, entry);
2346
+ const entryStats = await this.stat(srcEntry);
2347
+ if (!entryStats)
2348
+ continue;
2349
+ if (entryStats.isDirectory()) {
2350
+ await this.copyDirectory(srcEntry, destEntry);
2351
+ } else if (entryStats.isFile()) {
2352
+ const content = await this.readFile(srcEntry);
2353
+ if (content !== null) {
2354
+ await this.writeFile(destEntry, content);
2355
+ }
2356
+ }
2357
+ }
2358
+ }
2359
+ isEnoent(error) {
2360
+ return this.hasErrnoCode(error, "ENOENT");
2361
+ }
2362
+ hasErrnoCode(error, code) {
2363
+ return typeof error === "object" && error !== null && "code" in error && error.code === code;
2172
2364
  }
2173
- }
2174
- function settlePromiseLike(thenable) {
2175
- return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
2176
- error instanceof Error ? error : new Error(String(error)),
2177
- undefined
2178
- ]);
2179
2365
  }
2180
2366
 
2181
- // ../../common/src/error-handler.ts
2182
- var NETWORK_ERROR_CODES = new Set([
2183
- "ECONNREFUSED",
2184
- "ECONNRESET",
2185
- "ENOTFOUND",
2186
- "EAI_AGAIN",
2187
- "ETIMEDOUT",
2188
- "EPIPE",
2189
- "EHOSTUNREACH",
2190
- "ENETUNREACH",
2191
- "EAI_FAIL"
2367
+ // ../../filesystem/src/index.ts
2368
+ var fsInstance = new NodeFileSystem;
2369
+ var getFileSystem = () => fsInstance;
2370
+
2371
+ // ../../common/src/telemetry/pseudonymize.ts
2372
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2373
+ var PSEUDONYM_HEX_LENGTH = 32;
2374
+ var SHA256_K = new Uint32Array([
2375
+ 1116352408,
2376
+ 1899447441,
2377
+ 3049323471,
2378
+ 3921009573,
2379
+ 961987163,
2380
+ 1508970993,
2381
+ 2453635748,
2382
+ 2870763221,
2383
+ 3624381080,
2384
+ 310598401,
2385
+ 607225278,
2386
+ 1426881987,
2387
+ 1925078388,
2388
+ 2162078206,
2389
+ 2614888103,
2390
+ 3248222580,
2391
+ 3835390401,
2392
+ 4022224774,
2393
+ 264347078,
2394
+ 604807628,
2395
+ 770255983,
2396
+ 1249150122,
2397
+ 1555081692,
2398
+ 1996064986,
2399
+ 2554220882,
2400
+ 2821834349,
2401
+ 2952996808,
2402
+ 3210313671,
2403
+ 3336571891,
2404
+ 3584528711,
2405
+ 113926993,
2406
+ 338241895,
2407
+ 666307205,
2408
+ 773529912,
2409
+ 1294757372,
2410
+ 1396182291,
2411
+ 1695183700,
2412
+ 1986661051,
2413
+ 2177026350,
2414
+ 2456956037,
2415
+ 2730485921,
2416
+ 2820302411,
2417
+ 3259730800,
2418
+ 3345764771,
2419
+ 3516065817,
2420
+ 3600352804,
2421
+ 4094571909,
2422
+ 275423344,
2423
+ 430227734,
2424
+ 506948616,
2425
+ 659060556,
2426
+ 883997877,
2427
+ 958139571,
2428
+ 1322822218,
2429
+ 1537002063,
2430
+ 1747873779,
2431
+ 1955562222,
2432
+ 2024104815,
2433
+ 2227730452,
2434
+ 2361852424,
2435
+ 2428436474,
2436
+ 2756734187,
2437
+ 3204031479,
2438
+ 3329325298
2192
2439
  ]);
2193
- var TLS_ERROR_CODES = new Set([
2194
- "SELF_SIGNED_CERT_IN_CHAIN",
2195
- "DEPTH_ZERO_SELF_SIGNED_CERT",
2196
- "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
2197
- "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
2198
- "UNABLE_TO_GET_ISSUER_CERT",
2199
- "CERT_HAS_EXPIRED",
2200
- "CERT_UNTRUSTED",
2201
- "ERR_TLS_CERT_ALTNAME_INVALID"
2440
+ var SHA256_INITIAL_STATE = new Uint32Array([
2441
+ 1779033703,
2442
+ 3144134277,
2443
+ 1013904242,
2444
+ 2773480762,
2445
+ 1359893119,
2446
+ 2600822924,
2447
+ 528734635,
2448
+ 1541459225
2202
2449
  ]);
2203
- var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
2204
- 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.";
2205
- var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
2206
- // ../../../node_modules/commander/esm.mjs
2207
- var import__ = __toESM(require_commander(), 1);
2208
- var {
2209
- program,
2210
- createCommand,
2211
- createArgument,
2212
- createOption,
2213
- CommanderError,
2214
- InvalidArgumentError,
2215
- InvalidOptionArgumentError,
2216
- Command,
2217
- Argument,
2218
- Option,
2219
- Help
2220
- } = import__.default;
2450
+ function rotr(value, bits) {
2451
+ return (value >>> bits | value << 32 - bits) >>> 0;
2452
+ }
2453
+ function sha256Hex(input) {
2454
+ const bytes = new TextEncoder().encode(input);
2455
+ const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
2456
+ const buffer = new Uint8Array(paddedLength);
2457
+ buffer.set(bytes);
2458
+ buffer[bytes.length] = 128;
2459
+ const view = new DataView(buffer.buffer);
2460
+ const bitLength = bytes.length * 8;
2461
+ view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
2462
+ view.setUint32(paddedLength - 4, bitLength >>> 0);
2463
+ const state = SHA256_INITIAL_STATE.slice();
2464
+ const schedule = new Uint32Array(64);
2465
+ for (let offset = 0;offset < paddedLength; offset += 64) {
2466
+ for (let i = 0;i < 16; i++) {
2467
+ schedule[i] = view.getUint32(offset + i * 4);
2468
+ }
2469
+ for (let i = 16;i < 64; i++) {
2470
+ const x = schedule[i - 15];
2471
+ const y = schedule[i - 2];
2472
+ const s0 = (rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3) >>> 0;
2473
+ const s1 = (rotr(y, 17) ^ rotr(y, 19) ^ y >>> 10) >>> 0;
2474
+ schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1 >>> 0;
2475
+ }
2476
+ let a = state[0];
2477
+ let b = state[1];
2478
+ let c = state[2];
2479
+ let d = state[3];
2480
+ let e = state[4];
2481
+ let f = state[5];
2482
+ let g = state[6];
2483
+ let h = state[7];
2484
+ for (let i = 0;i < 64; i++) {
2485
+ const s1 = (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) >>> 0;
2486
+ const ch = (e & f ^ ~e & g) >>> 0;
2487
+ const temp1 = h + s1 + ch + SHA256_K[i] + schedule[i] >>> 0;
2488
+ const s0 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) >>> 0;
2489
+ const maj = (a & b ^ a & c ^ b & c) >>> 0;
2490
+ const temp2 = s0 + maj >>> 0;
2491
+ h = g;
2492
+ g = f;
2493
+ f = e;
2494
+ e = d + temp1 >>> 0;
2495
+ d = c;
2496
+ c = b;
2497
+ b = a;
2498
+ a = temp1 + temp2 >>> 0;
2499
+ }
2500
+ state[0] = state[0] + a >>> 0;
2501
+ state[1] = state[1] + b >>> 0;
2502
+ state[2] = state[2] + c >>> 0;
2503
+ state[3] = state[3] + d >>> 0;
2504
+ state[4] = state[4] + e >>> 0;
2505
+ state[5] = state[5] + f >>> 0;
2506
+ state[6] = state[6] + g >>> 0;
2507
+ state[7] = state[7] + h >>> 0;
2508
+ }
2509
+ let hex = "";
2510
+ for (const word of state) {
2511
+ hex += word.toString(16).padStart(8, "0");
2512
+ }
2513
+ return hex;
2514
+ }
2515
+ function resolveSha256Hex() {
2516
+ try {
2517
+ const nodeCrypto = __require("node:crypto");
2518
+ const createHash = nodeCrypto?.createHash;
2519
+ if (typeof createHash !== "function") {
2520
+ return sha256Hex;
2521
+ }
2522
+ const native = (input) => createHash("sha256").update(input, "utf8").digest("hex");
2523
+ return native("abc") === sha256Hex("abc") ? native : sha256Hex;
2524
+ } catch {
2525
+ return sha256Hex;
2526
+ }
2527
+ }
2528
+ var cachedSha256Hex;
2529
+ function digest(input) {
2530
+ cachedSha256Hex ??= resolveSha256Hex();
2531
+ return cachedSha256Hex(input);
2532
+ }
2533
+ function pseudonymize(input) {
2534
+ return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
2535
+ }
2221
2536
 
2222
- // ../../common/src/command-examples.ts
2223
- var examplesByCommand = new WeakMap;
2224
- Command.prototype.examples = function(examples) {
2225
- examplesByCommand.set(this, examples);
2226
- return this;
2227
- };
2228
2537
  // ../../common/src/singleton.ts
2229
2538
  var PREFIX = "@uipath/common/";
2230
2539
  var _g = globalThis;
@@ -2255,67 +2564,423 @@ function singleton(ctorOrName) {
2255
2564
  };
2256
2565
  }
2257
2566
 
2258
- // ../../common/src/preview.ts
2259
- var previewSlot = singleton("PreviewBuild");
2260
- function isPreviewBuild() {
2261
- return previewSlot.get(false) ?? false;
2567
+ // ../../common/src/telemetry/supplied-values.ts
2568
+ var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
2569
+ function activeEntries() {
2570
+ const existing = suppliedValuesSlot.get();
2571
+ return Array.isArray(existing) ? existing : [];
2572
+ }
2573
+ var MIN_SCRUBBABLE_LENGTH = 4;
2574
+ function recordSuppliedArgumentValues(values) {
2575
+ const flat = [];
2576
+ const push = (value) => {
2577
+ if (Array.isArray(value)) {
2578
+ for (const item of value) {
2579
+ push(item);
2580
+ }
2581
+ return;
2582
+ }
2583
+ if (typeof value === "string" && value.length >= MIN_SCRUBBABLE_LENGTH) {
2584
+ flat.push(value);
2585
+ }
2586
+ };
2587
+ push(values);
2588
+ const entry = { values: flat };
2589
+ suppliedValuesSlot.set([...activeEntries(), entry]);
2590
+ return entry;
2262
2591
  }
2263
- Command.prototype.previewCommand = function(nameAndArgs, opts) {
2264
- if (isPreviewBuild()) {
2265
- return this.command(nameAndArgs, opts);
2592
+ function releaseSuppliedArgumentValues(entry) {
2593
+ suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
2594
+ }
2595
+ function getSuppliedArgumentValues() {
2596
+ const all = new Set;
2597
+ for (const entry of activeEntries()) {
2598
+ for (const value of entry.values) {
2599
+ all.add(value);
2600
+ }
2266
2601
  }
2267
- return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
2268
- };
2602
+ return [...all].sort((a, b) => b.length - a.length);
2603
+ }
2269
2604
 
2270
- // ../../common/src/output-context.ts
2271
- function createStorage() {
2272
- const [error, mod] = catchError2(() => __require("node:async_hooks"));
2273
- if (error || typeof mod?.AsyncLocalStorage !== "function") {
2274
- return {
2275
- getStore: () => {
2276
- return;
2277
- },
2278
- run: (_store, fn) => fn()
2279
- };
2280
- }
2281
- return new mod.AsyncLocalStorage;
2605
+ // ../../common/src/telemetry/pii-redactor.ts
2606
+ var REDACTED = "[REDACTED]";
2607
+ var MAX_VALUE_LENGTH = 280;
2608
+ var MAX_STACK_LENGTH = 4096;
2609
+ var MAX_SCAN_LENGTH = MAX_STACK_LENGTH;
2610
+ function truncate(value, maxLength) {
2611
+ return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;
2282
2612
  }
2283
- var storageSingleton = singleton("OutputStorage");
2284
- var sinkSlot = singleton("OutputSink");
2285
- var outputStorage = storageSingleton.getOrInit(createStorage, (v) => ("getStore" in v));
2286
- var CONSOLE_FALLBACK = {
2287
- writeOut: (str) => process.stdout.write(str),
2288
- writeErr: (str) => process.stderr.write(str),
2289
- writeLog: (str) => process.stdout.write(str),
2290
- capabilities: {
2291
- isInteractive: false,
2292
- canReadInput: false,
2293
- supportsColor: false,
2294
- outputWidth: 80
2613
+ var SENSITIVE_NAME_TOKENS = new Set([
2614
+ "token",
2615
+ "tokens",
2616
+ "secret",
2617
+ "secrets",
2618
+ "password",
2619
+ "passwords",
2620
+ "pwd",
2621
+ "credential",
2622
+ "credentials",
2623
+ "auth",
2624
+ "authentication",
2625
+ "authorization",
2626
+ "authority",
2627
+ "cert",
2628
+ "certificate",
2629
+ "certificates"
2630
+ ]);
2631
+ var SENSITIVE_KEY_PREFIXES = new Set([
2632
+ "api",
2633
+ "access",
2634
+ "client",
2635
+ "private",
2636
+ "public",
2637
+ "signing",
2638
+ "encryption",
2639
+ "session",
2640
+ "master",
2641
+ "shared",
2642
+ "root",
2643
+ "ssh",
2644
+ "rsa",
2645
+ "aes",
2646
+ "hmac",
2647
+ "oauth"
2648
+ ]);
2649
+ 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;
2650
+ var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
2651
+ var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
2652
+ var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
2653
+ var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
2654
+ var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
2655
+ var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
2656
+ var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
2657
+ 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;
2658
+ var SOURCE_FILE_EXTENSIONS = new Set([
2659
+ "ts",
2660
+ "tsx",
2661
+ "js",
2662
+ "jsx",
2663
+ "mjs",
2664
+ "cjs",
2665
+ "cts",
2666
+ "mts",
2667
+ "py",
2668
+ "cs",
2669
+ "java",
2670
+ "go",
2671
+ "rs",
2672
+ "rb",
2673
+ "php",
2674
+ "sh",
2675
+ "ps1",
2676
+ "json",
2677
+ "jsonc",
2678
+ "yaml",
2679
+ "yml",
2680
+ "xml",
2681
+ "xaml",
2682
+ "md",
2683
+ "txt",
2684
+ "log",
2685
+ "css",
2686
+ "html",
2687
+ "htm",
2688
+ "csproj",
2689
+ "nuspec",
2690
+ "sql"
2691
+ ]);
2692
+ var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
2693
+ var QUOTED_LITERAL_MAX_SPAN = 200;
2694
+ var QUOTED_LITERAL_PATTERN = new RegExp([
2695
+ `(?<![A-Za-z0-9])'(?:[^\\
2696
+ ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
2697
+ `(?<![A-Za-z0-9])"(?:[^\\
2698
+ ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
2699
+ ].join("|"), "g");
2700
+ var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
2701
+ var COLLAPSED_BODY = "{…}";
2702
+ var COLLAPSED_BODY_MARKER = "\x01body\x01";
2703
+ var MAX_BODY_NESTING = 8;
2704
+ function collapseJsonBodies(text) {
2705
+ let out = text;
2706
+ for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
2707
+ const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
2708
+ if (next === out) {
2709
+ break;
2710
+ }
2711
+ out = next;
2295
2712
  }
2296
- };
2297
- function getOutputSink() {
2298
- return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
2713
+ return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
2299
2714
  }
2300
-
2301
- // ../../common/src/logger.ts
2302
- var logFilePathSlot = singleton("logFilePath");
2303
- function setGlobalLogFilePath(path) {
2304
- logFilePathSlot.set(path);
2715
+ var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
2716
+ function peelTrailingPunctuation(match) {
2717
+ const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
2718
+ return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
2305
2719
  }
2306
- function getGlobalLogFilePath() {
2307
- return logFilePathSlot.get("");
2720
+ function redactUrl(raw) {
2721
+ try {
2722
+ const url = new URL(raw);
2723
+ return `${url.protocol}//${url.host}`;
2724
+ } catch {
2725
+ return `url#${pseudonymize(raw)}`;
2726
+ }
2308
2727
  }
2309
- var DEFAULT_LOG_LEVEL = 3 /* ERROR */;
2310
-
2311
- class SimpleLogger {
2312
- __brand = "SimpleLogger";
2313
- level;
2314
- logFilePath;
2315
- fileLoggingEnabled;
2316
- pendingWrites = Promise.resolve();
2317
- pendingInit = Promise.resolve();
2318
- constructor() {
2728
+ function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
2729
+ let out = truncate(value, MAX_SCAN_LENGTH);
2730
+ out = out.replace(JWT_PATTERN, () => REDACTED);
2731
+ out = out.replace(URL_PATTERN, (match) => {
2732
+ const [core, trailing] = peelTrailingPunctuation(match);
2733
+ return `${redactUrl(core)}${trailing}`;
2734
+ });
2735
+ out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
2736
+ out = out.replace(UNC_PATH_PATTERN, (_match, before, path2) => {
2737
+ const [core, trailing] = peelTrailingPunctuation(path2);
2738
+ return `${before}unc#${pseudonymize(core)}${trailing}`;
2739
+ });
2740
+ out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
2741
+ out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
2742
+ out = out.replace(HOST_PORT_PATTERN, (match) => {
2743
+ const split = match.lastIndexOf(":");
2744
+ const host = match.slice(0, split);
2745
+ const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
2746
+ if (SOURCE_FILE_EXTENSIONS.has(extension)) {
2747
+ return match;
2748
+ }
2749
+ return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
2750
+ });
2751
+ out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
2752
+ out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
2753
+ out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
2754
+ return truncate(out, maxLength);
2755
+ }
2756
+ function redactSpanName(name) {
2757
+ return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
2758
+ }
2759
+ var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
2760
+ function redactHttpDependencyName(name) {
2761
+ const parts = HTTP_DEPENDENCY_NAME.exec(name);
2762
+ if (!parts) {
2763
+ return redactMessage(name);
2764
+ }
2765
+ return `${parts[1]} ${redactMessage(parts[2])}`;
2766
+ }
2767
+ function redactMessage(value) {
2768
+ let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
2769
+ for (const supplied of getSuppliedArgumentValues()) {
2770
+ out = out.split(supplied).join(REDACTED);
2771
+ }
2772
+ return redactValueDetectors(out);
2773
+ }
2774
+ var MESSAGE_NAMES = new Set([
2775
+ "message",
2776
+ "errormessage",
2777
+ "errmessage",
2778
+ "error_message",
2779
+ "msg",
2780
+ "detail",
2781
+ "details",
2782
+ "reason",
2783
+ "instructions",
2784
+ "warning"
2785
+ ]);
2786
+ function isFreeFormValue(name, value) {
2787
+ return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
2788
+ }
2789
+ function redactError(error) {
2790
+ const safe = new Error(redactMessage(error.message ?? ""));
2791
+ safe.name = error.name;
2792
+ safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
2793
+ return safe;
2794
+ }
2795
+ function redactStack(stack) {
2796
+ const bounded = truncate(stack, MAX_STACK_LENGTH);
2797
+ const firstBreak = bounded.indexOf(`
2798
+ `);
2799
+ if (firstBreak === -1) {
2800
+ return redactMessage(bounded);
2801
+ }
2802
+ return `${redactMessage(bounded.slice(0, firstBreak))}
2803
+ ${redactValueDetectors(bounded.slice(firstBreak + 1), MAX_STACK_LENGTH)}`;
2804
+ }
2805
+ function nameTokens(name) {
2806
+ 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);
2807
+ }
2808
+ function isSensitiveName(name) {
2809
+ const tokens = nameTokens(name);
2810
+ for (let i = 0;i < tokens.length; i++) {
2811
+ const token = tokens[i];
2812
+ if (SENSITIVE_NAME_TOKENS.has(token)) {
2813
+ return true;
2814
+ }
2815
+ if (token === "key" || token === "keys") {
2816
+ const prev = tokens[i - 1];
2817
+ if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
2818
+ return true;
2819
+ }
2820
+ }
2821
+ }
2822
+ return false;
2823
+ }
2824
+ function redactProperty(name, value) {
2825
+ if (value === undefined || value === null) {
2826
+ return;
2827
+ }
2828
+ if (isSensitiveName(name)) {
2829
+ return REDACTED;
2830
+ }
2831
+ if (typeof value === "boolean" || typeof value === "number") {
2832
+ return value;
2833
+ }
2834
+ if (typeof value !== "string") {
2835
+ return "[OBJECT]";
2836
+ }
2837
+ return isFreeFormValue(name, value) ? redactMessage(value) : redactValueDetectors(value);
2838
+ }
2839
+ function redactProperties(properties) {
2840
+ const out = {};
2841
+ for (const [name, value] of Object.entries(properties)) {
2842
+ const redacted = redactProperty(name, value);
2843
+ if (redacted !== undefined) {
2844
+ out[name] = redacted;
2845
+ }
2846
+ }
2847
+ return out;
2848
+ }
2849
+
2850
+ // ../../common/src/catch-error.ts
2851
+ var MAX_SERIALIZED_LENGTH = 500;
2852
+ var TRUNCATION_SUFFIX = "…(truncated)";
2853
+ var REDACTED2 = "[REDACTED]";
2854
+ function cap(text) {
2855
+ return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
2856
+ }
2857
+ function omitSensitive(key, value) {
2858
+ return key.length > 0 && isSensitiveName(key) ? REDACTED2 : value;
2859
+ }
2860
+ function describeThrownValue(value) {
2861
+ if (typeof value !== "object" || value === null) {
2862
+ return String(value);
2863
+ }
2864
+ let message;
2865
+ try {
2866
+ message = value.message;
2867
+ } catch {
2868
+ message = undefined;
2869
+ }
2870
+ if (typeof message === "string" && message.length > 0) {
2871
+ return cap(message);
2872
+ }
2873
+ try {
2874
+ const json = JSON.stringify(value, omitSensitive);
2875
+ if (json !== undefined) {
2876
+ return cap(json);
2877
+ }
2878
+ } catch {}
2879
+ return String(value);
2880
+ }
2881
+ function toError(error) {
2882
+ return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
2883
+ }
2884
+ function isPromiseLike(value) {
2885
+ return value !== null && typeof value === "object" && typeof value.then === "function";
2886
+ }
2887
+ function catchError(fnOrPromise) {
2888
+ if (isPromiseLike(fnOrPromise)) {
2889
+ return settlePromiseLike(fnOrPromise);
2890
+ }
2891
+ try {
2892
+ const result = fnOrPromise();
2893
+ if (isPromiseLike(result)) {
2894
+ return settlePromiseLike(result);
2895
+ }
2896
+ return [undefined, result];
2897
+ } catch (error) {
2898
+ return [toError(error), undefined];
2899
+ }
2900
+ }
2901
+ function settlePromiseLike(thenable) {
2902
+ return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
2903
+ }
2904
+
2905
+ // ../../common/src/error-handler.ts
2906
+ var NETWORK_ERROR_CODES = new Set([
2907
+ "ECONNREFUSED",
2908
+ "ECONNRESET",
2909
+ "ENOTFOUND",
2910
+ "EAI_AGAIN",
2911
+ "ETIMEDOUT",
2912
+ "EPIPE",
2913
+ "EHOSTUNREACH",
2914
+ "ENETUNREACH",
2915
+ "EAI_FAIL"
2916
+ ]);
2917
+ var TLS_ERROR_CODES = new Set([
2918
+ "SELF_SIGNED_CERT_IN_CHAIN",
2919
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
2920
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
2921
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
2922
+ "UNABLE_TO_GET_ISSUER_CERT",
2923
+ "CERT_HAS_EXPIRED",
2924
+ "CERT_UNTRUSTED",
2925
+ "ERR_TLS_CERT_ALTNAME_INVALID"
2926
+ ]);
2927
+ var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
2928
+ 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.";
2929
+ var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
2930
+ // ../../common/src/exit-code.ts
2931
+ function setExitCode(code) {
2932
+ process.exitCode = code;
2933
+ }
2934
+
2935
+ // ../../common/src/output-context.ts
2936
+ function createStorage() {
2937
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
2938
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
2939
+ return {
2940
+ getStore: () => {
2941
+ return;
2942
+ },
2943
+ run: (_store, fn) => fn()
2944
+ };
2945
+ }
2946
+ return new mod.AsyncLocalStorage;
2947
+ }
2948
+ var storageSingleton = singleton("OutputStorage");
2949
+ var sinkSlot = singleton("OutputSink");
2950
+ var outputStorage = storageSingleton.getOrInit(createStorage, (v) => ("getStore" in v));
2951
+ var CONSOLE_FALLBACK = {
2952
+ writeOut: (str) => process.stdout.write(str),
2953
+ writeErr: (str) => process.stderr.write(str),
2954
+ writeLog: (str) => process.stdout.write(str),
2955
+ capabilities: {
2956
+ isInteractive: false,
2957
+ canReadInput: false,
2958
+ supportsColor: false,
2959
+ outputWidth: 80
2960
+ }
2961
+ };
2962
+ function getOutputSink() {
2963
+ return outputStorage.getStore() ?? sinkSlot.get() ?? CONSOLE_FALLBACK;
2964
+ }
2965
+
2966
+ // ../../common/src/logger.ts
2967
+ var logFilePathSlot = singleton("logFilePath");
2968
+ function setGlobalLogFilePath(path2) {
2969
+ logFilePathSlot.set(path2);
2970
+ }
2971
+ function getGlobalLogFilePath() {
2972
+ return logFilePathSlot.get("");
2973
+ }
2974
+ var DEFAULT_LOG_LEVEL = 3 /* ERROR */;
2975
+
2976
+ class SimpleLogger {
2977
+ __brand = "SimpleLogger";
2978
+ level;
2979
+ logFilePath;
2980
+ fileLoggingEnabled;
2981
+ pendingWrites = Promise.resolve();
2982
+ pendingInit = Promise.resolve();
2983
+ constructor() {
2319
2984
  this.level = SimpleLogger.resolveLevel();
2320
2985
  this.logFilePath = "";
2321
2986
  this.fileLoggingEnabled = false;
@@ -2338,7 +3003,7 @@ class SimpleLogger {
2338
3003
  }
2339
3004
  return DEFAULT_LOG_LEVEL;
2340
3005
  }
2341
- const [localStorageError, hasDebug] = catchError2(() => typeof localStorage !== "undefined" && !!localStorage.getItem("debug"));
3006
+ const [localStorageError, hasDebug] = catchError(() => typeof localStorage !== "undefined" && !!localStorage.getItem("debug"));
2342
3007
  if (!localStorageError && hasDebug) {
2343
3008
  return 0 /* DEBUG */;
2344
3009
  }
@@ -2369,54 +3034,49 @@ class SimpleLogger {
2369
3034
  return this.fileLoggingEnabled || !!getGlobalLogFilePath();
2370
3035
  }
2371
3036
  writeToFile(formatted) {
2372
- const path = this.logFilePath || getGlobalLogFilePath();
2373
- if (!path)
3037
+ const path2 = this.logFilePath || getGlobalLogFilePath();
3038
+ if (!path2)
2374
3039
  return;
2375
3040
  const timestamp = new Date().toISOString();
2376
3041
  this.pendingWrites = Promise.all([
2377
3042
  this.pendingWrites,
2378
3043
  this.pendingInit
2379
- ]).then(() => getFileSystem().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
3044
+ ]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
2380
3045
  }
2381
- debug(message, ...args) {
2382
- if (this.level > 0 /* DEBUG */)
2383
- return;
2384
- const formatted = this.format(`[DEBUG] ${message}`, args);
3046
+ write(formatted) {
2385
3047
  if (this.isFileLoggingActive()) {
2386
3048
  this.writeToFile(formatted);
2387
3049
  } else {
2388
3050
  getOutputSink().writeErr(formatted);
2389
3051
  }
2390
3052
  }
3053
+ debug(message, ...args) {
3054
+ if (this.level > 0 /* DEBUG */)
3055
+ return;
3056
+ const formatted = this.format(`[DEBUG] ${message}`, args);
3057
+ this.write(formatted);
3058
+ }
2391
3059
  info(message, ...args) {
2392
3060
  if (this.level > 1 /* INFO */)
2393
3061
  return;
2394
3062
  const formatted = this.format(message, args);
2395
- if (this.isFileLoggingActive()) {
2396
- this.writeToFile(formatted);
2397
- } else {
2398
- getOutputSink().writeErr(formatted);
2399
- }
3063
+ this.write(formatted);
2400
3064
  }
2401
3065
  warn(message, ...args) {
2402
3066
  if (this.level > 2 /* WARN */)
2403
3067
  return;
2404
3068
  const formatted = this.format(`[WARN] ${message}`, args);
2405
- if (this.isFileLoggingActive()) {
2406
- this.writeToFile(formatted);
2407
- } else {
2408
- getOutputSink().writeErr(formatted);
2409
- }
3069
+ this.write(formatted);
2410
3070
  }
2411
3071
  error(message, ...args) {
2412
3072
  if (this.level > 3 /* ERROR */)
2413
3073
  return;
2414
3074
  const formatted = this.format(`[ERROR] ${message}`, args);
2415
- if (this.isFileLoggingActive()) {
2416
- this.writeToFile(formatted);
2417
- } else {
2418
- getOutputSink().writeErr(formatted);
2419
- }
3075
+ this.write(formatted);
3076
+ }
3077
+ report(message) {
3078
+ const formatted = this.format(message, []);
3079
+ this.write(formatted);
2420
3080
  }
2421
3081
  getLevel() {
2422
3082
  return this.level;
@@ -2431,17 +3091,17 @@ class SimpleLogger {
2431
3091
  setGlobalLogFilePath("");
2432
3092
  }
2433
3093
  }
2434
- setLogFile(path) {
2435
- this.logFilePath = path;
2436
- setGlobalLogFilePath(path);
2437
- if (!path)
3094
+ setLogFile(path2) {
3095
+ this.logFilePath = path2;
3096
+ setGlobalLogFilePath(path2);
3097
+ if (!path2)
2438
3098
  return;
2439
3099
  this.fileLoggingEnabled = true;
2440
- const fs = getFileSystem();
3100
+ const fs2 = getFileSystem();
2441
3101
  this.pendingInit = (async () => {
2442
- const [error] = await catchError2((async () => {
2443
- await fs.mkdir(fs.path.dirname(path));
2444
- await fs.writeFile(path, "");
3102
+ const [error] = await catchError((async () => {
3103
+ await fs2.mkdir(fs2.path.dirname(path2));
3104
+ await fs2.writeFile(path2, "");
2445
3105
  })());
2446
3106
  if (error)
2447
3107
  this.fileLoggingEnabled = false;
@@ -2495,12 +3155,12 @@ var jmespathSlot = singleton("JmespathCodec");
2495
3155
  async function loadOutputCodecsAsync(needed) {
2496
3156
  const loads = [];
2497
3157
  if (needed.yaml && yamlSlot.get() === undefined) {
2498
- loads.push(import("./js-yaml-eydtmn4r.js").then((mod) => {
3158
+ loads.push(import("./js-yaml-71wj4em9.js").then((mod) => {
2499
3159
  yamlSlot.set(mod);
2500
3160
  }));
2501
3161
  }
2502
3162
  if (needed.filter && jmespathSlot.get() === undefined) {
2503
- loads.push(import("./index-xaqpc626.js").then((mod) => {
3163
+ loads.push(import("./index-q6vc5bja.js").then((mod) => {
2504
3164
  jmespathSlot.set(mod);
2505
3165
  }));
2506
3166
  }
@@ -2755,7 +3415,7 @@ function readRegistryValue(keyPath, valueName) {
2755
3415
  if (process.platform !== "win32") {
2756
3416
  return "";
2757
3417
  }
2758
- const [error, output] = catchError2(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
3418
+ const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
2759
3419
  encoding: "utf-8",
2760
3420
  stdio: ["pipe", "pipe", "pipe"]
2761
3421
  }));
@@ -2778,27 +3438,41 @@ class LoggerTelemetryProvider {
2778
3438
  ...this.analyticsUniqueId ? { analyticsUniqueId: this.analyticsUniqueId } : {}
2779
3439
  };
2780
3440
  }
2781
- async trackEvent(eventName, properties) {
2782
- logger.debug(formatMessage("Event", eventName, this.enrich(properties)));
3441
+ async trackEvent({ name, properties }) {
3442
+ logger.debug(formatMessage("Event", name, this.enrich(properties)));
2783
3443
  }
2784
- async trackException(error, properties) {
3444
+ async trackException({
3445
+ error,
3446
+ properties
3447
+ }) {
2785
3448
  logger.error(formatMessage("Exception", error.message, this.enrich({
2786
3449
  ...properties,
2787
3450
  stack: error.stack
2788
3451
  })));
2789
3452
  }
2790
- async trackRequest(name, duration, success, properties) {
3453
+ async trackRequest({
3454
+ name,
3455
+ durationMs,
3456
+ success,
3457
+ properties
3458
+ }) {
2791
3459
  logger.debug(formatMessage("Request", name, this.enrich({
2792
3460
  ...properties,
2793
- duration: `${duration}ms`,
3461
+ duration: `${durationMs}ms`,
2794
3462
  success
2795
3463
  })));
2796
3464
  }
2797
- async trackDependency(name, type, duration, success, properties) {
3465
+ async trackDependency({
3466
+ name,
3467
+ type,
3468
+ durationMs,
3469
+ success,
3470
+ properties
3471
+ }) {
2798
3472
  logger.debug(formatMessage("Dependency", name, this.enrich({
2799
3473
  ...properties,
2800
3474
  type,
2801
- duration: `${duration}ms`,
3475
+ duration: `${durationMs}ms`,
2802
3476
  success
2803
3477
  })));
2804
3478
  }
@@ -3054,144 +3728,16 @@ function getGlobalTelemetryProperties() {
3054
3728
  return telemetryPropsSlot.get();
3055
3729
  }
3056
3730
 
3057
- // ../../common/src/telemetry/pii-redactor.ts
3058
- var REDACTED = "[REDACTED]";
3059
- var MAX_VALUE_LENGTH = 200;
3060
- var SENSITIVE_NAME_TOKENS = new Set([
3061
- "token",
3062
- "tokens",
3063
- "secret",
3064
- "secrets",
3065
- "password",
3066
- "passwords",
3067
- "pwd",
3068
- "credential",
3069
- "credentials",
3070
- "auth",
3071
- "authentication",
3072
- "authorization",
3073
- "authority",
3074
- "cert",
3075
- "certificate",
3076
- "certificates"
3077
- ]);
3078
- var SENSITIVE_KEY_PREFIXES = new Set([
3079
- "api",
3080
- "access",
3081
- "client",
3082
- "private",
3083
- "public",
3084
- "signing",
3085
- "encryption",
3086
- "session",
3087
- "master",
3088
- "shared",
3089
- "root",
3090
- "ssh",
3091
- "rsa",
3092
- "aes",
3093
- "hmac",
3094
- "oauth"
3095
- ]);
3096
- 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;
3097
- var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
3098
- var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
3099
- var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
3100
- var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
3101
- var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
3102
- var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
3103
- function shortHash(input) {
3104
- let hash = 2166136261;
3105
- for (let i = 0;i < input.length; i++) {
3106
- hash ^= input.charCodeAt(i);
3107
- hash = Math.imul(hash, 16777619);
3108
- }
3109
- return (hash >>> 0).toString(16).padStart(8, "0");
3110
- }
3111
- function redactUrl(raw) {
3112
- try {
3113
- const url = new URL(raw);
3114
- return `${url.protocol}//${url.host}`;
3115
- } catch {
3116
- return `url#${shortHash(raw)}`;
3117
- }
3118
- }
3119
- function redactValueDetectors(value) {
3120
- let out = value;
3121
- out = out.replace(JWT_PATTERN, () => REDACTED);
3122
- out = out.replace(URL_PATTERN, (match) => {
3123
- const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
3124
- const core = trailing ? match.slice(0, -trailing.length) : match;
3125
- return `${redactUrl(core)}${trailing}`;
3126
- });
3127
- out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
3128
- out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
3129
- out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
3130
- out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
3131
- if (out.length > MAX_VALUE_LENGTH) {
3132
- out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
3133
- }
3134
- return out;
3135
- }
3136
- function redactValue(value) {
3137
- return redactValueDetectors(value);
3138
- }
3139
- function redactError(error) {
3140
- const safe = new Error(redactValueDetectors(error.message ?? ""));
3141
- safe.name = error.name;
3142
- safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
3143
- return safe;
3144
- }
3145
- function nameTokens(name) {
3146
- 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);
3147
- }
3148
- function isSensitiveName(name) {
3149
- const tokens = nameTokens(name);
3150
- for (let i = 0;i < tokens.length; i++) {
3151
- const token = tokens[i];
3152
- if (SENSITIVE_NAME_TOKENS.has(token)) {
3153
- return true;
3154
- }
3155
- if (token === "key" || token === "keys") {
3156
- const prev = tokens[i - 1];
3157
- if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
3158
- return true;
3159
- }
3160
- }
3161
- }
3162
- return false;
3163
- }
3164
- function redactProperty(name, value) {
3165
- if (value === undefined || value === null) {
3166
- return;
3167
- }
3168
- if (isSensitiveName(name)) {
3169
- return REDACTED;
3170
- }
3171
- if (typeof value === "boolean" || typeof value === "number") {
3172
- return value;
3173
- }
3174
- if (typeof value !== "string") {
3175
- return "[OBJECT]";
3176
- }
3177
- return redactValueDetectors(value);
3178
- }
3179
- function redactProperties(properties) {
3180
- const out = {};
3181
- for (const [name, value] of Object.entries(properties)) {
3182
- const redacted = redactProperty(name, value);
3183
- if (redacted !== undefined) {
3184
- out[name] = redacted;
3185
- }
3186
- }
3187
- return out;
3731
+ // ../../common/src/telemetry/span-clock.ts
3732
+ function startSpanClock() {
3733
+ const started = performance.now();
3734
+ return {
3735
+ startedAt: new Date(performance.timeOrigin + started),
3736
+ elapsedMs: () => performance.now() - started
3737
+ };
3188
3738
  }
3189
3739
 
3190
3740
  // ../../common/src/telemetry/telemetry-service.ts
3191
- var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
3192
- var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
3193
- var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
3194
-
3195
3741
  class TelemetryService {
3196
3742
  telemetryProvider;
3197
3743
  contextStorage;
@@ -3211,36 +3757,39 @@ class TelemetryService {
3211
3757
  this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
3212
3758
  }
3213
3759
  trackEvent(name, properties) {
3214
- const context = this.getCurrentContext();
3215
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3216
- this.telemetryProvider.trackEvent(name, enrichedProperties);
3760
+ this.telemetryProvider.trackEvent({
3761
+ name: redactSpanName(name),
3762
+ properties: this.enrichProperties(properties),
3763
+ ...this.leafCorrelation()
3764
+ });
3217
3765
  }
3218
- trackException(error, properties) {
3219
- const context = this.getCurrentContext();
3220
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3221
- this.telemetryProvider.trackException(redactError(error), enrichedProperties);
3766
+ trackException(error, properties, context) {
3767
+ this.telemetryProvider.trackException({
3768
+ error: redactError(error),
3769
+ properties: this.enrichProperties(properties),
3770
+ ...this.leafCorrelation(context)
3771
+ });
3222
3772
  }
3223
3773
  async trackRequest(name, fn, properties) {
3224
- const parentContext = this.getCurrentContext();
3774
+ const parentContext = this.getActiveContext();
3225
3775
  const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
3226
3776
  const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
3777
+ const clock = startSpanClock();
3227
3778
  const context = {
3228
3779
  operationId,
3229
3780
  ...parentId !== undefined ? { parentId } : {},
3230
- id: this.generateId()
3781
+ id: this.generateId(),
3782
+ startedAt: clock.startedAt
3231
3783
  };
3232
- const startTime = performance.now();
3233
3784
  try {
3234
3785
  const result = await this.contextStorage.run(context, fn);
3235
- const durationMs = performance.now() - startTime;
3236
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3237
- await this.telemetryProvider.trackRequest(name, durationMs, true, enrichedProperties);
3786
+ const durationMs = clock.elapsedMs();
3787
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, true, properties, context));
3238
3788
  return result;
3239
3789
  } catch (error) {
3240
- const durationMs = performance.now() - startTime;
3790
+ const durationMs = clock.elapsedMs();
3241
3791
  const err = error instanceof Error ? error : new Error(String(error));
3242
- const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, context);
3243
- await this.telemetryProvider.trackRequest(name, durationMs, false, enrichedProperties);
3792
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, context));
3244
3793
  throw error;
3245
3794
  }
3246
3795
  }
@@ -3249,8 +3798,7 @@ class TelemetryService {
3249
3798
  operationId: this.operationId ?? getTelemetryOperationId(),
3250
3799
  id: this.generateId()
3251
3800
  };
3252
- const enrichedProperties = this.enrichPropertiesWithContext(properties, requestContext);
3253
- this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
3801
+ this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, success, properties, requestContext));
3254
3802
  }
3255
3803
  createRequestContext() {
3256
3804
  const operationId = this.operationId ?? getTelemetryOperationId();
@@ -3258,7 +3806,8 @@ class TelemetryService {
3258
3806
  return {
3259
3807
  operationId,
3260
3808
  ...parentId !== undefined ? { parentId } : {},
3261
- id: this.generateId()
3809
+ id: this.generateId(),
3810
+ startedAt: startSpanClock().startedAt
3262
3811
  };
3263
3812
  }
3264
3813
  inboundParentIdFor(operationId) {
@@ -3269,58 +3818,84 @@ class TelemetryService {
3269
3818
  return this.contextStorage.run(context, fn);
3270
3819
  }
3271
3820
  createDependencyContext() {
3272
- const parentContext = this.getCurrentContext();
3821
+ const parentContext = this.getActiveContext();
3273
3822
  if (!parentContext) {
3274
3823
  return;
3275
3824
  }
3276
3825
  return {
3277
3826
  operationId: parentContext.operationId,
3278
3827
  parentId: parentContext.id,
3279
- id: this.generateId()
3828
+ id: this.generateId(),
3829
+ startedAt: startSpanClock().startedAt
3280
3830
  };
3281
3831
  }
3282
3832
  trackDependencyResult(name, type, durationMs, success, properties, context, resultCode) {
3283
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3284
- this.telemetryProvider.trackDependency(redactValue(name), type, durationMs, success, enrichedProperties, resultCode);
3833
+ this.telemetryProvider.trackDependency({
3834
+ ...this.spanFor(redactHttpDependencyName(name), durationMs, success, properties, context),
3835
+ type,
3836
+ ...resultCode !== undefined ? { resultCode } : {}
3837
+ });
3285
3838
  }
3286
3839
  async trackDependencyOperation(name, type, fn, properties) {
3287
- const parentContext = this.getCurrentContext();
3840
+ const clock = startSpanClock();
3841
+ const parentContext = this.getActiveContext();
3288
3842
  const childContext = parentContext !== undefined ? {
3289
3843
  operationId: parentContext.operationId,
3290
3844
  parentId: parentContext.id,
3291
- id: this.generateId()
3292
- } : this.createRequestContext();
3293
- const startTime = performance.now();
3845
+ id: this.generateId(),
3846
+ startedAt: clock.startedAt
3847
+ } : {
3848
+ ...this.createRequestContext(),
3849
+ startedAt: clock.startedAt
3850
+ };
3294
3851
  try {
3295
3852
  const result = await this.contextStorage.run(childContext, fn);
3296
- const durationMs = performance.now() - startTime;
3297
- const enrichedProperties = this.enrichPropertiesWithContext(properties, childContext);
3298
- await this.telemetryProvider.trackDependency(name, type, durationMs, true, enrichedProperties);
3853
+ const durationMs = clock.elapsedMs();
3854
+ await this.telemetryProvider.trackDependency({
3855
+ ...this.spanFor(name, durationMs, true, properties, childContext),
3856
+ type
3857
+ });
3299
3858
  return result;
3300
3859
  } catch (error) {
3301
- const durationMs = performance.now() - startTime;
3860
+ const durationMs = clock.elapsedMs();
3302
3861
  const err = error instanceof Error ? error : new Error(String(error));
3303
- const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, childContext);
3304
- await this.telemetryProvider.trackDependency(name, type, durationMs, false, enrichedProperties);
3862
+ await this.telemetryProvider.trackDependency({
3863
+ ...this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, childContext),
3864
+ type
3865
+ });
3305
3866
  throw error;
3306
3867
  }
3307
3868
  }
3308
- getCurrentContext() {
3869
+ getActiveContext() {
3309
3870
  return this.contextStorage.getContext();
3310
3871
  }
3311
- enrichPropertiesWithContext(properties, context) {
3872
+ leafCorrelation(explicit) {
3873
+ const context = explicit ?? this.getActiveContext();
3874
+ return {
3875
+ operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
3876
+ ...context !== undefined ? { parentId: context.id } : {}
3877
+ };
3878
+ }
3879
+ spanFor(name, durationMs, success, properties, context) {
3880
+ return {
3881
+ name: redactSpanName(name),
3882
+ durationMs,
3883
+ success,
3884
+ properties: this.enrichProperties(properties),
3885
+ operationId: context.operationId,
3886
+ ...context.parentId !== undefined ? { parentId: context.parentId } : {},
3887
+ id: context.id,
3888
+ ...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
3889
+ };
3890
+ }
3891
+ enrichProperties(properties) {
3312
3892
  const globalProperties = getGlobalTelemetryProperties();
3313
3893
  const enriched = {
3314
3894
  ...getExecutionContextTelemetryProperties(),
3315
3895
  ...globalProperties,
3316
3896
  ...this.defaultProperties,
3317
3897
  ...redactProperties(properties ?? {}),
3318
- [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
3319
- ...context ? {
3320
- [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
3321
- ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
3322
- [TELEMETRY_SPAN_ID_PROPERTY]: context.id
3323
- } : {}
3898
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
3324
3899
  };
3325
3900
  return enriched;
3326
3901
  }
@@ -3337,6 +3912,81 @@ class TelemetryService {
3337
3912
  return hex;
3338
3913
  }
3339
3914
  }
3915
+ // ../../common/src/timings.ts
3916
+ var TIMINGS_ENV_VAR = "UIP_TIMINGS";
3917
+ function createStorage2() {
3918
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
3919
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
3920
+ return {
3921
+ getStore: () => {
3922
+ return;
3923
+ },
3924
+ run: (_store, fn) => fn()
3925
+ };
3926
+ }
3927
+ return new mod.AsyncLocalStorage;
3928
+ }
3929
+ var storageSlot = singleton("TimingStorage");
3930
+ var stateSlot = singleton("Timings");
3931
+ var rootStartedSlot = singleton("TimingsRootStarted");
3932
+ var longLivedHostSlot = singleton("TimingsLongLivedHost");
3933
+ var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
3934
+ function newState(baseline) {
3935
+ return { baseline, httpMs: 0, httpCalls: 0 };
3936
+ }
3937
+ function getState() {
3938
+ const scoped = storage.getStore();
3939
+ if (scoped) {
3940
+ return scoped;
3941
+ }
3942
+ const pinned = livePinnedState();
3943
+ if (pinned !== undefined) {
3944
+ return pinned;
3945
+ }
3946
+ return newState(processStartIsInvocationStart() ? 0 : performance.now());
3947
+ }
3948
+ function livePinnedState() {
3949
+ const pinned = stateSlot.get();
3950
+ return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
3951
+ }
3952
+ function processStartIsInvocationStart() {
3953
+ return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
3954
+ }
3955
+ function timingsEnabled() {
3956
+ if (typeof process === "undefined") {
3957
+ return false;
3958
+ }
3959
+ const value = process.env?.[TIMINGS_ENV_VAR];
3960
+ if (value === undefined) {
3961
+ return false;
3962
+ }
3963
+ const normalized = value.trim().toLowerCase();
3964
+ return normalized === "1" || normalized === "true";
3965
+ }
3966
+ function recordExitCode(exitCode) {
3967
+ if (!timingsEnabled()) {
3968
+ return;
3969
+ }
3970
+ getState().exitCode = exitCode;
3971
+ }
3972
+ function invocationStartedAt() {
3973
+ return new Date(performance.timeOrigin + getState().baseline);
3974
+ }
3975
+ function invocationElapsedMs() {
3976
+ return performance.now() - getState().baseline;
3977
+ }
3978
+ function markCommandStart() {
3979
+ if (!timingsEnabled()) {
3980
+ return;
3981
+ }
3982
+ getState().commandStart = performance.now();
3983
+ }
3984
+ function recordCommandDuration(durationMs) {
3985
+ if (!timingsEnabled()) {
3986
+ return;
3987
+ }
3988
+ getState().commandMs = durationMs;
3989
+ }
3340
3990
  // ../../common/src/telemetry/proxy-http-agent.ts
3341
3991
  var slot = singleton("ProxyAuthHttpsAgent");
3342
3992
 
@@ -3357,6 +4007,9 @@ function getGlobalTelemetryInstance() {
3357
4007
  }
3358
4008
  return;
3359
4009
  }
4010
+ function setGlobalTelemetryInstance(instance) {
4011
+ telemetryInstanceSlot.set(instance);
4012
+ }
3360
4013
  var _localTelemetryInstance;
3361
4014
  function getTelemetryInstance() {
3362
4015
  const global = getGlobalTelemetryInstance();
@@ -3364,6 +4017,7 @@ function getTelemetryInstance() {
3364
4017
  return global;
3365
4018
  if (!_localTelemetryInstance) {
3366
4019
  _localTelemetryInstance = new TelemetryService(new LoggerTelemetryProvider, new NodeContextStorage);
4020
+ setGlobalTelemetryInstance(_localTelemetryInstance);
3367
4021
  }
3368
4022
  return _localTelemetryInstance;
3369
4023
  }
@@ -3376,6 +4030,14 @@ var telemetry = new Proxy({}, {
3376
4030
  });
3377
4031
 
3378
4032
  // ../../common/src/formatter.ts
4033
+ var ANSI_STYLES = {
4034
+ red: "\x1B[31m",
4035
+ dim: "\x1B[2m"
4036
+ };
4037
+ var ANSI_RESET = "\x1B[0m";
4038
+ function styleLine(line, style) {
4039
+ return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
4040
+ }
3379
4041
  var CLI_ERROR_CODES = [
3380
4042
  "invalid_argument",
3381
4043
  "authentication_required",
@@ -3414,22 +4076,6 @@ var EXIT_CODES = {
3414
4076
  ValidationError: 3,
3415
4077
  TimeoutError: 4
3416
4078
  };
3417
- class SuccessOutput {
3418
- Result = RESULTS.Success;
3419
- Code;
3420
- Data;
3421
- Pagination;
3422
- Instructions;
3423
- Log;
3424
- constructor(code, data) {
3425
- this.Code = code;
3426
- this.Data = data;
3427
- const logPath = getLogFilePath();
3428
- if (logPath) {
3429
- this.Log = logPath;
3430
- }
3431
- }
3432
- }
3433
4079
  function escapeNonAscii(jsonText) {
3434
4080
  return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
3435
4081
  const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
@@ -3494,19 +4140,45 @@ function toPascalCaseKey(key) {
3494
4140
  const lowerCamelKey = toLowerCamelCaseKey(key);
3495
4141
  return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
3496
4142
  }
3497
- function toPascalCaseData(value) {
4143
+ function collectVerbatimRefs(value, into) {
4144
+ if (typeof value !== "object" || value === null)
4145
+ return;
4146
+ if (into.has(value))
4147
+ return;
4148
+ into.add(value);
4149
+ for (const nested of Array.isArray(value) ? value : Object.values(value)) {
4150
+ collectVerbatimRefs(nested, into);
4151
+ }
4152
+ }
4153
+ function toPascalCaseData(value, verbatimKeys, subtrees) {
4154
+ if (subtrees?.mode === "skip" && typeof value === "object" && value !== null && subtrees.refs.has(value)) {
4155
+ return value;
4156
+ }
3498
4157
  if (Array.isArray(value))
3499
- return value.map(toPascalCaseData);
4158
+ return value.map((entry) => toPascalCaseData(entry, verbatimKeys, subtrees));
3500
4159
  if (!isPlainRecord(value))
3501
4160
  return value;
3502
4161
  const result = {};
3503
4162
  for (const [key, nestedValue] of Object.entries(value)) {
3504
- result[toPascalCaseKey(key)] = toPascalCaseData(nestedValue);
4163
+ const pascalKey = toPascalCaseKey(key);
4164
+ if (verbatimKeys?.has(pascalKey)) {
4165
+ result[pascalKey] = nestedValue;
4166
+ if (subtrees?.mode === "collect") {
4167
+ collectVerbatimRefs(nestedValue, subtrees.refs);
4168
+ }
4169
+ continue;
4170
+ }
4171
+ result[pascalKey] = toPascalCaseData(nestedValue, verbatimKeys, subtrees);
3505
4172
  }
3506
4173
  return result;
3507
4174
  }
3508
- function normalizeDataKeys(data) {
3509
- return toPascalCaseData(data);
4175
+ function normalizeDataKeys(data, verbatimKeys, subtrees) {
4176
+ return toPascalCaseData(data, verbatimKeys, subtrees);
4177
+ }
4178
+ function toVerbatimKeySet(preserve) {
4179
+ if (!Array.isArray(preserve))
4180
+ return;
4181
+ return new Set(preserve.map(toPascalCaseKey));
3510
4182
  }
3511
4183
  function normalizeOutputKeys(data) {
3512
4184
  const result = {};
@@ -3516,7 +4188,7 @@ function normalizeOutputKeys(data) {
3516
4188
  }
3517
4189
  return result;
3518
4190
  }
3519
- function printOutput(data, format = "json", logFn, asciiSafe = false) {
4191
+ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowStyle) {
3520
4192
  if (!data) {
3521
4193
  logFn("Empty response object. No data to display.");
3522
4194
  return;
@@ -3551,7 +4223,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
3551
4223
  if (hasData && !(rows !== null && rows.length === 0)) {
3552
4224
  const logValue = data.Log;
3553
4225
  if (rows !== null) {
3554
- printResizableTable(rows, logFn, logValue);
4226
+ printResizableTable(rows, logFn, logValue, undefined, tableRowStyle);
3555
4227
  } else {
3556
4228
  printVerticalTable(data.Data, logFn, logValue);
3557
4229
  }
@@ -3562,10 +4234,11 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
3562
4234
  }
3563
4235
  }
3564
4236
  }
3565
- function logOutput(data, format = "json") {
4237
+ function logOutput(data, format = "json", tableRowStyle) {
3566
4238
  const sink = getOutputSink();
4239
+ const styleFn = sink.capabilities.isInteractive && sink.capabilities.supportsColor ? tableRowStyle : undefined;
3567
4240
  printOutput(data, format, (msg) => sink.writeOut(`${msg}
3568
- `), needsAsciiSafeJson(sink));
4241
+ `), needsAsciiSafeJson(sink), styleFn);
3569
4242
  }
3570
4243
  function cellToString(val) {
3571
4244
  return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
@@ -3579,7 +4252,7 @@ function wrapText(text, width) {
3579
4252
  }
3580
4253
  return lines;
3581
4254
  }
3582
- function printTable(data, logFn, externalLogValue) {
4255
+ function printTable(data, logFn, externalLogValue, tableRowStyle) {
3583
4256
  if (data.length === 0)
3584
4257
  return;
3585
4258
  const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
@@ -3589,7 +4262,7 @@ function printTable(data, logFn, externalLogValue) {
3589
4262
  logFn(keys.map((_, i) => "-".repeat(maxWidths[i])).join("-|-"));
3590
4263
  data.forEach((item) => {
3591
4264
  const row = keys.map((key, i) => cellToString(item[key]).padEnd(maxWidths[i])).join(" | ");
3592
- logFn(row);
4265
+ logFn(styleLine(row, tableRowStyle?.(item)));
3593
4266
  });
3594
4267
  if (externalLogValue) {
3595
4268
  logFn("");
@@ -3632,14 +4305,14 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
3632
4305
  logFn(`Log: ${externalLogValue}`);
3633
4306
  }
3634
4307
  }
3635
- function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth) {
4308
+ function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
3636
4309
  if (data.length === 0)
3637
4310
  return;
3638
4311
  const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
3639
4312
  if (keys.length === 0)
3640
4313
  return;
3641
4314
  if (!process.stdout.isTTY) {
3642
- printTable(data, logFn, externalLogValue);
4315
+ printTable(data, logFn, externalLogValue, tableRowStyle);
3643
4316
  return;
3644
4317
  }
3645
4318
  const naturalWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
@@ -3647,7 +4320,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
3647
4320
  const totalWidth = naturalWidths.reduce((a, b) => a + b, 0) + separatorTotal;
3648
4321
  const termWidth = availableWidth ?? (process.stdout.columns || 120);
3649
4322
  if (totalWidth <= termWidth) {
3650
- printTable(data, logFn, externalLogValue);
4323
+ printTable(data, logFn, externalLogValue, tableRowStyle);
3651
4324
  return;
3652
4325
  }
3653
4326
  const overflow = totalWidth - termWidth;
@@ -3693,6 +4366,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
3693
4366
  logFn(header);
3694
4367
  logFn(keys.map((_, i) => "-".repeat(finalWidths[i])).join("-|-"));
3695
4368
  data.forEach((item) => {
4369
+ const style = tableRowStyle?.(item);
3696
4370
  const cellLines = keys.map((key, i) => wrapText(cellToString(item[key]), finalWidths[i]));
3697
4371
  const lineCount = Math.max(...cellLines.map((l) => l.length));
3698
4372
  for (let line = 0;line < lineCount; line++) {
@@ -3700,7 +4374,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
3700
4374
  const val = line < cellLines[i].length ? cellLines[i][line] : "";
3701
4375
  return val.padEnd(finalWidths[i]);
3702
4376
  }).join(" | ");
3703
- logFn(row);
4377
+ logFn(styleLine(row, style));
3704
4378
  }
3705
4379
  });
3706
4380
  if (externalLogValue) {
@@ -3844,30 +4518,36 @@ var OutputFormatter;
3844
4518
  ((OutputFormatter) => {
3845
4519
  function success(data, options) {
3846
4520
  data.Log ??= getLogFilePath() || undefined;
3847
- const normalize = !options?.preserveDataKeys;
4521
+ const normalize = options?.preserveDataKeys !== true;
4522
+ const verbatim = toVerbatimKeySet(options?.preserveDataKeys);
4523
+ const subtrees = verbatim && {
4524
+ refs: new Set,
4525
+ mode: "collect"
4526
+ };
3848
4527
  if (normalize) {
3849
- data.Data = normalizeDataKeys(data.Data);
4528
+ data.Data = normalizeDataKeys(data.Data, verbatim, subtrees);
3850
4529
  }
3851
4530
  const filter = getOutputFilter();
3852
4531
  if (filter) {
3853
4532
  const filtered = applyFilter(data.Data, filter);
3854
- data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
4533
+ data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
3855
4534
  }
3856
- logOutput(normalizeOutputKeys(data), getOutputFormat());
4535
+ logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
3857
4536
  }
3858
4537
  OutputFormatter.success = success;
3859
4538
  function error(data) {
3860
4539
  data.Log ??= getLogFilePath() || undefined;
3861
4540
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
3862
4541
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
3863
- process.exitCode = EXIT_CODES[data.Result] ?? 1;
4542
+ const exitCode = EXIT_CODES[data.Result] ?? 1;
4543
+ setExitCode(exitCode);
3864
4544
  recordCommandFailureTelemetry({
3865
4545
  result: data.Result,
3866
4546
  errorCode: data.ErrorCode,
3867
4547
  retry: data.Retry,
3868
4548
  message: data.Message,
3869
4549
  context: data.Context,
3870
- exitCode: process.exitCode,
4550
+ exitCode,
3871
4551
  errorClass: data.TelemetryErrorClass,
3872
4552
  terminalOutcome: data.TelemetryTerminalOutcome,
3873
4553
  terminalSignal: data.TelemetryTerminalSignal
@@ -3943,6 +4623,39 @@ var OutputFormatter;
3943
4623
  }
3944
4624
  OutputFormatter.formatToString = formatToString;
3945
4625
  })(OutputFormatter ||= {});
4626
+ // ../../../node_modules/commander/esm.mjs
4627
+ var import__ = __toESM(require_commander(), 1);
4628
+ var {
4629
+ program,
4630
+ createCommand,
4631
+ createArgument,
4632
+ createOption,
4633
+ CommanderError,
4634
+ InvalidArgumentError,
4635
+ InvalidOptionArgumentError,
4636
+ Command,
4637
+ Argument,
4638
+ Option,
4639
+ Help
4640
+ } = import__.default;
4641
+
4642
+ // ../../common/src/command-examples.ts
4643
+ var examplesByCommand = new WeakMap;
4644
+ Command.prototype.examples = function(examples) {
4645
+ examplesByCommand.set(this, examples);
4646
+ return this;
4647
+ };
4648
+ // ../../common/src/preview.ts
4649
+ var previewSlot = singleton("PreviewBuild");
4650
+ function isPreviewBuild() {
4651
+ return previewSlot.get(false) ?? false;
4652
+ }
4653
+ Command.prototype.previewCommand = function(nameAndArgs, opts) {
4654
+ if (isPreviewBuild()) {
4655
+ return this.command(nameAndArgs, opts);
4656
+ }
4657
+ return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
4658
+ };
3946
4659
 
3947
4660
  // ../../common/src/telemetry/command-attribution.ts
3948
4661
  var LEGACY_SKILL_NAMESPACE = "uipath:";
@@ -4097,6 +4810,57 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
4097
4810
  };
4098
4811
  }
4099
4812
 
4813
+ // ../../common/src/telemetry/command-name.ts
4814
+ var TELEMETRY_COMMAND_ROOT = "uip";
4815
+ function commandTelemetryName(parts) {
4816
+ const tokens = [];
4817
+ for (const part of parts) {
4818
+ const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== TELEMETRY_COMMAND_ROOT);
4819
+ if (pieces.every(isCommandToken)) {
4820
+ tokens.push(...pieces);
4821
+ continue;
4822
+ }
4823
+ tokens.push(UNKNOWN_TOKEN);
4824
+ }
4825
+ return [TELEMETRY_COMMAND_ROOT, ...tokens].join(".");
4826
+ }
4827
+ var COMMAND_TOKEN_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
4828
+ var MAX_COMMAND_TOKEN_LENGTH = 32;
4829
+ var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
4830
+ function isCommandToken(token) {
4831
+ return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token) && !/^\d+$/.test(token);
4832
+ }
4833
+ var UNKNOWN_TOKEN = "<unknown>";
4834
+
4835
+ // ../../common/src/telemetry/invocation-request.ts
4836
+ var requestContextSlot = singleton("TelemetryInvocationRequestContext");
4837
+ function activeContext() {
4838
+ return telemetry.getActiveContext?.();
4839
+ }
4840
+ function runWithInvocationRequest(fn) {
4841
+ const context = telemetry.createRequestContext();
4842
+ context.startedAt = invocationStartedAt();
4843
+ requestContextSlot.set(context);
4844
+ return telemetry.runWithContext(context, fn);
4845
+ }
4846
+ function ensureInvocationRequestScope(fn) {
4847
+ if (activeContext() !== undefined) {
4848
+ return fn();
4849
+ }
4850
+ const kept = requestContextSlot.get();
4851
+ return kept === undefined ? runWithInvocationRequest(fn) : telemetry.runWithContext(kept, fn);
4852
+ }
4853
+ function getInvocationRequestContext() {
4854
+ return activeContext() ?? requestContextSlot.get();
4855
+ }
4856
+ function emitInvocationRequest(name, success, properties) {
4857
+ const context = getInvocationRequestContext();
4858
+ telemetry.trackRequestResult(name, invocationElapsedMs(), success, properties, context);
4859
+ if (context !== undefined && requestContextSlot.get() === context) {
4860
+ requestContextSlot.clear();
4861
+ }
4862
+ }
4863
+
4100
4864
  // ../../common/src/trackedAction.ts
4101
4865
  var pollSignalSlot = singleton("PollSignal");
4102
4866
  var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
@@ -4104,28 +4868,74 @@ var retryHintValues = new Set(RETRY_HINTS);
4104
4868
  var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
4105
4869
  var processContext = {
4106
4870
  exit: (code) => {
4107
- process.exitCode = code;
4871
+ recordExitCode(code);
4872
+ setExitCode(code);
4108
4873
  },
4109
4874
  get pollSignal() {
4110
4875
  return pollSignalSlot.get();
4111
4876
  }
4112
4877
  };
4878
+ var TELEMETRY_ARG_VALUE_WITHHELD = "<provided>";
4879
+ var TELEMETRY_ARG_VALUE_DEFAULTED = "<default>";
4880
+ function recordableArgValue(value, choices) {
4881
+ if (typeof value === "boolean" || typeof value === "number") {
4882
+ return value;
4883
+ }
4884
+ if (choices && choices.length > 0) {
4885
+ if (typeof value === "string" && choices.includes(value)) {
4886
+ return value;
4887
+ }
4888
+ if (Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string" && choices.includes(entry))) {
4889
+ return value.join(",");
4890
+ }
4891
+ }
4892
+ return TELEMETRY_ARG_VALUE_WITHHELD;
4893
+ }
4113
4894
  function extractCommandParams(cmd) {
4114
4895
  const params = {};
4115
- const add = (name, value) => {
4116
- if (name && value !== undefined) {
4117
- params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = value;
4118
- }
4119
- };
4896
+ forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
4897
+ const recordable = recordableArgValue(value, choices);
4898
+ params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
4899
+ });
4900
+ return params;
4901
+ }
4902
+ function isDefaultedOption(cmd, name) {
4903
+ const source = cmd.getOptionValueSource?.(name);
4904
+ return source === "default" || source === "implied";
4905
+ }
4906
+ function isDefaultedPositional(cmd, index) {
4907
+ return index >= (cmd.args?.length ?? 0);
4908
+ }
4909
+ function forEachSuppliedArgument(cmd, visit) {
4120
4910
  const registered = cmd.registeredArguments ?? [];
4121
4911
  const processed = cmd.processedArgs ?? [];
4122
4912
  for (let i = 0;i < registered.length; i++) {
4123
- add(registered[i].name(), processed[i]);
4913
+ const name = registered[i].name();
4914
+ if (name && processed[i] !== undefined) {
4915
+ visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
4916
+ }
4917
+ }
4918
+ const choicesByAttribute = new Map;
4919
+ for (const option of cmd.options) {
4920
+ choicesByAttribute.set(option.attributeName(), option.argChoices);
4124
4921
  }
4125
4922
  for (const [key, value] of Object.entries(cmd.opts())) {
4126
- add(key, value);
4923
+ if (key && value !== undefined) {
4924
+ visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
4925
+ }
4127
4926
  }
4128
- return params;
4927
+ }
4928
+ function withheldArgumentValues(cmd) {
4929
+ const values = [];
4930
+ forEachSuppliedArgument(cmd, (_name, value, choices, defaulted) => {
4931
+ if (defaulted) {
4932
+ return;
4933
+ }
4934
+ if (recordableArgValue(value, choices) === TELEMETRY_ARG_VALUE_WITHHELD) {
4935
+ values.push(value);
4936
+ }
4937
+ });
4938
+ return values;
4129
4939
  }
4130
4940
  function deriveCommandPath(cmd) {
4131
4941
  const parts = [];
@@ -4140,7 +4950,7 @@ function deriveCommandPath(cmd) {
4140
4950
  if (parts.length > 1) {
4141
4951
  parts.shift();
4142
4952
  }
4143
- return ["uip", ...parts.filter((p) => p !== "uip")].join(".");
4953
+ return commandTelemetryName(parts);
4144
4954
  }
4145
4955
  function isCliErrorCode(value) {
4146
4956
  return typeof value === "string" && cliErrorCodeValues.has(value);
@@ -4180,68 +4990,77 @@ Command.prototype.trackedAction = function(context, fn, properties) {
4180
4990
  });
4181
4991
  const telemetryName = deriveCommandPath(command);
4182
4992
  const props = typeof properties === "function" ? properties(...args) : properties;
4183
- const requestContext = telemetry.createRequestContext();
4184
- const startTime = performance.now();
4185
- let errorMessage;
4186
- let fallbackExitCode = EXIT_CODES.Success;
4187
- clearRecordedCommandFailureTelemetry();
4188
- const [error] = await catchError2(telemetry.runWithContext(requestContext, () => {
4189
- const violation = implicitLimitViolation(command);
4190
- if (violation) {
4191
- return Promise.reject(violation);
4192
- }
4193
- return fn(...args);
4194
- }));
4195
- if (error) {
4196
- errorMessage = error instanceof Error ? error.message : String(error);
4197
- logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
4198
- const typed = error;
4199
- const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
4200
- const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
4201
- const finalResult = customResult ?? RESULTS.Failure;
4202
- const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
4203
- const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
4204
- const typedRetry = typed.retry ?? typed.Retry;
4205
- const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
4206
- const typedContext = typed.context ?? typed.Context;
4207
- const customContext = isErrorContext(typedContext) ? typedContext : undefined;
4208
- const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
4209
- fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
4210
- OutputFormatter.error({
4211
- Result: finalResult,
4212
- ...customErrorCode ? { ErrorCode: customErrorCode } : {},
4213
- Message: errorMessage,
4214
- Instructions: customInstructions ?? commandHelpHint(telemetryName),
4215
- ...customRetry ? { Retry: customRetry } : {},
4216
- ...customContext ? { Context: customContext } : {}
4993
+ markCommandStart();
4994
+ const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
4995
+ try {
4996
+ const startTime = performance.now();
4997
+ let errorMessage;
4998
+ let fallbackExitCode = EXIT_CODES.Success;
4999
+ clearRecordedCommandFailureTelemetry();
5000
+ const [error] = await catchError(ensureInvocationRequestScope(() => {
5001
+ const violation = implicitLimitViolation(command);
5002
+ if (violation) {
5003
+ return Promise.reject(violation);
5004
+ }
5005
+ return fn(...args);
5006
+ }));
5007
+ if (error) {
5008
+ errorMessage = error instanceof Error ? error.message : String(error);
5009
+ logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
5010
+ const typed = error;
5011
+ const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
5012
+ const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
5013
+ const finalResult = customResult ?? RESULTS.Failure;
5014
+ const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
5015
+ const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
5016
+ const typedRetry = typed.retry ?? typed.Retry;
5017
+ const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
5018
+ const typedContext = typed.context ?? typed.Context;
5019
+ const customContext = isErrorContext(typedContext) ? typedContext : undefined;
5020
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
5021
+ fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
5022
+ OutputFormatter.error({
5023
+ Result: finalResult,
5024
+ ...customErrorCode ? { ErrorCode: customErrorCode } : {},
5025
+ Message: errorMessage,
5026
+ Instructions: customInstructions ?? commandHelpHint(telemetryName),
5027
+ ...customRetry ? { Retry: customRetry } : {},
5028
+ ...customContext ? { Context: customContext } : {}
5029
+ });
5030
+ context.exit(fallbackExitCode);
5031
+ }
5032
+ const durationMs = performance.now() - startTime;
5033
+ recordCommandDuration(durationMs);
5034
+ const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
5035
+ const recordedFailure = takeRecordedCommandFailureTelemetry();
5036
+ const success = !error && exitCode === 0;
5037
+ const terminalTelemetry = buildCommandTerminalTelemetryProperties({
5038
+ error,
5039
+ exitCode,
5040
+ recordedFailure,
5041
+ pollSignal: context.pollSignal
4217
5042
  });
4218
- context.exit(fallbackExitCode);
4219
- }
4220
- const durationMs = performance.now() - startTime;
4221
- const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
4222
- const recordedFailure = takeRecordedCommandFailureTelemetry();
4223
- const success = !error && exitCode === 0;
4224
- const terminalTelemetry = buildCommandTerminalTelemetryProperties({
4225
- error,
4226
- exitCode,
4227
- recordedFailure,
4228
- pollSignal: context.pollSignal
4229
- });
4230
- const commandParams = extractCommandParams(command);
4231
- if (props) {
4232
- for (const key of Object.keys(props)) {
4233
- delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
4234
- }
4235
- }
4236
- const baseProperties = redactProperties({
4237
- ...commandParams,
4238
- ...props,
4239
- ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
4240
- command: "true",
4241
- ...terminalTelemetry,
4242
- ...errorMessage ? { errorMessage } : {}
4243
- });
4244
- telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
5043
+ if (terminalTelemetry.error_class === "internal" && error) {
5044
+ telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { command_name: telemetryName }, getInvocationRequestContext());
5045
+ }
5046
+ const commandParams = extractCommandParams(command);
5047
+ if (props) {
5048
+ for (const key of Object.keys(props)) {
5049
+ delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
5050
+ }
5051
+ }
5052
+ const baseProperties = redactProperties({
5053
+ ...commandParams,
5054
+ ...props,
5055
+ ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
5056
+ command: "true",
5057
+ ...terminalTelemetry,
5058
+ ...errorMessage ? { errorMessage } : {}
5059
+ });
5060
+ emitInvocationRequest(telemetryName, success, baseProperties);
5061
+ } finally {
5062
+ releaseSuppliedArgumentValues(supplied);
5063
+ }
4245
5064
  });
4246
5065
  };
4247
5066
  // ../../common/src/completer.ts
@@ -4251,6 +5070,204 @@ var guardInstalledSlot = singleton("ConsoleGuardInstalled");
4251
5070
  var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
4252
5071
  // ../../common/src/constants.ts
4253
5072
  var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
5073
+ // ../../common/src/entity-name-rules.ts
5074
+ var RESERVED_SQL_KEYWORDS_LOWER = new Set(["group", "order"]);
5075
+ var RESERVED_FIELD_NAMES_LOWER = new Set([
5076
+ "id",
5077
+ "createdby",
5078
+ "createtime",
5079
+ "updatedby",
5080
+ "updatetime",
5081
+ "recordowner",
5082
+ "version"
5083
+ ]);
5084
+ var RESERVED_KEYWORDS_LOWER = new Set([
5085
+ "abstract",
5086
+ "as",
5087
+ "base",
5088
+ "bool",
5089
+ "break",
5090
+ "byte",
5091
+ "case",
5092
+ "catch",
5093
+ "char",
5094
+ "checked",
5095
+ "class",
5096
+ "const",
5097
+ "continue",
5098
+ "decimal",
5099
+ "default",
5100
+ "delegate",
5101
+ "do",
5102
+ "double",
5103
+ "else",
5104
+ "enum",
5105
+ "event",
5106
+ "explicit",
5107
+ "extern",
5108
+ "false",
5109
+ "finally",
5110
+ "fixed",
5111
+ "float",
5112
+ "for",
5113
+ "foreach",
5114
+ "goto",
5115
+ "if",
5116
+ "implicit",
5117
+ "in",
5118
+ "int",
5119
+ "interface",
5120
+ "internal",
5121
+ "is",
5122
+ "lock",
5123
+ "long",
5124
+ "namespace",
5125
+ "new",
5126
+ "null",
5127
+ "object",
5128
+ "operator",
5129
+ "out",
5130
+ "override",
5131
+ "params",
5132
+ "private",
5133
+ "protected",
5134
+ "public",
5135
+ "readonly",
5136
+ "ref",
5137
+ "return",
5138
+ "sbyte",
5139
+ "sealed",
5140
+ "short",
5141
+ "sizeof",
5142
+ "stackalloc",
5143
+ "static",
5144
+ "string",
5145
+ "struct",
5146
+ "switch",
5147
+ "this",
5148
+ "throw",
5149
+ "true",
5150
+ "try",
5151
+ "typeof",
5152
+ "uint",
5153
+ "ulong",
5154
+ "unchecked",
5155
+ "unsafe",
5156
+ "ushort",
5157
+ "using",
5158
+ "virtual",
5159
+ "void",
5160
+ "volatile",
5161
+ "while",
5162
+ "addhandler",
5163
+ "addressof",
5164
+ "alias",
5165
+ "and",
5166
+ "andalso",
5167
+ "boolean",
5168
+ "byref",
5169
+ "byval",
5170
+ "call",
5171
+ "cbool",
5172
+ "cbyte",
5173
+ "cchar",
5174
+ "cdate",
5175
+ "cdbl",
5176
+ "cdec",
5177
+ "cint",
5178
+ "clng",
5179
+ "cobj",
5180
+ "csbyte",
5181
+ "cshort",
5182
+ "csng",
5183
+ "cstr",
5184
+ "ctype",
5185
+ "cuint",
5186
+ "culng",
5187
+ "cushort",
5188
+ "date",
5189
+ "declare",
5190
+ "dim",
5191
+ "directcast",
5192
+ "each",
5193
+ "elseif",
5194
+ "end",
5195
+ "endif",
5196
+ "erase",
5197
+ "error",
5198
+ "exit",
5199
+ "friend",
5200
+ "function",
5201
+ "get",
5202
+ "gettype",
5203
+ "getxmlnamespace",
5204
+ "global",
5205
+ "gosub",
5206
+ "goto",
5207
+ "handles",
5208
+ "implements",
5209
+ "imports",
5210
+ "inherits",
5211
+ "integer",
5212
+ "isnot",
5213
+ "let",
5214
+ "lib",
5215
+ "like",
5216
+ "loop",
5217
+ "me",
5218
+ "mod",
5219
+ "module",
5220
+ "mustinherit",
5221
+ "mustoverride",
5222
+ "mybase",
5223
+ "myclass",
5224
+ "narrowing",
5225
+ "next",
5226
+ "not",
5227
+ "nothing",
5228
+ "notinheritable",
5229
+ "notoverridable",
5230
+ "of",
5231
+ "on",
5232
+ "option",
5233
+ "optional",
5234
+ "or",
5235
+ "orelse",
5236
+ "overloads",
5237
+ "overridable",
5238
+ "overrides",
5239
+ "paramarray",
5240
+ "partial",
5241
+ "property",
5242
+ "raiseevent",
5243
+ "redim",
5244
+ "rem",
5245
+ "removehandler",
5246
+ "resume",
5247
+ "select",
5248
+ "set",
5249
+ "shadows",
5250
+ "shared",
5251
+ "single",
5252
+ "step",
5253
+ "stop",
5254
+ "structure",
5255
+ "sub",
5256
+ "synclock",
5257
+ "then",
5258
+ "to",
5259
+ "trycast",
5260
+ "uinteger",
5261
+ "ushort",
5262
+ "variant",
5263
+ "wend",
5264
+ "when",
5265
+ "widening",
5266
+ "with",
5267
+ "withevents",
5268
+ "writeonly",
5269
+ "xor"
5270
+ ]);
4254
5271
  // ../../common/src/host-global-options.ts
4255
5272
  var HOST_GLOBAL_OPTIONS_WITH_VALUE = [
4256
5273
  "--output",
@@ -4349,6 +5366,40 @@ function addSdkUserAgentHeader(headers, userAgent) {
4349
5366
  var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
4350
5367
  // ../../common/src/tool-provider.ts
4351
5368
  var factorySlot = singleton("PackagerFactoryProvider");
5369
+ // ../../auth/src/catch-error.ts
5370
+ function isPromiseLike2(value) {
5371
+ return value !== null && typeof value === "object" && typeof value.then === "function";
5372
+ }
5373
+ function catchError2(fnOrPromise) {
5374
+ if (isPromiseLike2(fnOrPromise)) {
5375
+ return settlePromiseLike2(fnOrPromise);
5376
+ }
5377
+ try {
5378
+ const result = fnOrPromise();
5379
+ if (isPromiseLike2(result)) {
5380
+ return settlePromiseLike2(result);
5381
+ }
5382
+ return [undefined, result];
5383
+ } catch (error) {
5384
+ return [
5385
+ error instanceof Error ? error : new Error(String(error)),
5386
+ undefined
5387
+ ];
5388
+ }
5389
+ }
5390
+ function settlePromiseLike2(thenable) {
5391
+ return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
5392
+ error instanceof Error ? error : new Error(String(error)),
5393
+ undefined
5394
+ ]);
5395
+ }
5396
+
5397
+ // ../../auth/src/constants.ts
5398
+ var UIPATH_HOME_DIR = ".uipath";
5399
+ var AUTH_FILENAME = ".auth";
5400
+ var DEFAULT_BASE_URL = "https://cloud.uipath.com";
5401
+ var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
5402
+
4352
5403
  // ../../auth/src/config.ts
4353
5404
  var DEFAULT_CLIENT_ID = "36dea5b8-e8bb-423d-8e7b-c808df8f1c00";
4354
5405
  var AUTH_FILE_CONFIG_KEY = Symbol.for("@uipath/auth/AuthFileConfig");
@@ -4362,7 +5413,7 @@ class InvalidBaseUrlError extends Error {
4362
5413
  super(`Invalid base URL: "${url}"
4363
5414
  ` + `Reason: ${reason}
4364
5415
 
4365
- ` + `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>).
5416
+ ` + `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>).
4366
5417
  ` + `You can specify the URL via:
4367
5418
  ` + ` • --authority flag
4368
5419
  ` + ` • UIPATH_URL environment variable
@@ -4383,10 +5434,16 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
4383
5434
  while (baseUrl.endsWith("/")) {
4384
5435
  baseUrl = baseUrl.slice(0, -1);
4385
5436
  }
5437
+ const hasScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(baseUrl);
5438
+ const [hostCandidate] = baseUrl.split(/[/?#]/, 1);
5439
+ if (!hasScheme && hostCandidate.includes(".")) {
5440
+ baseUrl = `https://${baseUrl}`;
5441
+ }
4386
5442
  const resolvedBaseUrl = baseUrl;
4387
- const [urlError, url] = catchError(() => new URL(resolvedBaseUrl));
5443
+ const [urlError, url] = catchError2(() => new URL(resolvedBaseUrl));
4388
5444
  if (urlError) {
4389
- throw new InvalidBaseUrlError(baseUrl, `Malformed URL. ${urlError instanceof Error ? urlError.message : "Unknown error"}`);
5445
+ 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"}`;
5446
+ throw new InvalidBaseUrlError(baseUrl, `Malformed URL.${shapeHint}`);
4390
5447
  }
4391
5448
  if (url.protocol !== "https:") {
4392
5449
  throw new InvalidBaseUrlError(baseUrl, `Authority must use https:// scheme, got ${url.protocol}//. OIDC token exchange requires TLS end-to-end.`);
@@ -4441,6 +5498,11 @@ var resolveConfigAsync = async ({
4441
5498
  };
4442
5499
  };
4443
5500
 
5501
+ // ../../auth/src/utils/platform.ts
5502
+ function isBrowser() {
5503
+ return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
5504
+ }
5505
+
4444
5506
  // ../../auth/src/authProfile.ts
4445
5507
  var DEFAULT_AUTH_PROFILE = "default";
4446
5508
  var PROFILE_DIR = "profiles";
@@ -4452,7 +5514,7 @@ function isAuthProfileStorage(value) {
4452
5514
  return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
4453
5515
  }
4454
5516
  function createProfileStorage() {
4455
- const [error, mod] = catchError(() => __require("node:async_hooks"));
5517
+ const [error, mod] = catchError2(() => __require("node:async_hooks"));
4456
5518
  if (error || typeof mod?.AsyncLocalStorage !== "function") {
4457
5519
  return {
4458
5520
  getStore: () => {
@@ -4468,9 +5530,9 @@ function getProfileStorage() {
4468
5530
  if (isAuthProfileStorage(existing)) {
4469
5531
  return existing;
4470
5532
  }
4471
- const storage = createProfileStorage();
4472
- globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
4473
- return storage;
5533
+ const storage2 = createProfileStorage();
5534
+ globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage2;
5535
+ return storage2;
4474
5536
  }
4475
5537
  var profileStorage = getProfileStorage();
4476
5538
 
@@ -4501,8 +5563,8 @@ function resolveAuthProfileFilePath(profile) {
4501
5563
  if (normalized === undefined) {
4502
5564
  throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
4503
5565
  }
4504
- const fs = getFileSystem();
4505
- return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
5566
+ const fs2 = getFileSystem();
5567
+ return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
4506
5568
  }
4507
5569
  function getActiveAuthProfileFilePath() {
4508
5570
  const profile = getActiveAuthProfile();
@@ -4583,7 +5645,7 @@ var getTokenExpiration = (accessToken) => {
4583
5645
  // ../../auth/src/sessionIdentity.ts
4584
5646
  var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
4585
5647
  var decodeClaims = (accessToken) => {
4586
- const [error, claims] = catchError(() => parseJWT(accessToken));
5648
+ const [error, claims] = catchError2(() => parseJWT(accessToken));
4587
5649
  return error ? undefined : claims;
4588
5650
  };
4589
5651
  var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
@@ -4667,27 +5729,48 @@ var requireEnv = (name) => {
4667
5729
  }
4668
5730
  return value;
4669
5731
  };
5732
+ var OPAQUE_TOKEN_BASE_URL_VAR = "UIPATH_URL";
5733
+ var resolveBaseUrl = (rawUrl, failureContext) => {
5734
+ const [baseUrlError, baseUrl] = catchError2(() => normalizeAndValidateBaseUrl(rawUrl));
5735
+ if (baseUrlError) {
5736
+ if (baseUrlError instanceof InvalidBaseUrlError) {
5737
+ throw baseUrlError;
5738
+ }
5739
+ throw new EnvAuthConfigError(`${failureContext}: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
5740
+ }
5741
+ return baseUrl;
5742
+ };
4670
5743
  var readAuthFromEnv = () => {
4671
5744
  const accessToken = requireEnv(ENV_AUTH_VARS.token);
4672
5745
  const organizationName = requireEnv(ENV_AUTH_VARS.organizationName);
4673
5746
  const organizationId = requireEnv(ENV_AUTH_VARS.organizationId);
4674
5747
  const tenantName = requireEnv(ENV_AUTH_VARS.tenantName);
4675
5748
  const tenantId = requireEnv(ENV_AUTH_VARS.tenantId);
4676
- const [parseError, payload] = catchError(() => parseJWT(accessToken));
5749
+ const [parseError, payload] = catchError2(() => parseJWT(accessToken));
4677
5750
  if (parseError) {
4678
- throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} is not a valid JWT: ` + `${parseError instanceof Error ? parseError.message : String(parseError)}`);
5751
+ const parseErrorMessage = parseError instanceof Error ? parseError.message : String(parseError);
5752
+ const rawUrl = process.env[OPAQUE_TOKEN_BASE_URL_VAR];
5753
+ if (!rawUrl) {
5754
+ 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}).`);
5755
+ }
5756
+ const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
5757
+ return {
5758
+ loginStatus: "Logged in",
5759
+ accessToken,
5760
+ baseUrl: baseUrl2,
5761
+ organizationName,
5762
+ organizationId,
5763
+ tenantName,
5764
+ tenantId,
5765
+ source: "env-vars" /* EnvironmentVariables */,
5766
+ 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}`
5767
+ };
4679
5768
  }
4680
5769
  const iss = payload.iss;
4681
5770
  if (typeof iss !== "string" || iss.length === 0) {
4682
5771
  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.`);
4683
5772
  }
4684
- const [baseUrlError, baseUrl] = catchError(() => normalizeAndValidateBaseUrl(iss));
4685
- if (baseUrlError) {
4686
- if (baseUrlError instanceof InvalidBaseUrlError) {
4687
- throw baseUrlError;
4688
- }
4689
- throw new EnvAuthConfigError(`Failed to derive server URL from token 'iss' claim: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
4690
- }
5773
+ const baseUrl = resolveBaseUrl(iss, "Failed to derive server URL from token 'iss' claim");
4691
5774
  const expiration = getTokenExpiration(accessToken);
4692
5775
  const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
4693
5776
  const identity = resolveSessionIdentity(accessToken);
@@ -4713,8 +5796,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
4713
5796
  async function refreshTokenFingerprint(refreshToken) {
4714
5797
  const bytes = new TextEncoder().encode(refreshToken);
4715
5798
  if (globalThis.crypto?.subtle) {
4716
- const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
4717
- return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
5799
+ const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
5800
+ return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
4718
5801
  }
4719
5802
  const { createHash } = await import("node:crypto");
4720
5803
  return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
@@ -4723,9 +5806,9 @@ function breakerPathFor(authPath) {
4723
5806
  return `${authPath}${BREAKER_SUFFIX}`;
4724
5807
  }
4725
5808
  async function loadRefreshBreaker(authPath) {
4726
- const fs = getFileSystem();
5809
+ const fs2 = getFileSystem();
4727
5810
  try {
4728
- const content = await fs.readFile(breakerPathFor(authPath), "utf-8");
5811
+ const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
4729
5812
  if (!content)
4730
5813
  return {};
4731
5814
  const parsed = JSON.parse(content);
@@ -4736,20 +5819,20 @@ async function loadRefreshBreaker(authPath) {
4736
5819
  }
4737
5820
  async function saveRefreshBreaker(authPath, state) {
4738
5821
  try {
4739
- const fs = getFileSystem();
4740
- const path = breakerPathFor(authPath);
4741
- await fs.mkdir(fs.path.dirname(path));
4742
- const tempPath = `${path}.tmp`;
4743
- await fs.writeFile(tempPath, JSON.stringify(state));
4744
- await fs.rename(tempPath, path);
5822
+ const fs2 = getFileSystem();
5823
+ const path2 = breakerPathFor(authPath);
5824
+ await fs2.mkdir(fs2.path.dirname(path2));
5825
+ const tempPath = `${path2}.tmp`;
5826
+ await fs2.writeFile(tempPath, JSON.stringify(state));
5827
+ await fs2.rename(tempPath, path2);
4745
5828
  } catch {}
4746
5829
  }
4747
5830
  async function clearRefreshBreaker(authPath) {
4748
- const fs = getFileSystem();
4749
- const path = breakerPathFor(authPath);
5831
+ const fs2 = getFileSystem();
5832
+ const path2 = breakerPathFor(authPath);
4750
5833
  try {
4751
- if (await fs.exists(path)) {
4752
- await fs.rm(path);
5834
+ if (await fs2.exists(path2)) {
5835
+ await fs2.rm(path2);
4753
5836
  }
4754
5837
  } catch {}
4755
5838
  }
@@ -4770,43 +5853,43 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
4770
5853
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
4771
5854
  var PIPE_NAME_MAX_LENGTH = 103;
4772
5855
  var getRobotIpcPipeNames = async () => {
4773
- const fs = getFileSystem();
4774
- const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
5856
+ const fs2 = getFileSystem();
5857
+ const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
4775
5858
  if (!username) {
4776
5859
  throw new Error("Unable to determine current username");
4777
5860
  }
4778
- const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
4779
- return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
5861
+ const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
5862
+ return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
4780
5863
  };
4781
5864
  var defaultIsRobotIpcAvailable = async () => {
4782
5865
  if (process.platform === "win32") {
4783
5866
  return true;
4784
5867
  }
4785
- const [pipeNamesError, pipeNames] = await catchError(getRobotIpcPipeNames());
5868
+ const [pipeNamesError, pipeNames] = await catchError2(getRobotIpcPipeNames());
4786
5869
  if (pipeNamesError || !pipeNames) {
4787
5870
  return false;
4788
5871
  }
4789
- const fs = getFileSystem();
5872
+ const fs2 = getFileSystem();
4790
5873
  for (const pipeName of pipeNames) {
4791
- const [existsError, exists] = await catchError(fs.exists(pipeName));
5874
+ const [existsError, exists] = await catchError2(fs2.exists(pipeName));
4792
5875
  if (!existsError && exists === true) {
4793
5876
  return true;
4794
5877
  }
4795
5878
  }
4796
5879
  return false;
4797
5880
  };
4798
- var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
5881
+ var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
4799
5882
  const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
4800
5883
  promise.then((value) => {
4801
5884
  clearTimeout(timer);
4802
- resolve(value);
5885
+ resolve2(value);
4803
5886
  }, (error) => {
4804
5887
  clearTimeout(timer);
4805
5888
  reject(error);
4806
5889
  });
4807
5890
  });
4808
5891
  var parseResourceUrl = (url) => {
4809
- const [error, parsed] = catchError(() => new URL(url));
5892
+ const [error, parsed] = catchError2(() => new URL(url));
4810
5893
  if (error || !parsed)
4811
5894
  return;
4812
5895
  const segments = parsed.pathname.split("/").filter(Boolean);
@@ -4826,7 +5909,7 @@ var defaultLoadModule = async () => {
4826
5909
  if (!hostLoader) {
4827
5910
  return;
4828
5911
  }
4829
- const [error, mod] = await catchError(() => hostLoader());
5912
+ const [error, mod] = await catchError2(() => hostLoader());
4830
5913
  if (error || !mod) {
4831
5914
  return;
4832
5915
  }
@@ -4852,7 +5935,7 @@ var tryRobotClientFallback = async (options = {}) => {
4852
5935
  const mod = await loadModule();
4853
5936
  if (!mod)
4854
5937
  return;
4855
- const [ctorError, proxy] = catchError(() => new mod.RobotProxyConstructor);
5938
+ const [ctorError, proxy] = catchError2(() => new mod.RobotProxyConstructor);
4856
5939
  if (ctorError || !proxy) {
4857
5940
  return;
4858
5941
  }
@@ -4875,7 +5958,7 @@ var tryRobotClientFallback = async (options = {}) => {
4875
5958
  let organizationIdFromToken;
4876
5959
  let tenantIdFromToken;
4877
5960
  let issuerFromToken;
4878
- const [jwtError, claims] = catchError(() => parseJWT(accessToken));
5961
+ const [jwtError, claims] = catchError2(() => parseJWT(accessToken));
4879
5962
  if (!jwtError && claims) {
4880
5963
  const rawOrgId = claims.prtId ?? claims.organizationId ?? claims.prt_id;
4881
5964
  if (typeof rawOrgId === "string" && rawOrgId.length > 0) {
@@ -4902,7 +5985,7 @@ var tryRobotClientFallback = async (options = {}) => {
4902
5985
  } catch {
4903
5986
  return;
4904
5987
  } finally {
4905
- await catchError(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
5988
+ await catchError2(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
4906
5989
  }
4907
5990
  };
4908
5991
 
@@ -4972,9 +6055,9 @@ var errorCode = (err) => {
4972
6055
  }
4973
6056
  return "EUNKNOWN";
4974
6057
  };
4975
- var probeAsync = async (fs, candidate) => {
6058
+ var probeAsync = async (fs2, candidate) => {
4976
6059
  try {
4977
- const stats = await fs.stat(candidate);
6060
+ const stats = await fs2.stat(candidate);
4978
6061
  if (stats === null) {
4979
6062
  return { exists: false };
4980
6063
  }
@@ -5001,9 +6084,9 @@ var probeAsync = async (fs, candidate) => {
5001
6084
  }
5002
6085
  };
5003
6086
  var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
5004
- const fs = getFileSystem();
5005
- if (fs.path.isAbsolute(envFilePath)) {
5006
- const probe2 = await probeAsync(fs, envFilePath);
6087
+ const fs2 = getFileSystem();
6088
+ if (fs2.path.isAbsolute(envFilePath)) {
6089
+ const probe2 = await probeAsync(fs2, envFilePath);
5007
6090
  return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
5008
6091
  exists: false,
5009
6092
  absolutePath: envFilePath,
@@ -5011,11 +6094,11 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
5011
6094
  ...probe2.unusable ? { unusable: probe2.unusable } : {}
5012
6095
  };
5013
6096
  }
5014
- const cwd = opts?.cwd ?? fs.env.cwd();
6097
+ const cwd = opts?.cwd ?? fs2.env.cwd();
5015
6098
  let searchDir = cwd;
5016
6099
  while (true) {
5017
- const candidate = fs.path.join(searchDir, envFilePath);
5018
- const probe2 = await probeAsync(fs, candidate);
6100
+ const candidate = fs2.path.join(searchDir, envFilePath);
6101
+ const probe2 = await probeAsync(fs2, candidate);
5019
6102
  if (probe2.exists) {
5020
6103
  return {
5021
6104
  exists: true,
@@ -5023,14 +6106,14 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
5023
6106
  source: searchDir === cwd ? "cwd" : "ancestor"
5024
6107
  };
5025
6108
  }
5026
- const parentDir = fs.path.dirname(searchDir);
6109
+ const parentDir = fs2.path.dirname(searchDir);
5027
6110
  if (parentDir === searchDir) {
5028
6111
  break;
5029
6112
  }
5030
6113
  searchDir = parentDir;
5031
6114
  }
5032
- const homePath = fs.path.join(fs.env.homedir(), envFilePath);
5033
- const probe = await probeAsync(fs, homePath);
6115
+ const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
6116
+ const probe = await probeAsync(fs2, homePath);
5034
6117
  if (probe.exists) {
5035
6118
  return { exists: true, absolutePath: homePath, source: "home" };
5036
6119
  }
@@ -5052,12 +6135,12 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
5052
6135
  };
5053
6136
  };
5054
6137
  var loadEnvFileAsync = async ({ envPath }) => {
5055
- const fs = getFileSystem();
5056
- const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
5057
- if (!await fs.exists(absolutePath)) {
6138
+ const fs2 = getFileSystem();
6139
+ const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
6140
+ if (!await fs2.exists(absolutePath)) {
5058
6141
  throw new Error(`Environment file not found: ${envPath}`);
5059
6142
  }
5060
- const content = await fs.readFile(absolutePath, "utf-8");
6143
+ const content = await fs2.readFile(absolutePath, "utf-8");
5061
6144
  if (content === null) {
5062
6145
  throw new Error(`Environment file not found: ${envPath}`);
5063
6146
  }
@@ -5086,10 +6169,10 @@ var saveEnvFileAsync = async ({
5086
6169
  data,
5087
6170
  merge = true
5088
6171
  }) => {
5089
- const fs = getFileSystem();
5090
- const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
6172
+ const fs2 = getFileSystem();
6173
+ const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
5091
6174
  let existingData = {};
5092
- if (merge && await fs.exists(absolutePath)) {
6175
+ if (merge && await fs2.exists(absolutePath)) {
5093
6176
  try {
5094
6177
  existingData = await loadEnvFileAsync({ envPath: absolutePath });
5095
6178
  } catch {}
@@ -5107,11 +6190,11 @@ var saveEnvFileAsync = async ({
5107
6190
  const content = `${lines.join(`
5108
6191
  `)}
5109
6192
  `;
5110
- const dir = fs.path.dirname(absolutePath);
5111
- await fs.mkdir(dir);
6193
+ const dir = fs2.path.dirname(absolutePath);
6194
+ await fs2.mkdir(dir);
5112
6195
  const tempPath = `${absolutePath}.tmp`;
5113
- await fs.writeFile(tempPath, content);
5114
- await fs.rename(tempPath, absolutePath);
6196
+ await fs2.writeFile(tempPath, content);
6197
+ await fs2.rename(tempPath, absolutePath);
5115
6198
  };
5116
6199
 
5117
6200
  // ../../auth/src/loginStatus.ts
@@ -5225,11 +6308,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
5225
6308
  return { credentials };
5226
6309
  }
5227
6310
  async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
5228
- const fs = getFs();
5229
- const globalPath = fs.path.join(fs.env.homedir(), envFilePath);
6311
+ const fs2 = getFs();
6312
+ const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
5230
6313
  if (absolutePath === globalPath)
5231
6314
  return;
5232
- if (!await fs.exists(globalPath))
6315
+ if (!await fs2.exists(globalPath))
5233
6316
  return;
5234
6317
  try {
5235
6318
  const globalCreds = await loadEnvFile({ envPath: globalPath });
@@ -5979,7 +7062,7 @@ function reportProbeUnavailable(probe, instructions) {
5979
7062
  }
5980
7063
  var PROBE_FAILED_INSTRUCTIONS = "Check the connection is enabled with 'uip is connections list --connection-id <id> --all-folders', and confirm the validator type is exposed with 'uip guardrails byo-configurations list-validators --connection-id <id>'.";
5981
7064
  async function probeOrAbort(request, loginValidity, failureMessage) {
5982
- const [probeError, probe] = await catchError2(probeByoGuardrailConfiguration(request, { loginValidity }));
7065
+ const [probeError, probe] = await catchError(probeByoGuardrailConfiguration(request, { loginValidity }));
5983
7066
  if (probeError) {
5984
7067
  reportByoGuardrailError(probeError, failureMessage);
5985
7068
  return null;
@@ -5993,7 +7076,7 @@ async function probeOrAbort(request, loginValidity, failureMessage) {
5993
7076
  var registerByoConfigurationsCommands = (program2) => {
5994
7077
  const byoConfigurations = program2.command("byo-configurations").description("Manage bring-your-own guardrail (BYOG) configurations for the tenant (Admin -> AI Trust Layer -> Guardrails Configurations)");
5995
7078
  byoConfigurations.command("list").description("List bring-your-own guardrail (BYOG) configurations for the authenticated tenant, including connection details").examples(BYO_CONFIGURATIONS_LIST_EXAMPLES).trackedAction(processContext, async () => {
5996
- const [error, configurations] = await catchError2(getByoGuardrailConfigurations());
7079
+ const [error, configurations] = await catchError(getByoGuardrailConfigurations());
5997
7080
  if (error) {
5998
7081
  reportByoGuardrailError(error, "Failed to list BYO guardrail configurations");
5999
7082
  return;
@@ -6011,7 +7094,7 @@ var registerByoConfigurationsCommands = (program2) => {
6011
7094
  }, options.loginValidity, "Failed to probe BYO guardrail configuration before create");
6012
7095
  if (!probe)
6013
7096
  return;
6014
- const [error, configuration] = await catchError2(createByoGuardrailConfiguration({
7097
+ const [error, configuration] = await catchError(createByoGuardrailConfiguration({
6015
7098
  connectionId: options.connectionId,
6016
7099
  validatorName: options.validatorName,
6017
7100
  validatorType: options.validatorType,
@@ -6038,7 +7121,7 @@ var registerByoConfigurationsCommands = (program2) => {
6038
7121
  processContext.exit(1);
6039
7122
  return;
6040
7123
  }
6041
- const [fetchError, existing] = await catchError2(getByoGuardrailConfigurationById(configurationId, {
7124
+ const [fetchError, existing] = await catchError(getByoGuardrailConfigurationById(configurationId, {
6042
7125
  loginValidity: options.loginValidity
6043
7126
  }));
6044
7127
  if (fetchError) {
@@ -6053,7 +7136,7 @@ var registerByoConfigurationsCommands = (program2) => {
6053
7136
  if (!probe)
6054
7137
  return;
6055
7138
  }
6056
- const [error, configuration] = await catchError2(updateByoGuardrailConfiguration(configurationId, {
7139
+ const [error, configuration] = await catchError(updateByoGuardrailConfiguration(configurationId, {
6057
7140
  connectionId: options.connectionId ?? existing.connectionId,
6058
7141
  fallbackOnUiPath: options.fallbackOnUiPath ?? existing.fallbackOnUiPath,
6059
7142
  enabled: options.disabled ? false : options.enabled ?? existing.enabled
@@ -6078,7 +7161,7 @@ var registerByoConfigurationsCommands = (program2) => {
6078
7161
  processContext.exit(1);
6079
7162
  return;
6080
7163
  }
6081
- const [error] = await catchError2(deleteByoGuardrailConfiguration(configurationId, {
7164
+ const [error] = await catchError(deleteByoGuardrailConfiguration(configurationId, {
6082
7165
  loginValidity: options.loginValidity
6083
7166
  }));
6084
7167
  if (error) {
@@ -6105,7 +7188,7 @@ var registerByoConfigurationsCommands = (program2) => {
6105
7188
  });
6106
7189
  });
6107
7190
  byoConfigurations.command("list-validators").description("List the validators an Integration Service connection exposes. Each Validator value is a valid --validator-type for 'probe' and 'create'.").requiredOption("--connection-id <guid>", "Integration Service connection GUID to inspect.").option("--login-validity <minutes>", "Override the interactive-login token lifetime for this call.", (v) => Number.parseInt(v, 10)).examples(BYO_CONFIGURATIONS_LIST_VALIDATORS_EXAMPLES).trackedAction(processContext, async (options) => {
6108
- const [error, validators] = await catchError2(getByoGuardrailConnectionValidators(options.connectionId, {
7191
+ const [error, validators] = await catchError(getByoGuardrailConnectionValidators(options.connectionId, {
6109
7192
  loginValidity: options.loginValidity
6110
7193
  }));
6111
7194
  if (error) {
@@ -6131,8 +7214,8 @@ var registerCommands = async (program2) => {
6131
7214
  registerByoConfigurationsCommands(program2);
6132
7215
  };
6133
7216
  export {
6134
- registerCommands,
6135
- metadata
7217
+ metadata,
7218
+ registerCommands
6136
7219
  };
6137
7220
 
6138
- //# debugId=03DD5709DCA3278464756E2164756E21
7221
+ //# debugId=48EDD3CE27B5E10564756E2164756E21