@uipath/conversational-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.
@@ -1,23 +1,11 @@
1
- import {
2
- isBrowser
3
- } from "./tool-9qecd4wb.js";
4
- import {
5
- catchError,
6
- getFileSystem
7
- } from "./tool-4pvh3k50.js";
8
- import {
9
- AUTH_FILENAME,
10
- DEFAULT_BASE_URL,
11
- UIPATH_HOME_DIR
12
- } from "./tool-5arsyj36.js";
13
1
  import {
14
2
  __commonJS,
15
3
  __require,
16
4
  __toESM
17
- } from "./tool-wckvcay0.js";
5
+ } from "./tool-1yh8g550.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,7 +723,7 @@ 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
729
  var path = __require("node:path");
@@ -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/conversational-tool",
2114
2102
  license: "MIT",
2115
- version: "1.201.0",
2103
+ version: "1.202.0-preview.136",
2116
2104
  description: "Handle conversations with deployed UiPath conversational processes.",
2117
2105
  publishConfig: {
2118
2106
  registry: "https://npm.pkg.github.com/"
@@ -2233,11 +2221,723 @@ function addSdkUserAgentHeader(headers, userAgent) {
2233
2221
  return result;
2234
2222
  }
2235
2223
 
2224
+ // ../filesystem/src/node.ts
2225
+ import { randomUUID } from "node:crypto";
2226
+ import { existsSync } from "node:fs";
2227
+ import * as fs from "node:fs/promises";
2228
+ import * as os from "node:os";
2229
+ import * as path from "node:path";
2230
+ var LOCK_HEARTBEAT_MS = 5000;
2231
+ var LOCK_STALE_MS = 15000;
2232
+ var LOCK_MAX_WAIT_MS = 20000;
2233
+ var LOCK_MAX_HOLD_MS = 60000;
2234
+ var LOCK_RETRY_MIN_MS = 100;
2235
+ var LOCK_RETRY_JITTER_MS = 200;
2236
+
2237
+ class NodeFileSystem {
2238
+ path = {
2239
+ join: path.join,
2240
+ resolve: path.resolve,
2241
+ relative: path.relative,
2242
+ dirname: path.dirname,
2243
+ isAbsolute: path.isAbsolute,
2244
+ basename: path.basename
2245
+ };
2246
+ env = {
2247
+ cwd: process.cwd,
2248
+ homedir: os.homedir,
2249
+ tmpdir: os.tmpdir,
2250
+ getenv: (key) => process.env[key]
2251
+ };
2252
+ utils = {
2253
+ open: async (url) => {
2254
+ const { default: open } = await import("./index-h8cph72k.js");
2255
+ await open(url);
2256
+ }
2257
+ };
2258
+ async readFile(path2, options) {
2259
+ try {
2260
+ if (options) {
2261
+ return await fs.readFile(path2, "utf-8");
2262
+ }
2263
+ return await fs.readFile(path2);
2264
+ } catch (error) {
2265
+ if (this.isEnoent(error))
2266
+ return null;
2267
+ throw error;
2268
+ }
2269
+ }
2270
+ async writeFile(filePath, data) {
2271
+ const dir = path.dirname(filePath);
2272
+ if (dir) {
2273
+ await fs.mkdir(dir, { recursive: true });
2274
+ }
2275
+ await fs.writeFile(filePath, data);
2276
+ }
2277
+ async appendFile(filePath, data) {
2278
+ const dir = path.dirname(filePath);
2279
+ if (dir) {
2280
+ await fs.mkdir(dir, { recursive: true });
2281
+ }
2282
+ await fs.appendFile(filePath, data);
2283
+ }
2284
+ async readdir(dirPath) {
2285
+ try {
2286
+ return await fs.readdir(dirPath);
2287
+ } catch (error) {
2288
+ if (this.isEnoent(error))
2289
+ return [];
2290
+ throw error;
2291
+ }
2292
+ }
2293
+ async stat(filePath) {
2294
+ try {
2295
+ const stats = await fs.stat(filePath);
2296
+ return {
2297
+ isFile: () => stats.isFile(),
2298
+ isDirectory: () => stats.isDirectory(),
2299
+ size: stats.size,
2300
+ mtimeMs: stats.mtimeMs
2301
+ };
2302
+ } catch (error) {
2303
+ if (this.isEnoent(error))
2304
+ return null;
2305
+ throw error;
2306
+ }
2307
+ }
2308
+ async exists(filePath) {
2309
+ return existsSync(filePath);
2310
+ }
2311
+ async mkdir(dirPath) {
2312
+ await fs.mkdir(dirPath, { recursive: true });
2313
+ }
2314
+ async acquireLock(lockPath) {
2315
+ const canonicalPath = await this.canonicalizeLockTarget(lockPath);
2316
+ const lockFile = `${canonicalPath}.lock`;
2317
+ const ownerId = randomUUID();
2318
+ const start = Date.now();
2319
+ while (true) {
2320
+ try {
2321
+ await fs.writeFile(lockFile, ownerId, { flag: "wx" });
2322
+ return this.createLockRelease(lockFile, ownerId);
2323
+ } catch (error) {
2324
+ if (!this.hasErrnoCode(error, "EEXIST")) {
2325
+ throw error;
2326
+ }
2327
+ const stats = await fs.stat(lockFile).catch(() => null);
2328
+ if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
2329
+ const reclaimed = await fs.rm(lockFile, { force: true }).then(() => true).catch(() => false);
2330
+ if (reclaimed)
2331
+ continue;
2332
+ }
2333
+ if (Date.now() - start > LOCK_MAX_WAIT_MS) {
2334
+ throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
2335
+ }
2336
+ await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
2337
+ }
2338
+ }
2339
+ }
2340
+ async canonicalizeLockTarget(lockPath) {
2341
+ const absolute = path.resolve(lockPath);
2342
+ const fullReal = await fs.realpath(absolute).catch(() => null);
2343
+ if (fullReal)
2344
+ return fullReal;
2345
+ const parent = path.dirname(absolute);
2346
+ const base = path.basename(absolute);
2347
+ const canonicalParent = await fs.realpath(parent).catch(() => parent);
2348
+ return path.join(canonicalParent, base);
2349
+ }
2350
+ createLockRelease(lockFile, ownerId) {
2351
+ const heartbeatStart = Date.now();
2352
+ let heartbeatTimer;
2353
+ let stopped = false;
2354
+ const stopHeartbeat = () => {
2355
+ stopped = true;
2356
+ if (heartbeatTimer)
2357
+ clearTimeout(heartbeatTimer);
2358
+ };
2359
+ const scheduleNextHeartbeat = () => {
2360
+ if (stopped)
2361
+ return;
2362
+ if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
2363
+ stopped = true;
2364
+ return;
2365
+ }
2366
+ heartbeatTimer = setTimeout(() => {
2367
+ runHeartbeat();
2368
+ }, LOCK_HEARTBEAT_MS);
2369
+ heartbeatTimer.unref?.();
2370
+ };
2371
+ const runHeartbeat = async () => {
2372
+ if (stopped)
2373
+ return;
2374
+ const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
2375
+ if (stopped)
2376
+ return;
2377
+ if (current !== ownerId) {
2378
+ stopped = true;
2379
+ return;
2380
+ }
2381
+ const now = Date.now() / 1000;
2382
+ await fs.utimes(lockFile, now, now).catch(() => {});
2383
+ scheduleNextHeartbeat();
2384
+ };
2385
+ scheduleNextHeartbeat();
2386
+ let released = false;
2387
+ return async () => {
2388
+ if (released)
2389
+ return;
2390
+ released = true;
2391
+ stopHeartbeat();
2392
+ const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
2393
+ if (current === ownerId) {
2394
+ await fs.rm(lockFile, { force: true });
2395
+ }
2396
+ };
2397
+ }
2398
+ async rm(filePath) {
2399
+ await fs.rm(filePath, { recursive: true, force: true });
2400
+ }
2401
+ async rename(oldPath, newPath) {
2402
+ await fs.rename(oldPath, newPath);
2403
+ }
2404
+ async realpath(filePath) {
2405
+ try {
2406
+ return await fs.realpath(filePath);
2407
+ } catch (error) {
2408
+ if (this.isEnoent(error))
2409
+ return filePath;
2410
+ throw error;
2411
+ }
2412
+ }
2413
+ async getTempDir() {
2414
+ return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
2415
+ }
2416
+ async copyDirectory(sourcePath, destPath) {
2417
+ const sourceStats = await this.stat(sourcePath);
2418
+ if (!sourceStats) {
2419
+ throw new Error(`Source directory does not exist: ${sourcePath}`);
2420
+ }
2421
+ if (!sourceStats.isDirectory()) {
2422
+ throw new Error(`Source path is not a directory: ${sourcePath}`);
2423
+ }
2424
+ await this.mkdir(destPath);
2425
+ const entries = await this.readdir(sourcePath);
2426
+ for (const entry of entries) {
2427
+ const srcEntry = path.join(sourcePath, entry);
2428
+ const destEntry = path.join(destPath, entry);
2429
+ const entryStats = await this.stat(srcEntry);
2430
+ if (!entryStats)
2431
+ continue;
2432
+ if (entryStats.isDirectory()) {
2433
+ await this.copyDirectory(srcEntry, destEntry);
2434
+ } else if (entryStats.isFile()) {
2435
+ const content = await this.readFile(srcEntry);
2436
+ if (content !== null) {
2437
+ await this.writeFile(destEntry, content);
2438
+ }
2439
+ }
2440
+ }
2441
+ }
2442
+ isEnoent(error) {
2443
+ return this.hasErrnoCode(error, "ENOENT");
2444
+ }
2445
+ hasErrnoCode(error, code) {
2446
+ return typeof error === "object" && error !== null && "code" in error && error.code === code;
2447
+ }
2448
+ }
2449
+
2450
+ // ../filesystem/src/index.ts
2451
+ var fsInstance = new NodeFileSystem;
2452
+ var getFileSystem = () => fsInstance;
2453
+
2454
+ // ../common/src/telemetry/pseudonymize.ts
2455
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2456
+ var PSEUDONYM_HEX_LENGTH = 32;
2457
+ var SHA256_K = new Uint32Array([
2458
+ 1116352408,
2459
+ 1899447441,
2460
+ 3049323471,
2461
+ 3921009573,
2462
+ 961987163,
2463
+ 1508970993,
2464
+ 2453635748,
2465
+ 2870763221,
2466
+ 3624381080,
2467
+ 310598401,
2468
+ 607225278,
2469
+ 1426881987,
2470
+ 1925078388,
2471
+ 2162078206,
2472
+ 2614888103,
2473
+ 3248222580,
2474
+ 3835390401,
2475
+ 4022224774,
2476
+ 264347078,
2477
+ 604807628,
2478
+ 770255983,
2479
+ 1249150122,
2480
+ 1555081692,
2481
+ 1996064986,
2482
+ 2554220882,
2483
+ 2821834349,
2484
+ 2952996808,
2485
+ 3210313671,
2486
+ 3336571891,
2487
+ 3584528711,
2488
+ 113926993,
2489
+ 338241895,
2490
+ 666307205,
2491
+ 773529912,
2492
+ 1294757372,
2493
+ 1396182291,
2494
+ 1695183700,
2495
+ 1986661051,
2496
+ 2177026350,
2497
+ 2456956037,
2498
+ 2730485921,
2499
+ 2820302411,
2500
+ 3259730800,
2501
+ 3345764771,
2502
+ 3516065817,
2503
+ 3600352804,
2504
+ 4094571909,
2505
+ 275423344,
2506
+ 430227734,
2507
+ 506948616,
2508
+ 659060556,
2509
+ 883997877,
2510
+ 958139571,
2511
+ 1322822218,
2512
+ 1537002063,
2513
+ 1747873779,
2514
+ 1955562222,
2515
+ 2024104815,
2516
+ 2227730452,
2517
+ 2361852424,
2518
+ 2428436474,
2519
+ 2756734187,
2520
+ 3204031479,
2521
+ 3329325298
2522
+ ]);
2523
+ var SHA256_INITIAL_STATE = new Uint32Array([
2524
+ 1779033703,
2525
+ 3144134277,
2526
+ 1013904242,
2527
+ 2773480762,
2528
+ 1359893119,
2529
+ 2600822924,
2530
+ 528734635,
2531
+ 1541459225
2532
+ ]);
2533
+ function rotr(value, bits) {
2534
+ return (value >>> bits | value << 32 - bits) >>> 0;
2535
+ }
2536
+ function sha256Hex(input) {
2537
+ const bytes = new TextEncoder().encode(input);
2538
+ const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
2539
+ const buffer = new Uint8Array(paddedLength);
2540
+ buffer.set(bytes);
2541
+ buffer[bytes.length] = 128;
2542
+ const view = new DataView(buffer.buffer);
2543
+ const bitLength = bytes.length * 8;
2544
+ view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
2545
+ view.setUint32(paddedLength - 4, bitLength >>> 0);
2546
+ const state = SHA256_INITIAL_STATE.slice();
2547
+ const schedule = new Uint32Array(64);
2548
+ for (let offset = 0;offset < paddedLength; offset += 64) {
2549
+ for (let i = 0;i < 16; i++) {
2550
+ schedule[i] = view.getUint32(offset + i * 4);
2551
+ }
2552
+ for (let i = 16;i < 64; i++) {
2553
+ const x = schedule[i - 15];
2554
+ const y = schedule[i - 2];
2555
+ const s0 = (rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3) >>> 0;
2556
+ const s1 = (rotr(y, 17) ^ rotr(y, 19) ^ y >>> 10) >>> 0;
2557
+ schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1 >>> 0;
2558
+ }
2559
+ let a = state[0];
2560
+ let b = state[1];
2561
+ let c = state[2];
2562
+ let d = state[3];
2563
+ let e = state[4];
2564
+ let f = state[5];
2565
+ let g = state[6];
2566
+ let h = state[7];
2567
+ for (let i = 0;i < 64; i++) {
2568
+ const s1 = (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) >>> 0;
2569
+ const ch = (e & f ^ ~e & g) >>> 0;
2570
+ const temp1 = h + s1 + ch + SHA256_K[i] + schedule[i] >>> 0;
2571
+ const s0 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) >>> 0;
2572
+ const maj = (a & b ^ a & c ^ b & c) >>> 0;
2573
+ const temp2 = s0 + maj >>> 0;
2574
+ h = g;
2575
+ g = f;
2576
+ f = e;
2577
+ e = d + temp1 >>> 0;
2578
+ d = c;
2579
+ c = b;
2580
+ b = a;
2581
+ a = temp1 + temp2 >>> 0;
2582
+ }
2583
+ state[0] = state[0] + a >>> 0;
2584
+ state[1] = state[1] + b >>> 0;
2585
+ state[2] = state[2] + c >>> 0;
2586
+ state[3] = state[3] + d >>> 0;
2587
+ state[4] = state[4] + e >>> 0;
2588
+ state[5] = state[5] + f >>> 0;
2589
+ state[6] = state[6] + g >>> 0;
2590
+ state[7] = state[7] + h >>> 0;
2591
+ }
2592
+ let hex = "";
2593
+ for (const word of state) {
2594
+ hex += word.toString(16).padStart(8, "0");
2595
+ }
2596
+ return hex;
2597
+ }
2598
+ function resolveSha256Hex() {
2599
+ try {
2600
+ const nodeCrypto = __require("node:crypto");
2601
+ const createHash = nodeCrypto?.createHash;
2602
+ if (typeof createHash !== "function") {
2603
+ return sha256Hex;
2604
+ }
2605
+ const native = (input) => createHash("sha256").update(input, "utf8").digest("hex");
2606
+ return native("abc") === sha256Hex("abc") ? native : sha256Hex;
2607
+ } catch {
2608
+ return sha256Hex;
2609
+ }
2610
+ }
2611
+ var cachedSha256Hex;
2612
+ function digest(input) {
2613
+ cachedSha256Hex ??= resolveSha256Hex();
2614
+ return cachedSha256Hex(input);
2615
+ }
2616
+ function pseudonymize(input) {
2617
+ return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
2618
+ }
2619
+
2620
+ // ../common/src/telemetry/supplied-values.ts
2621
+ var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
2622
+ function activeEntries() {
2623
+ const existing = suppliedValuesSlot.get();
2624
+ return Array.isArray(existing) ? existing : [];
2625
+ }
2626
+ var MIN_SCRUBBABLE_LENGTH = 4;
2627
+ function recordSuppliedArgumentValues(values) {
2628
+ const flat = [];
2629
+ const push = (value) => {
2630
+ if (Array.isArray(value)) {
2631
+ for (const item of value) {
2632
+ push(item);
2633
+ }
2634
+ return;
2635
+ }
2636
+ if (typeof value === "string" && value.length >= MIN_SCRUBBABLE_LENGTH) {
2637
+ flat.push(value);
2638
+ }
2639
+ };
2640
+ push(values);
2641
+ const entry = { values: flat };
2642
+ suppliedValuesSlot.set([...activeEntries(), entry]);
2643
+ return entry;
2644
+ }
2645
+ function releaseSuppliedArgumentValues(entry) {
2646
+ suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
2647
+ }
2648
+ function getSuppliedArgumentValues() {
2649
+ const all = new Set;
2650
+ for (const entry of activeEntries()) {
2651
+ for (const value of entry.values) {
2652
+ all.add(value);
2653
+ }
2654
+ }
2655
+ return [...all].sort((a, b) => b.length - a.length);
2656
+ }
2657
+
2658
+ // ../common/src/telemetry/pii-redactor.ts
2659
+ var REDACTED = "[REDACTED]";
2660
+ var MAX_VALUE_LENGTH = 280;
2661
+ var MAX_STACK_LENGTH = 4096;
2662
+ var MAX_SCAN_LENGTH = MAX_STACK_LENGTH;
2663
+ function truncate(value, maxLength) {
2664
+ return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;
2665
+ }
2666
+ var SENSITIVE_NAME_TOKENS = new Set([
2667
+ "token",
2668
+ "tokens",
2669
+ "secret",
2670
+ "secrets",
2671
+ "password",
2672
+ "passwords",
2673
+ "pwd",
2674
+ "credential",
2675
+ "credentials",
2676
+ "auth",
2677
+ "authentication",
2678
+ "authorization",
2679
+ "authority",
2680
+ "cert",
2681
+ "certificate",
2682
+ "certificates"
2683
+ ]);
2684
+ var SENSITIVE_KEY_PREFIXES = new Set([
2685
+ "api",
2686
+ "access",
2687
+ "client",
2688
+ "private",
2689
+ "public",
2690
+ "signing",
2691
+ "encryption",
2692
+ "session",
2693
+ "master",
2694
+ "shared",
2695
+ "root",
2696
+ "ssh",
2697
+ "rsa",
2698
+ "aes",
2699
+ "hmac",
2700
+ "oauth"
2701
+ ]);
2702
+ 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;
2703
+ var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
2704
+ var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
2705
+ var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
2706
+ var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
2707
+ var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
2708
+ var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
2709
+ var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
2710
+ 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;
2711
+ var SOURCE_FILE_EXTENSIONS = new Set([
2712
+ "ts",
2713
+ "tsx",
2714
+ "js",
2715
+ "jsx",
2716
+ "mjs",
2717
+ "cjs",
2718
+ "cts",
2719
+ "mts",
2720
+ "py",
2721
+ "cs",
2722
+ "java",
2723
+ "go",
2724
+ "rs",
2725
+ "rb",
2726
+ "php",
2727
+ "sh",
2728
+ "ps1",
2729
+ "json",
2730
+ "jsonc",
2731
+ "yaml",
2732
+ "yml",
2733
+ "xml",
2734
+ "xaml",
2735
+ "md",
2736
+ "txt",
2737
+ "log",
2738
+ "css",
2739
+ "html",
2740
+ "htm",
2741
+ "csproj",
2742
+ "nuspec",
2743
+ "sql"
2744
+ ]);
2745
+ var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
2746
+ var QUOTED_LITERAL_MAX_SPAN = 200;
2747
+ var QUOTED_LITERAL_PATTERN = new RegExp([
2748
+ `(?<![A-Za-z0-9])'(?:[^\\
2749
+ ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
2750
+ `(?<![A-Za-z0-9])"(?:[^\\
2751
+ ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
2752
+ ].join("|"), "g");
2753
+ var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
2754
+ var COLLAPSED_BODY = "{…}";
2755
+ var COLLAPSED_BODY_MARKER = "\x01body\x01";
2756
+ var MAX_BODY_NESTING = 8;
2757
+ function collapseJsonBodies(text) {
2758
+ let out = text;
2759
+ for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
2760
+ const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
2761
+ if (next === out) {
2762
+ break;
2763
+ }
2764
+ out = next;
2765
+ }
2766
+ return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
2767
+ }
2768
+ var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
2769
+ function peelTrailingPunctuation(match) {
2770
+ const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
2771
+ return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
2772
+ }
2773
+ function redactUrl(raw) {
2774
+ try {
2775
+ const url = new URL(raw);
2776
+ return `${url.protocol}//${url.host}`;
2777
+ } catch {
2778
+ return `url#${pseudonymize(raw)}`;
2779
+ }
2780
+ }
2781
+ function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
2782
+ let out = truncate(value, MAX_SCAN_LENGTH);
2783
+ out = out.replace(JWT_PATTERN, () => REDACTED);
2784
+ out = out.replace(URL_PATTERN, (match) => {
2785
+ const [core, trailing] = peelTrailingPunctuation(match);
2786
+ return `${redactUrl(core)}${trailing}`;
2787
+ });
2788
+ out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
2789
+ out = out.replace(UNC_PATH_PATTERN, (_match, before, path2) => {
2790
+ const [core, trailing] = peelTrailingPunctuation(path2);
2791
+ return `${before}unc#${pseudonymize(core)}${trailing}`;
2792
+ });
2793
+ out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
2794
+ out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
2795
+ out = out.replace(HOST_PORT_PATTERN, (match) => {
2796
+ const split = match.lastIndexOf(":");
2797
+ const host = match.slice(0, split);
2798
+ const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
2799
+ if (SOURCE_FILE_EXTENSIONS.has(extension)) {
2800
+ return match;
2801
+ }
2802
+ return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
2803
+ });
2804
+ out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
2805
+ out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
2806
+ out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
2807
+ return truncate(out, maxLength);
2808
+ }
2809
+ function redactSpanName(name) {
2810
+ return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
2811
+ }
2812
+ var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
2813
+ function redactHttpDependencyName(name) {
2814
+ const parts = HTTP_DEPENDENCY_NAME.exec(name);
2815
+ if (!parts) {
2816
+ return redactMessage(name);
2817
+ }
2818
+ return `${parts[1]} ${redactMessage(parts[2])}`;
2819
+ }
2820
+ function redactMessage(value) {
2821
+ let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
2822
+ for (const supplied of getSuppliedArgumentValues()) {
2823
+ out = out.split(supplied).join(REDACTED);
2824
+ }
2825
+ return redactValueDetectors(out);
2826
+ }
2827
+ var MESSAGE_NAMES = new Set([
2828
+ "message",
2829
+ "errormessage",
2830
+ "errmessage",
2831
+ "error_message",
2832
+ "msg",
2833
+ "detail",
2834
+ "details",
2835
+ "reason",
2836
+ "instructions",
2837
+ "warning"
2838
+ ]);
2839
+ function isFreeFormValue(name, value) {
2840
+ return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
2841
+ }
2842
+ function redactError(error) {
2843
+ const safe = new Error(redactMessage(error.message ?? ""));
2844
+ safe.name = error.name;
2845
+ safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
2846
+ return safe;
2847
+ }
2848
+ function redactStack(stack) {
2849
+ const bounded = truncate(stack, MAX_STACK_LENGTH);
2850
+ const firstBreak = bounded.indexOf(`
2851
+ `);
2852
+ if (firstBreak === -1) {
2853
+ return redactMessage(bounded);
2854
+ }
2855
+ return `${redactMessage(bounded.slice(0, firstBreak))}
2856
+ ${redactValueDetectors(bounded.slice(firstBreak + 1), MAX_STACK_LENGTH)}`;
2857
+ }
2858
+ function nameTokens(name) {
2859
+ 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);
2860
+ }
2861
+ function isSensitiveName(name) {
2862
+ const tokens = nameTokens(name);
2863
+ for (let i = 0;i < tokens.length; i++) {
2864
+ const token = tokens[i];
2865
+ if (SENSITIVE_NAME_TOKENS.has(token)) {
2866
+ return true;
2867
+ }
2868
+ if (token === "key" || token === "keys") {
2869
+ const prev = tokens[i - 1];
2870
+ if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
2871
+ return true;
2872
+ }
2873
+ }
2874
+ }
2875
+ return false;
2876
+ }
2877
+ function redactProperty(name, value) {
2878
+ if (value === undefined || value === null) {
2879
+ return;
2880
+ }
2881
+ if (isSensitiveName(name)) {
2882
+ return REDACTED;
2883
+ }
2884
+ if (typeof value === "boolean" || typeof value === "number") {
2885
+ return value;
2886
+ }
2887
+ if (typeof value !== "string") {
2888
+ return "[OBJECT]";
2889
+ }
2890
+ return isFreeFormValue(name, value) ? redactMessage(value) : redactValueDetectors(value);
2891
+ }
2892
+ function redactProperties(properties) {
2893
+ const out = {};
2894
+ for (const [name, value] of Object.entries(properties)) {
2895
+ const redacted = redactProperty(name, value);
2896
+ if (redacted !== undefined) {
2897
+ out[name] = redacted;
2898
+ }
2899
+ }
2900
+ return out;
2901
+ }
2902
+
2236
2903
  // ../common/src/catch-error.ts
2904
+ var MAX_SERIALIZED_LENGTH = 500;
2905
+ var TRUNCATION_SUFFIX = "…(truncated)";
2906
+ var REDACTED2 = "[REDACTED]";
2907
+ function cap(text) {
2908
+ return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
2909
+ }
2910
+ function omitSensitive(key, value) {
2911
+ return key.length > 0 && isSensitiveName(key) ? REDACTED2 : value;
2912
+ }
2913
+ function describeThrownValue(value) {
2914
+ if (typeof value !== "object" || value === null) {
2915
+ return String(value);
2916
+ }
2917
+ let message;
2918
+ try {
2919
+ message = value.message;
2920
+ } catch {
2921
+ message = undefined;
2922
+ }
2923
+ if (typeof message === "string" && message.length > 0) {
2924
+ return cap(message);
2925
+ }
2926
+ try {
2927
+ const json = JSON.stringify(value, omitSensitive);
2928
+ if (json !== undefined) {
2929
+ return cap(json);
2930
+ }
2931
+ } catch {}
2932
+ return String(value);
2933
+ }
2934
+ function toError(error) {
2935
+ return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
2936
+ }
2237
2937
  function isPromiseLike(value) {
2238
2938
  return value !== null && typeof value === "object" && typeof value.then === "function";
2239
2939
  }
2240
- function catchError2(fnOrPromise) {
2940
+ function catchError(fnOrPromise) {
2241
2941
  if (isPromiseLike(fnOrPromise)) {
2242
2942
  return settlePromiseLike(fnOrPromise);
2243
2943
  }
@@ -2248,17 +2948,11 @@ function catchError2(fnOrPromise) {
2248
2948
  }
2249
2949
  return [undefined, result];
2250
2950
  } catch (error) {
2251
- return [
2252
- error instanceof Error ? error : new Error(String(error)),
2253
- undefined
2254
- ];
2951
+ return [toError(error), undefined];
2255
2952
  }
2256
2953
  }
2257
2954
  function settlePromiseLike(thenable) {
2258
- return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
2259
- error instanceof Error ? error : new Error(String(error)),
2260
- undefined
2261
- ]);
2955
+ return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
2262
2956
  }
2263
2957
 
2264
2958
  // ../common/src/error-handler.ts
@@ -2292,8 +2986,8 @@ var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most
2292
2986
  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.";
2293
2987
  var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
2294
2988
  var LOCAL_PERMISSION_MESSAGE_PATTERN = /\b(EACCES|EPERM|EROFS)\b/;
2295
- function localPermissionInstructions(code, path) {
2296
- const target = path !== undefined ? `'${path}'` : "a local file or resource";
2989
+ function localPermissionInstructions(code, path2) {
2990
+ const target = path2 !== undefined ? `'${path2}'` : "a local file or resource";
2297
2991
  if (code === "EROFS") {
2298
2992
  return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
2299
2993
  }
@@ -2329,12 +3023,12 @@ function describePermissionError(error) {
2329
3023
  const code = matchLocalPermissionCode(cur.code, message);
2330
3024
  if (!code)
2331
3025
  continue;
2332
- const path = localPermissionPath(cur.path, message);
3026
+ const path2 = localPermissionPath(cur.path, message);
2333
3027
  return {
2334
3028
  code,
2335
3029
  message: message ?? code,
2336
- ...path !== undefined ? { path } : {},
2337
- instructions: localPermissionInstructions(code, path)
3030
+ ...path2 !== undefined ? { path: path2 } : {},
3031
+ instructions: localPermissionInstructions(code, path2)
2338
3032
  };
2339
3033
  }
2340
3034
  return;
@@ -2346,9 +3040,9 @@ function matchLocalPermissionCode(code, message) {
2346
3040
  const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
2347
3041
  return match ? match[1] : undefined;
2348
3042
  }
2349
- function localPermissionPath(path, message) {
2350
- if (typeof path === "string")
2351
- return path;
3043
+ function localPermissionPath(path2, message) {
3044
+ if (typeof path2 === "string")
3045
+ return path2;
2352
3046
  return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
2353
3047
  }
2354
3048
  function* walkErrorGraph(error) {
@@ -2457,10 +3151,10 @@ async function extractErrorDetails(error, options) {
2457
3151
  let parsedBody;
2458
3152
  const textFn = response?.text?.bind(response);
2459
3153
  if (textFn) {
2460
- const [bodyError, body] = await catchError2((async () => textFn())());
3154
+ const [bodyError, body] = await catchError((async () => textFn())());
2461
3155
  if (!bodyError && body) {
2462
3156
  rawBody = body;
2463
- const [parseError, parsed] = catchError2(() => JSON.parse(body));
3157
+ const [parseError, parsed] = catchError(() => JSON.parse(body));
2464
3158
  if (!parseError && parsed && typeof parsed === "object") {
2465
3159
  parsedBody = parsed;
2466
3160
  if (parsedBody.errors && typeof parsedBody.errors === "object") {
@@ -2563,7 +3257,7 @@ async function extractErrorDetails(error, options) {
2563
3257
  } else if (typeof err.message === "string") {
2564
3258
  details = err.message;
2565
3259
  } else {
2566
- details = String(error);
3260
+ details = describeThrownValue(error);
2567
3261
  }
2568
3262
  const context = {};
2569
3263
  if (status) {
@@ -2647,29 +3341,16 @@ function extractErrorMessageSync(error) {
2647
3341
  return error.message;
2648
3342
  }
2649
3343
  }
2650
- return String(error);
3344
+ return describeThrownValue(error);
2651
3345
  }
2652
- // ../common/src/command-examples.ts
2653
- var examplesByCommand = new WeakMap;
2654
- Command.prototype.examples = function(examples) {
2655
- examplesByCommand.set(this, examples);
2656
- return this;
2657
- };
2658
- // ../common/src/preview.ts
2659
- var previewSlot = singleton("PreviewBuild");
2660
- function isPreviewBuild() {
2661
- return previewSlot.get(false) ?? false;
3346
+ // ../common/src/exit-code.ts
3347
+ function setExitCode(code) {
3348
+ process.exitCode = code;
2662
3349
  }
2663
- Command.prototype.previewCommand = function(nameAndArgs, opts) {
2664
- if (isPreviewBuild()) {
2665
- return this.command(nameAndArgs, opts);
2666
- }
2667
- return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
2668
- };
2669
3350
 
2670
3351
  // ../common/src/output-context.ts
2671
3352
  function createStorage() {
2672
- const [error, mod] = catchError2(() => __require("node:async_hooks"));
3353
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
2673
3354
  if (error || typeof mod?.AsyncLocalStorage !== "function") {
2674
3355
  return {
2675
3356
  getStore: () => {
@@ -2700,8 +3381,8 @@ function getOutputSink() {
2700
3381
 
2701
3382
  // ../common/src/logger.ts
2702
3383
  var logFilePathSlot = singleton("logFilePath");
2703
- function setGlobalLogFilePath(path) {
2704
- logFilePathSlot.set(path);
3384
+ function setGlobalLogFilePath(path2) {
3385
+ logFilePathSlot.set(path2);
2705
3386
  }
2706
3387
  function getGlobalLogFilePath() {
2707
3388
  return logFilePathSlot.get("");
@@ -2738,7 +3419,7 @@ class SimpleLogger {
2738
3419
  }
2739
3420
  return DEFAULT_LOG_LEVEL;
2740
3421
  }
2741
- const [localStorageError, hasDebug] = catchError2(() => typeof localStorage !== "undefined" && !!localStorage.getItem("debug"));
3422
+ const [localStorageError, hasDebug] = catchError(() => typeof localStorage !== "undefined" && !!localStorage.getItem("debug"));
2742
3423
  if (!localStorageError && hasDebug) {
2743
3424
  return 0 /* DEBUG */;
2744
3425
  }
@@ -2769,54 +3450,49 @@ class SimpleLogger {
2769
3450
  return this.fileLoggingEnabled || !!getGlobalLogFilePath();
2770
3451
  }
2771
3452
  writeToFile(formatted) {
2772
- const path = this.logFilePath || getGlobalLogFilePath();
2773
- if (!path)
3453
+ const path2 = this.logFilePath || getGlobalLogFilePath();
3454
+ if (!path2)
2774
3455
  return;
2775
3456
  const timestamp = new Date().toISOString();
2776
3457
  this.pendingWrites = Promise.all([
2777
3458
  this.pendingWrites,
2778
3459
  this.pendingInit
2779
- ]).then(() => getFileSystem().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
3460
+ ]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
2780
3461
  }
2781
- debug(message, ...args) {
2782
- if (this.level > 0 /* DEBUG */)
2783
- return;
2784
- const formatted = this.format(`[DEBUG] ${message}`, args);
3462
+ write(formatted) {
2785
3463
  if (this.isFileLoggingActive()) {
2786
3464
  this.writeToFile(formatted);
2787
3465
  } else {
2788
3466
  getOutputSink().writeErr(formatted);
2789
3467
  }
2790
3468
  }
3469
+ debug(message, ...args) {
3470
+ if (this.level > 0 /* DEBUG */)
3471
+ return;
3472
+ const formatted = this.format(`[DEBUG] ${message}`, args);
3473
+ this.write(formatted);
3474
+ }
2791
3475
  info(message, ...args) {
2792
3476
  if (this.level > 1 /* INFO */)
2793
3477
  return;
2794
3478
  const formatted = this.format(message, args);
2795
- if (this.isFileLoggingActive()) {
2796
- this.writeToFile(formatted);
2797
- } else {
2798
- getOutputSink().writeErr(formatted);
2799
- }
3479
+ this.write(formatted);
2800
3480
  }
2801
3481
  warn(message, ...args) {
2802
3482
  if (this.level > 2 /* WARN */)
2803
3483
  return;
2804
3484
  const formatted = this.format(`[WARN] ${message}`, args);
2805
- if (this.isFileLoggingActive()) {
2806
- this.writeToFile(formatted);
2807
- } else {
2808
- getOutputSink().writeErr(formatted);
2809
- }
3485
+ this.write(formatted);
2810
3486
  }
2811
3487
  error(message, ...args) {
2812
3488
  if (this.level > 3 /* ERROR */)
2813
3489
  return;
2814
3490
  const formatted = this.format(`[ERROR] ${message}`, args);
2815
- if (this.isFileLoggingActive()) {
2816
- this.writeToFile(formatted);
2817
- } else {
2818
- getOutputSink().writeErr(formatted);
2819
- }
3491
+ this.write(formatted);
3492
+ }
3493
+ report(message) {
3494
+ const formatted = this.format(message, []);
3495
+ this.write(formatted);
2820
3496
  }
2821
3497
  getLevel() {
2822
3498
  return this.level;
@@ -2831,17 +3507,17 @@ class SimpleLogger {
2831
3507
  setGlobalLogFilePath("");
2832
3508
  }
2833
3509
  }
2834
- setLogFile(path) {
2835
- this.logFilePath = path;
2836
- setGlobalLogFilePath(path);
2837
- if (!path)
3510
+ setLogFile(path2) {
3511
+ this.logFilePath = path2;
3512
+ setGlobalLogFilePath(path2);
3513
+ if (!path2)
2838
3514
  return;
2839
3515
  this.fileLoggingEnabled = true;
2840
- const fs = getFileSystem();
3516
+ const fs2 = getFileSystem();
2841
3517
  this.pendingInit = (async () => {
2842
- const [error] = await catchError2((async () => {
2843
- await fs.mkdir(fs.path.dirname(path));
2844
- await fs.writeFile(path, "");
3518
+ const [error] = await catchError((async () => {
3519
+ await fs2.mkdir(fs2.path.dirname(path2));
3520
+ await fs2.writeFile(path2, "");
2845
3521
  })());
2846
3522
  if (error)
2847
3523
  this.fileLoggingEnabled = false;
@@ -2895,12 +3571,12 @@ var jmespathSlot = singleton("JmespathCodec");
2895
3571
  async function loadOutputCodecsAsync(needed) {
2896
3572
  const loads = [];
2897
3573
  if (needed.yaml && yamlSlot.get() === undefined) {
2898
- loads.push(import("./js-yaml-cggj6w7q.js").then((mod) => {
3574
+ loads.push(import("./js-yaml-87cdx6bm.js").then((mod) => {
2899
3575
  yamlSlot.set(mod);
2900
3576
  }));
2901
3577
  }
2902
3578
  if (needed.filter && jmespathSlot.get() === undefined) {
2903
- loads.push(import("./index-9f8q2ege.js").then((mod) => {
3579
+ loads.push(import("./index-p3vk57z7.js").then((mod) => {
2904
3580
  jmespathSlot.set(mod);
2905
3581
  }));
2906
3582
  }
@@ -3155,7 +3831,7 @@ function readRegistryValue(keyPath, valueName) {
3155
3831
  if (process.platform !== "win32") {
3156
3832
  return "";
3157
3833
  }
3158
- const [error, output] = catchError2(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
3834
+ const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
3159
3835
  encoding: "utf-8",
3160
3836
  stdio: ["pipe", "pipe", "pipe"]
3161
3837
  }));
@@ -3178,27 +3854,41 @@ class LoggerTelemetryProvider {
3178
3854
  ...this.analyticsUniqueId ? { analyticsUniqueId: this.analyticsUniqueId } : {}
3179
3855
  };
3180
3856
  }
3181
- async trackEvent(eventName, properties) {
3182
- logger.debug(formatMessage("Event", eventName, this.enrich(properties)));
3857
+ async trackEvent({ name, properties }) {
3858
+ logger.debug(formatMessage("Event", name, this.enrich(properties)));
3183
3859
  }
3184
- async trackException(error, properties) {
3860
+ async trackException({
3861
+ error,
3862
+ properties
3863
+ }) {
3185
3864
  logger.error(formatMessage("Exception", error.message, this.enrich({
3186
3865
  ...properties,
3187
3866
  stack: error.stack
3188
3867
  })));
3189
3868
  }
3190
- async trackRequest(name, duration, success, properties) {
3869
+ async trackRequest({
3870
+ name,
3871
+ durationMs,
3872
+ success,
3873
+ properties
3874
+ }) {
3191
3875
  logger.debug(formatMessage("Request", name, this.enrich({
3192
3876
  ...properties,
3193
- duration: `${duration}ms`,
3877
+ duration: `${durationMs}ms`,
3194
3878
  success
3195
3879
  })));
3196
3880
  }
3197
- async trackDependency(name, type, duration, success, properties) {
3881
+ async trackDependency({
3882
+ name,
3883
+ type,
3884
+ durationMs,
3885
+ success,
3886
+ properties
3887
+ }) {
3198
3888
  logger.debug(formatMessage("Dependency", name, this.enrich({
3199
3889
  ...properties,
3200
3890
  type,
3201
- duration: `${duration}ms`,
3891
+ duration: `${durationMs}ms`,
3202
3892
  success
3203
3893
  })));
3204
3894
  }
@@ -3448,144 +4138,16 @@ function getTelemetryOperationId() {
3448
4138
  telemetryOperationIdSlot.set(generated);
3449
4139
  return generated;
3450
4140
  }
3451
- // ../common/src/telemetry/pii-redactor.ts
3452
- var REDACTED = "[REDACTED]";
3453
- var MAX_VALUE_LENGTH = 200;
3454
- var SENSITIVE_NAME_TOKENS = new Set([
3455
- "token",
3456
- "tokens",
3457
- "secret",
3458
- "secrets",
3459
- "password",
3460
- "passwords",
3461
- "pwd",
3462
- "credential",
3463
- "credentials",
3464
- "auth",
3465
- "authentication",
3466
- "authorization",
3467
- "authority",
3468
- "cert",
3469
- "certificate",
3470
- "certificates"
3471
- ]);
3472
- var SENSITIVE_KEY_PREFIXES = new Set([
3473
- "api",
3474
- "access",
3475
- "client",
3476
- "private",
3477
- "public",
3478
- "signing",
3479
- "encryption",
3480
- "session",
3481
- "master",
3482
- "shared",
3483
- "root",
3484
- "ssh",
3485
- "rsa",
3486
- "aes",
3487
- "hmac",
3488
- "oauth"
3489
- ]);
3490
- 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;
3491
- var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
3492
- var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
3493
- var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
3494
- var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
3495
- var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
3496
- var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
3497
- function shortHash(input) {
3498
- let hash = 2166136261;
3499
- for (let i = 0;i < input.length; i++) {
3500
- hash ^= input.charCodeAt(i);
3501
- hash = Math.imul(hash, 16777619);
3502
- }
3503
- return (hash >>> 0).toString(16).padStart(8, "0");
3504
- }
3505
- function redactUrl(raw) {
3506
- try {
3507
- const url = new URL(raw);
3508
- return `${url.protocol}//${url.host}`;
3509
- } catch {
3510
- return `url#${shortHash(raw)}`;
3511
- }
3512
- }
3513
- function redactValueDetectors(value) {
3514
- let out = value;
3515
- out = out.replace(JWT_PATTERN, () => REDACTED);
3516
- out = out.replace(URL_PATTERN, (match) => {
3517
- const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
3518
- const core = trailing ? match.slice(0, -trailing.length) : match;
3519
- return `${redactUrl(core)}${trailing}`;
3520
- });
3521
- out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
3522
- out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
3523
- out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
3524
- out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
3525
- if (out.length > MAX_VALUE_LENGTH) {
3526
- out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
3527
- }
3528
- return out;
3529
- }
3530
- function redactValue(value) {
3531
- return redactValueDetectors(value);
3532
- }
3533
- function redactError(error) {
3534
- const safe = new Error(redactValueDetectors(error.message ?? ""));
3535
- safe.name = error.name;
3536
- safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
3537
- return safe;
3538
- }
3539
- function nameTokens(name) {
3540
- 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);
3541
- }
3542
- function isSensitiveName(name) {
3543
- const tokens = nameTokens(name);
3544
- for (let i = 0;i < tokens.length; i++) {
3545
- const token = tokens[i];
3546
- if (SENSITIVE_NAME_TOKENS.has(token)) {
3547
- return true;
3548
- }
3549
- if (token === "key" || token === "keys") {
3550
- const prev = tokens[i - 1];
3551
- if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
3552
- return true;
3553
- }
3554
- }
3555
- }
3556
- return false;
3557
- }
3558
- function redactProperty(name, value) {
3559
- if (value === undefined || value === null) {
3560
- return;
3561
- }
3562
- if (isSensitiveName(name)) {
3563
- return REDACTED;
3564
- }
3565
- if (typeof value === "boolean" || typeof value === "number") {
3566
- return value;
3567
- }
3568
- if (typeof value !== "string") {
3569
- return "[OBJECT]";
3570
- }
3571
- return redactValueDetectors(value);
3572
- }
3573
- function redactProperties(properties) {
3574
- const out = {};
3575
- for (const [name, value] of Object.entries(properties)) {
3576
- const redacted = redactProperty(name, value);
3577
- if (redacted !== undefined) {
3578
- out[name] = redacted;
3579
- }
3580
- }
3581
- return out;
4141
+ // ../common/src/telemetry/span-clock.ts
4142
+ function startSpanClock() {
4143
+ const started = performance.now();
4144
+ return {
4145
+ startedAt: new Date(performance.timeOrigin + started),
4146
+ elapsedMs: () => performance.now() - started
4147
+ };
3582
4148
  }
3583
4149
 
3584
4150
  // ../common/src/telemetry/telemetry-service.ts
3585
- var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
3586
- var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
3587
- var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
3588
-
3589
4151
  class TelemetryService {
3590
4152
  telemetryProvider;
3591
4153
  contextStorage;
@@ -3605,36 +4167,39 @@ class TelemetryService {
3605
4167
  this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
3606
4168
  }
3607
4169
  trackEvent(name, properties) {
3608
- const context = this.getCurrentContext();
3609
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3610
- this.telemetryProvider.trackEvent(name, enrichedProperties);
4170
+ this.telemetryProvider.trackEvent({
4171
+ name: redactSpanName(name),
4172
+ properties: this.enrichProperties(properties),
4173
+ ...this.leafCorrelation()
4174
+ });
3611
4175
  }
3612
- trackException(error, properties) {
3613
- const context = this.getCurrentContext();
3614
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3615
- this.telemetryProvider.trackException(redactError(error), enrichedProperties);
4176
+ trackException(error, properties, context) {
4177
+ this.telemetryProvider.trackException({
4178
+ error: redactError(error),
4179
+ properties: this.enrichProperties(properties),
4180
+ ...this.leafCorrelation(context)
4181
+ });
3616
4182
  }
3617
4183
  async trackRequest(name, fn, properties) {
3618
- const parentContext = this.getCurrentContext();
4184
+ const parentContext = this.getActiveContext();
3619
4185
  const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
3620
4186
  const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
4187
+ const clock = startSpanClock();
3621
4188
  const context = {
3622
4189
  operationId,
3623
4190
  ...parentId !== undefined ? { parentId } : {},
3624
- id: this.generateId()
4191
+ id: this.generateId(),
4192
+ startedAt: clock.startedAt
3625
4193
  };
3626
- const startTime = performance.now();
3627
4194
  try {
3628
4195
  const result = await this.contextStorage.run(context, fn);
3629
- const durationMs = performance.now() - startTime;
3630
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3631
- await this.telemetryProvider.trackRequest(name, durationMs, true, enrichedProperties);
4196
+ const durationMs = clock.elapsedMs();
4197
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, true, properties, context));
3632
4198
  return result;
3633
4199
  } catch (error) {
3634
- const durationMs = performance.now() - startTime;
4200
+ const durationMs = clock.elapsedMs();
3635
4201
  const err = error instanceof Error ? error : new Error(String(error));
3636
- const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, context);
3637
- await this.telemetryProvider.trackRequest(name, durationMs, false, enrichedProperties);
4202
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, context));
3638
4203
  throw error;
3639
4204
  }
3640
4205
  }
@@ -3643,8 +4208,7 @@ class TelemetryService {
3643
4208
  operationId: this.operationId ?? getTelemetryOperationId(),
3644
4209
  id: this.generateId()
3645
4210
  };
3646
- const enrichedProperties = this.enrichPropertiesWithContext(properties, requestContext);
3647
- this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
4211
+ this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, success, properties, requestContext));
3648
4212
  }
3649
4213
  createRequestContext() {
3650
4214
  const operationId = this.operationId ?? getTelemetryOperationId();
@@ -3652,7 +4216,8 @@ class TelemetryService {
3652
4216
  return {
3653
4217
  operationId,
3654
4218
  ...parentId !== undefined ? { parentId } : {},
3655
- id: this.generateId()
4219
+ id: this.generateId(),
4220
+ startedAt: startSpanClock().startedAt
3656
4221
  };
3657
4222
  }
3658
4223
  inboundParentIdFor(operationId) {
@@ -3663,58 +4228,84 @@ class TelemetryService {
3663
4228
  return this.contextStorage.run(context, fn);
3664
4229
  }
3665
4230
  createDependencyContext() {
3666
- const parentContext = this.getCurrentContext();
4231
+ const parentContext = this.getActiveContext();
3667
4232
  if (!parentContext) {
3668
4233
  return;
3669
4234
  }
3670
4235
  return {
3671
4236
  operationId: parentContext.operationId,
3672
4237
  parentId: parentContext.id,
3673
- id: this.generateId()
4238
+ id: this.generateId(),
4239
+ startedAt: startSpanClock().startedAt
3674
4240
  };
3675
4241
  }
3676
4242
  trackDependencyResult(name, type, durationMs, success, properties, context, resultCode) {
3677
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3678
- this.telemetryProvider.trackDependency(redactValue(name), type, durationMs, success, enrichedProperties, resultCode);
4243
+ this.telemetryProvider.trackDependency({
4244
+ ...this.spanFor(redactHttpDependencyName(name), durationMs, success, properties, context),
4245
+ type,
4246
+ ...resultCode !== undefined ? { resultCode } : {}
4247
+ });
3679
4248
  }
3680
4249
  async trackDependencyOperation(name, type, fn, properties) {
3681
- const parentContext = this.getCurrentContext();
4250
+ const clock = startSpanClock();
4251
+ const parentContext = this.getActiveContext();
3682
4252
  const childContext = parentContext !== undefined ? {
3683
4253
  operationId: parentContext.operationId,
3684
4254
  parentId: parentContext.id,
3685
- id: this.generateId()
3686
- } : this.createRequestContext();
3687
- const startTime = performance.now();
4255
+ id: this.generateId(),
4256
+ startedAt: clock.startedAt
4257
+ } : {
4258
+ ...this.createRequestContext(),
4259
+ startedAt: clock.startedAt
4260
+ };
3688
4261
  try {
3689
4262
  const result = await this.contextStorage.run(childContext, fn);
3690
- const durationMs = performance.now() - startTime;
3691
- const enrichedProperties = this.enrichPropertiesWithContext(properties, childContext);
3692
- await this.telemetryProvider.trackDependency(name, type, durationMs, true, enrichedProperties);
4263
+ const durationMs = clock.elapsedMs();
4264
+ await this.telemetryProvider.trackDependency({
4265
+ ...this.spanFor(name, durationMs, true, properties, childContext),
4266
+ type
4267
+ });
3693
4268
  return result;
3694
4269
  } catch (error) {
3695
- const durationMs = performance.now() - startTime;
4270
+ const durationMs = clock.elapsedMs();
3696
4271
  const err = error instanceof Error ? error : new Error(String(error));
3697
- const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, childContext);
3698
- await this.telemetryProvider.trackDependency(name, type, durationMs, false, enrichedProperties);
4272
+ await this.telemetryProvider.trackDependency({
4273
+ ...this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, childContext),
4274
+ type
4275
+ });
3699
4276
  throw error;
3700
4277
  }
3701
4278
  }
3702
- getCurrentContext() {
4279
+ getActiveContext() {
3703
4280
  return this.contextStorage.getContext();
3704
4281
  }
3705
- enrichPropertiesWithContext(properties, context) {
4282
+ leafCorrelation(explicit) {
4283
+ const context = explicit ?? this.getActiveContext();
4284
+ return {
4285
+ operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
4286
+ ...context !== undefined ? { parentId: context.id } : {}
4287
+ };
4288
+ }
4289
+ spanFor(name, durationMs, success, properties, context) {
4290
+ return {
4291
+ name: redactSpanName(name),
4292
+ durationMs,
4293
+ success,
4294
+ properties: this.enrichProperties(properties),
4295
+ operationId: context.operationId,
4296
+ ...context.parentId !== undefined ? { parentId: context.parentId } : {},
4297
+ id: context.id,
4298
+ ...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
4299
+ };
4300
+ }
4301
+ enrichProperties(properties) {
3706
4302
  const globalProperties = getGlobalTelemetryProperties();
3707
4303
  const enriched = {
3708
4304
  ...getExecutionContextTelemetryProperties(),
3709
4305
  ...globalProperties,
3710
4306
  ...this.defaultProperties,
3711
4307
  ...redactProperties(properties ?? {}),
3712
- [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
3713
- ...context ? {
3714
- [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
3715
- ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
3716
- [TELEMETRY_SPAN_ID_PROPERTY]: context.id
3717
- } : {}
4308
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
3718
4309
  };
3719
4310
  return enriched;
3720
4311
  }
@@ -3731,6 +4322,81 @@ class TelemetryService {
3731
4322
  return hex;
3732
4323
  }
3733
4324
  }
4325
+ // ../common/src/timings.ts
4326
+ var TIMINGS_ENV_VAR = "UIP_TIMINGS";
4327
+ function createStorage2() {
4328
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
4329
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
4330
+ return {
4331
+ getStore: () => {
4332
+ return;
4333
+ },
4334
+ run: (_store, fn) => fn()
4335
+ };
4336
+ }
4337
+ return new mod.AsyncLocalStorage;
4338
+ }
4339
+ var storageSlot = singleton("TimingStorage");
4340
+ var stateSlot = singleton("Timings");
4341
+ var rootStartedSlot = singleton("TimingsRootStarted");
4342
+ var longLivedHostSlot = singleton("TimingsLongLivedHost");
4343
+ var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
4344
+ function newState(baseline) {
4345
+ return { baseline, httpMs: 0, httpCalls: 0 };
4346
+ }
4347
+ function getState() {
4348
+ const scoped = storage.getStore();
4349
+ if (scoped) {
4350
+ return scoped;
4351
+ }
4352
+ const pinned = livePinnedState();
4353
+ if (pinned !== undefined) {
4354
+ return pinned;
4355
+ }
4356
+ return newState(processStartIsInvocationStart() ? 0 : performance.now());
4357
+ }
4358
+ function livePinnedState() {
4359
+ const pinned = stateSlot.get();
4360
+ return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
4361
+ }
4362
+ function processStartIsInvocationStart() {
4363
+ return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
4364
+ }
4365
+ function timingsEnabled() {
4366
+ if (typeof process === "undefined") {
4367
+ return false;
4368
+ }
4369
+ const value = process.env?.[TIMINGS_ENV_VAR];
4370
+ if (value === undefined) {
4371
+ return false;
4372
+ }
4373
+ const normalized = value.trim().toLowerCase();
4374
+ return normalized === "1" || normalized === "true";
4375
+ }
4376
+ function recordExitCode(exitCode) {
4377
+ if (!timingsEnabled()) {
4378
+ return;
4379
+ }
4380
+ getState().exitCode = exitCode;
4381
+ }
4382
+ function invocationStartedAt() {
4383
+ return new Date(performance.timeOrigin + getState().baseline);
4384
+ }
4385
+ function invocationElapsedMs() {
4386
+ return performance.now() - getState().baseline;
4387
+ }
4388
+ function markCommandStart() {
4389
+ if (!timingsEnabled()) {
4390
+ return;
4391
+ }
4392
+ getState().commandStart = performance.now();
4393
+ }
4394
+ function recordCommandDuration(durationMs) {
4395
+ if (!timingsEnabled()) {
4396
+ return;
4397
+ }
4398
+ getState().commandMs = durationMs;
4399
+ }
3734
4400
  // ../common/src/telemetry/proxy-http-agent.ts
3735
4401
  var slot = singleton("ProxyAuthHttpsAgent");
3736
4402
 
@@ -3751,6 +4417,9 @@ function getGlobalTelemetryInstance() {
3751
4417
  }
3752
4418
  return;
3753
4419
  }
4420
+ function setGlobalTelemetryInstance(instance) {
4421
+ telemetryInstanceSlot.set(instance);
4422
+ }
3754
4423
  var _localTelemetryInstance;
3755
4424
  function getTelemetryInstance() {
3756
4425
  const global = getGlobalTelemetryInstance();
@@ -3758,6 +4427,7 @@ function getTelemetryInstance() {
3758
4427
  return global;
3759
4428
  if (!_localTelemetryInstance) {
3760
4429
  _localTelemetryInstance = new TelemetryService(new LoggerTelemetryProvider, new NodeContextStorage);
4430
+ setGlobalTelemetryInstance(_localTelemetryInstance);
3761
4431
  }
3762
4432
  return _localTelemetryInstance;
3763
4433
  }
@@ -3770,6 +4440,14 @@ var telemetry = new Proxy({}, {
3770
4440
  });
3771
4441
 
3772
4442
  // ../common/src/formatter.ts
4443
+ var ANSI_STYLES = {
4444
+ red: "\x1B[31m",
4445
+ dim: "\x1B[2m"
4446
+ };
4447
+ var ANSI_RESET = "\x1B[0m";
4448
+ function styleLine(line, style) {
4449
+ return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
4450
+ }
3773
4451
  var CLI_ERROR_CODES = [
3774
4452
  "invalid_argument",
3775
4453
  "authentication_required",
@@ -3808,22 +4486,6 @@ var EXIT_CODES = {
3808
4486
  ValidationError: 3,
3809
4487
  TimeoutError: 4
3810
4488
  };
3811
- class SuccessOutput {
3812
- Result = RESULTS.Success;
3813
- Code;
3814
- Data;
3815
- Pagination;
3816
- Instructions;
3817
- Log;
3818
- constructor(code, data) {
3819
- this.Code = code;
3820
- this.Data = data;
3821
- const logPath = getLogFilePath();
3822
- if (logPath) {
3823
- this.Log = logPath;
3824
- }
3825
- }
3826
- }
3827
4489
  function escapeNonAscii(jsonText) {
3828
4490
  return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
3829
4491
  const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
@@ -3888,19 +4550,45 @@ function toPascalCaseKey(key) {
3888
4550
  const lowerCamelKey = toLowerCamelCaseKey(key);
3889
4551
  return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
3890
4552
  }
3891
- function toPascalCaseData(value) {
4553
+ function collectVerbatimRefs(value, into) {
4554
+ if (typeof value !== "object" || value === null)
4555
+ return;
4556
+ if (into.has(value))
4557
+ return;
4558
+ into.add(value);
4559
+ for (const nested of Array.isArray(value) ? value : Object.values(value)) {
4560
+ collectVerbatimRefs(nested, into);
4561
+ }
4562
+ }
4563
+ function toPascalCaseData(value, verbatimKeys, subtrees) {
4564
+ if (subtrees?.mode === "skip" && typeof value === "object" && value !== null && subtrees.refs.has(value)) {
4565
+ return value;
4566
+ }
3892
4567
  if (Array.isArray(value))
3893
- return value.map(toPascalCaseData);
4568
+ return value.map((entry) => toPascalCaseData(entry, verbatimKeys, subtrees));
3894
4569
  if (!isPlainRecord(value))
3895
4570
  return value;
3896
4571
  const result = {};
3897
4572
  for (const [key, nestedValue] of Object.entries(value)) {
3898
- result[toPascalCaseKey(key)] = toPascalCaseData(nestedValue);
4573
+ const pascalKey = toPascalCaseKey(key);
4574
+ if (verbatimKeys?.has(pascalKey)) {
4575
+ result[pascalKey] = nestedValue;
4576
+ if (subtrees?.mode === "collect") {
4577
+ collectVerbatimRefs(nestedValue, subtrees.refs);
4578
+ }
4579
+ continue;
4580
+ }
4581
+ result[pascalKey] = toPascalCaseData(nestedValue, verbatimKeys, subtrees);
3899
4582
  }
3900
4583
  return result;
3901
4584
  }
3902
- function normalizeDataKeys(data) {
3903
- return toPascalCaseData(data);
4585
+ function normalizeDataKeys(data, verbatimKeys, subtrees) {
4586
+ return toPascalCaseData(data, verbatimKeys, subtrees);
4587
+ }
4588
+ function toVerbatimKeySet(preserve) {
4589
+ if (!Array.isArray(preserve))
4590
+ return;
4591
+ return new Set(preserve.map(toPascalCaseKey));
3904
4592
  }
3905
4593
  function normalizeOutputKeys(data) {
3906
4594
  const result = {};
@@ -3910,7 +4598,7 @@ function normalizeOutputKeys(data) {
3910
4598
  }
3911
4599
  return result;
3912
4600
  }
3913
- function printOutput(data, format = "json", logFn, asciiSafe = false) {
4601
+ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowStyle) {
3914
4602
  if (!data) {
3915
4603
  logFn("Empty response object. No data to display.");
3916
4604
  return;
@@ -3945,7 +4633,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
3945
4633
  if (hasData && !(rows !== null && rows.length === 0)) {
3946
4634
  const logValue = data.Log;
3947
4635
  if (rows !== null) {
3948
- printResizableTable(rows, logFn, logValue);
4636
+ printResizableTable(rows, logFn, logValue, undefined, tableRowStyle);
3949
4637
  } else {
3950
4638
  printVerticalTable(data.Data, logFn, logValue);
3951
4639
  }
@@ -3956,10 +4644,11 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
3956
4644
  }
3957
4645
  }
3958
4646
  }
3959
- function logOutput(data, format = "json") {
4647
+ function logOutput(data, format = "json", tableRowStyle) {
3960
4648
  const sink = getOutputSink();
4649
+ const styleFn = sink.capabilities.isInteractive && sink.capabilities.supportsColor ? tableRowStyle : undefined;
3961
4650
  printOutput(data, format, (msg) => sink.writeOut(`${msg}
3962
- `), needsAsciiSafeJson(sink));
4651
+ `), needsAsciiSafeJson(sink), styleFn);
3963
4652
  }
3964
4653
  function cellToString(val) {
3965
4654
  return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
@@ -3973,7 +4662,7 @@ function wrapText(text, width) {
3973
4662
  }
3974
4663
  return lines;
3975
4664
  }
3976
- function printTable(data, logFn, externalLogValue) {
4665
+ function printTable(data, logFn, externalLogValue, tableRowStyle) {
3977
4666
  if (data.length === 0)
3978
4667
  return;
3979
4668
  const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
@@ -3983,7 +4672,7 @@ function printTable(data, logFn, externalLogValue) {
3983
4672
  logFn(keys.map((_, i) => "-".repeat(maxWidths[i])).join("-|-"));
3984
4673
  data.forEach((item) => {
3985
4674
  const row = keys.map((key, i) => cellToString(item[key]).padEnd(maxWidths[i])).join(" | ");
3986
- logFn(row);
4675
+ logFn(styleLine(row, tableRowStyle?.(item)));
3987
4676
  });
3988
4677
  if (externalLogValue) {
3989
4678
  logFn("");
@@ -4026,14 +4715,14 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
4026
4715
  logFn(`Log: ${externalLogValue}`);
4027
4716
  }
4028
4717
  }
4029
- function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth) {
4718
+ function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
4030
4719
  if (data.length === 0)
4031
4720
  return;
4032
4721
  const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
4033
4722
  if (keys.length === 0)
4034
4723
  return;
4035
4724
  if (!process.stdout.isTTY) {
4036
- printTable(data, logFn, externalLogValue);
4725
+ printTable(data, logFn, externalLogValue, tableRowStyle);
4037
4726
  return;
4038
4727
  }
4039
4728
  const naturalWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
@@ -4041,7 +4730,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
4041
4730
  const totalWidth = naturalWidths.reduce((a, b) => a + b, 0) + separatorTotal;
4042
4731
  const termWidth = availableWidth ?? (process.stdout.columns || 120);
4043
4732
  if (totalWidth <= termWidth) {
4044
- printTable(data, logFn, externalLogValue);
4733
+ printTable(data, logFn, externalLogValue, tableRowStyle);
4045
4734
  return;
4046
4735
  }
4047
4736
  const overflow = totalWidth - termWidth;
@@ -4087,6 +4776,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
4087
4776
  logFn(header);
4088
4777
  logFn(keys.map((_, i) => "-".repeat(finalWidths[i])).join("-|-"));
4089
4778
  data.forEach((item) => {
4779
+ const style = tableRowStyle?.(item);
4090
4780
  const cellLines = keys.map((key, i) => wrapText(cellToString(item[key]), finalWidths[i]));
4091
4781
  const lineCount = Math.max(...cellLines.map((l) => l.length));
4092
4782
  for (let line = 0;line < lineCount; line++) {
@@ -4094,7 +4784,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
4094
4784
  const val = line < cellLines[i].length ? cellLines[i][line] : "";
4095
4785
  return val.padEnd(finalWidths[i]);
4096
4786
  }).join(" | ");
4097
- logFn(row);
4787
+ logFn(styleLine(row, style));
4098
4788
  }
4099
4789
  });
4100
4790
  if (externalLogValue) {
@@ -4238,30 +4928,36 @@ var OutputFormatter;
4238
4928
  ((OutputFormatter) => {
4239
4929
  function success(data, options) {
4240
4930
  data.Log ??= getLogFilePath() || undefined;
4241
- const normalize = !options?.preserveDataKeys;
4931
+ const normalize = options?.preserveDataKeys !== true;
4932
+ const verbatim = toVerbatimKeySet(options?.preserveDataKeys);
4933
+ const subtrees = verbatim && {
4934
+ refs: new Set,
4935
+ mode: "collect"
4936
+ };
4242
4937
  if (normalize) {
4243
- data.Data = normalizeDataKeys(data.Data);
4938
+ data.Data = normalizeDataKeys(data.Data, verbatim, subtrees);
4244
4939
  }
4245
4940
  const filter = getOutputFilter();
4246
4941
  if (filter) {
4247
4942
  const filtered = applyFilter(data.Data, filter);
4248
- data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
4943
+ data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
4249
4944
  }
4250
- logOutput(normalizeOutputKeys(data), getOutputFormat());
4945
+ logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4251
4946
  }
4252
4947
  OutputFormatter.success = success;
4253
4948
  function error(data) {
4254
4949
  data.Log ??= getLogFilePath() || undefined;
4255
4950
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
4256
4951
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
4257
- process.exitCode = EXIT_CODES[data.Result] ?? 1;
4952
+ const exitCode = EXIT_CODES[data.Result] ?? 1;
4953
+ setExitCode(exitCode);
4258
4954
  recordCommandFailureTelemetry({
4259
4955
  result: data.Result,
4260
4956
  errorCode: data.ErrorCode,
4261
4957
  retry: data.Retry,
4262
4958
  message: data.Message,
4263
4959
  context: data.Context,
4264
- exitCode: process.exitCode,
4960
+ exitCode,
4265
4961
  errorClass: data.TelemetryErrorClass,
4266
4962
  terminalOutcome: data.TelemetryTerminalOutcome,
4267
4963
  terminalSignal: data.TelemetryTerminalSignal
@@ -4337,6 +5033,23 @@ var OutputFormatter;
4337
5033
  }
4338
5034
  OutputFormatter.formatToString = formatToString;
4339
5035
  })(OutputFormatter ||= {});
5036
+ // ../common/src/command-examples.ts
5037
+ var examplesByCommand = new WeakMap;
5038
+ Command.prototype.examples = function(examples) {
5039
+ examplesByCommand.set(this, examples);
5040
+ return this;
5041
+ };
5042
+ // ../common/src/preview.ts
5043
+ var previewSlot = singleton("PreviewBuild");
5044
+ function isPreviewBuild() {
5045
+ return previewSlot.get(false) ?? false;
5046
+ }
5047
+ Command.prototype.previewCommand = function(nameAndArgs, opts) {
5048
+ if (isPreviewBuild()) {
5049
+ return this.command(nameAndArgs, opts);
5050
+ }
5051
+ return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
5052
+ };
4340
5053
 
4341
5054
  // ../common/src/telemetry/command-attribution.ts
4342
5055
  var LEGACY_SKILL_NAMESPACE = "uipath:";
@@ -4491,6 +5204,57 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
4491
5204
  };
4492
5205
  }
4493
5206
 
5207
+ // ../common/src/telemetry/command-name.ts
5208
+ var TELEMETRY_COMMAND_ROOT = "uip";
5209
+ function commandTelemetryName(parts) {
5210
+ const tokens = [];
5211
+ for (const part of parts) {
5212
+ const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== TELEMETRY_COMMAND_ROOT);
5213
+ if (pieces.every(isCommandToken)) {
5214
+ tokens.push(...pieces);
5215
+ continue;
5216
+ }
5217
+ tokens.push(UNKNOWN_TOKEN);
5218
+ }
5219
+ return [TELEMETRY_COMMAND_ROOT, ...tokens].join(".");
5220
+ }
5221
+ var COMMAND_TOKEN_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
5222
+ var MAX_COMMAND_TOKEN_LENGTH = 32;
5223
+ var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
5224
+ function isCommandToken(token) {
5225
+ return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token) && !/^\d+$/.test(token);
5226
+ }
5227
+ var UNKNOWN_TOKEN = "<unknown>";
5228
+
5229
+ // ../common/src/telemetry/invocation-request.ts
5230
+ var requestContextSlot = singleton("TelemetryInvocationRequestContext");
5231
+ function activeContext() {
5232
+ return telemetry.getActiveContext?.();
5233
+ }
5234
+ function runWithInvocationRequest(fn) {
5235
+ const context = telemetry.createRequestContext();
5236
+ context.startedAt = invocationStartedAt();
5237
+ requestContextSlot.set(context);
5238
+ return telemetry.runWithContext(context, fn);
5239
+ }
5240
+ function ensureInvocationRequestScope(fn) {
5241
+ if (activeContext() !== undefined) {
5242
+ return fn();
5243
+ }
5244
+ const kept = requestContextSlot.get();
5245
+ return kept === undefined ? runWithInvocationRequest(fn) : telemetry.runWithContext(kept, fn);
5246
+ }
5247
+ function getInvocationRequestContext() {
5248
+ return activeContext() ?? requestContextSlot.get();
5249
+ }
5250
+ function emitInvocationRequest(name, success, properties) {
5251
+ const context = getInvocationRequestContext();
5252
+ telemetry.trackRequestResult(name, invocationElapsedMs(), success, properties, context);
5253
+ if (context !== undefined && requestContextSlot.get() === context) {
5254
+ requestContextSlot.clear();
5255
+ }
5256
+ }
5257
+
4494
5258
  // ../common/src/trackedAction.ts
4495
5259
  var pollSignalSlot = singleton("PollSignal");
4496
5260
  var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
@@ -4498,28 +5262,74 @@ var retryHintValues = new Set(RETRY_HINTS);
4498
5262
  var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
4499
5263
  var processContext = {
4500
5264
  exit: (code) => {
4501
- process.exitCode = code;
5265
+ recordExitCode(code);
5266
+ setExitCode(code);
4502
5267
  },
4503
5268
  get pollSignal() {
4504
5269
  return pollSignalSlot.get();
4505
5270
  }
4506
5271
  };
5272
+ var TELEMETRY_ARG_VALUE_WITHHELD = "<provided>";
5273
+ var TELEMETRY_ARG_VALUE_DEFAULTED = "<default>";
5274
+ function recordableArgValue(value, choices) {
5275
+ if (typeof value === "boolean" || typeof value === "number") {
5276
+ return value;
5277
+ }
5278
+ if (choices && choices.length > 0) {
5279
+ if (typeof value === "string" && choices.includes(value)) {
5280
+ return value;
5281
+ }
5282
+ if (Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string" && choices.includes(entry))) {
5283
+ return value.join(",");
5284
+ }
5285
+ }
5286
+ return TELEMETRY_ARG_VALUE_WITHHELD;
5287
+ }
4507
5288
  function extractCommandParams(cmd) {
4508
5289
  const params = {};
4509
- const add = (name, value) => {
4510
- if (name && value !== undefined) {
4511
- params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = value;
4512
- }
4513
- };
5290
+ forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
5291
+ const recordable = recordableArgValue(value, choices);
5292
+ params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
5293
+ });
5294
+ return params;
5295
+ }
5296
+ function isDefaultedOption(cmd, name) {
5297
+ const source = cmd.getOptionValueSource?.(name);
5298
+ return source === "default" || source === "implied";
5299
+ }
5300
+ function isDefaultedPositional(cmd, index) {
5301
+ return index >= (cmd.args?.length ?? 0);
5302
+ }
5303
+ function forEachSuppliedArgument(cmd, visit) {
4514
5304
  const registered = cmd.registeredArguments ?? [];
4515
5305
  const processed = cmd.processedArgs ?? [];
4516
5306
  for (let i = 0;i < registered.length; i++) {
4517
- add(registered[i].name(), processed[i]);
5307
+ const name = registered[i].name();
5308
+ if (name && processed[i] !== undefined) {
5309
+ visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
5310
+ }
5311
+ }
5312
+ const choicesByAttribute = new Map;
5313
+ for (const option of cmd.options) {
5314
+ choicesByAttribute.set(option.attributeName(), option.argChoices);
4518
5315
  }
4519
5316
  for (const [key, value] of Object.entries(cmd.opts())) {
4520
- add(key, value);
5317
+ if (key && value !== undefined) {
5318
+ visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
5319
+ }
4521
5320
  }
4522
- return params;
5321
+ }
5322
+ function withheldArgumentValues(cmd) {
5323
+ const values = [];
5324
+ forEachSuppliedArgument(cmd, (_name, value, choices, defaulted) => {
5325
+ if (defaulted) {
5326
+ return;
5327
+ }
5328
+ if (recordableArgValue(value, choices) === TELEMETRY_ARG_VALUE_WITHHELD) {
5329
+ values.push(value);
5330
+ }
5331
+ });
5332
+ return values;
4523
5333
  }
4524
5334
  function deriveCommandPath(cmd) {
4525
5335
  const parts = [];
@@ -4534,7 +5344,7 @@ function deriveCommandPath(cmd) {
4534
5344
  if (parts.length > 1) {
4535
5345
  parts.shift();
4536
5346
  }
4537
- return ["uip", ...parts.filter((p) => p !== "uip")].join(".");
5347
+ return commandTelemetryName(parts);
4538
5348
  }
4539
5349
  function isCliErrorCode(value) {
4540
5350
  return typeof value === "string" && cliErrorCodeValues.has(value);
@@ -4574,68 +5384,77 @@ Command.prototype.trackedAction = function(context, fn, properties) {
4574
5384
  });
4575
5385
  const telemetryName = deriveCommandPath(command);
4576
5386
  const props = typeof properties === "function" ? properties(...args) : properties;
4577
- const requestContext = telemetry.createRequestContext();
4578
- const startTime = performance.now();
4579
- let errorMessage;
4580
- let fallbackExitCode = EXIT_CODES.Success;
4581
- clearRecordedCommandFailureTelemetry();
4582
- const [error] = await catchError2(telemetry.runWithContext(requestContext, () => {
4583
- const violation = implicitLimitViolation(command);
4584
- if (violation) {
4585
- return Promise.reject(violation);
4586
- }
4587
- return fn(...args);
4588
- }));
4589
- if (error) {
4590
- errorMessage = error instanceof Error ? error.message : String(error);
4591
- logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
4592
- const typed = error;
4593
- const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
4594
- const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
4595
- const finalResult = customResult ?? RESULTS.Failure;
4596
- const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
4597
- const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
4598
- const typedRetry = typed.retry ?? typed.Retry;
4599
- const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
4600
- const typedContext = typed.context ?? typed.Context;
4601
- const customContext = isErrorContext(typedContext) ? typedContext : undefined;
4602
- const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
4603
- fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
4604
- OutputFormatter.error({
4605
- Result: finalResult,
4606
- ...customErrorCode ? { ErrorCode: customErrorCode } : {},
4607
- Message: errorMessage,
4608
- Instructions: customInstructions ?? commandHelpHint(telemetryName),
4609
- ...customRetry ? { Retry: customRetry } : {},
4610
- ...customContext ? { Context: customContext } : {}
5387
+ markCommandStart();
5388
+ const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
5389
+ try {
5390
+ const startTime = performance.now();
5391
+ let errorMessage;
5392
+ let fallbackExitCode = EXIT_CODES.Success;
5393
+ clearRecordedCommandFailureTelemetry();
5394
+ const [error] = await catchError(ensureInvocationRequestScope(() => {
5395
+ const violation = implicitLimitViolation(command);
5396
+ if (violation) {
5397
+ return Promise.reject(violation);
5398
+ }
5399
+ return fn(...args);
5400
+ }));
5401
+ if (error) {
5402
+ errorMessage = error instanceof Error ? error.message : String(error);
5403
+ logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
5404
+ const typed = error;
5405
+ const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
5406
+ const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
5407
+ const finalResult = customResult ?? RESULTS.Failure;
5408
+ const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
5409
+ const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
5410
+ const typedRetry = typed.retry ?? typed.Retry;
5411
+ const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
5412
+ const typedContext = typed.context ?? typed.Context;
5413
+ const customContext = isErrorContext(typedContext) ? typedContext : undefined;
5414
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
5415
+ fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
5416
+ OutputFormatter.error({
5417
+ Result: finalResult,
5418
+ ...customErrorCode ? { ErrorCode: customErrorCode } : {},
5419
+ Message: errorMessage,
5420
+ Instructions: customInstructions ?? commandHelpHint(telemetryName),
5421
+ ...customRetry ? { Retry: customRetry } : {},
5422
+ ...customContext ? { Context: customContext } : {}
5423
+ });
5424
+ context.exit(fallbackExitCode);
5425
+ }
5426
+ const durationMs = performance.now() - startTime;
5427
+ recordCommandDuration(durationMs);
5428
+ const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
5429
+ const recordedFailure = takeRecordedCommandFailureTelemetry();
5430
+ const success = !error && exitCode === 0;
5431
+ const terminalTelemetry = buildCommandTerminalTelemetryProperties({
5432
+ error,
5433
+ exitCode,
5434
+ recordedFailure,
5435
+ pollSignal: context.pollSignal
4611
5436
  });
4612
- context.exit(fallbackExitCode);
4613
- }
4614
- const durationMs = performance.now() - startTime;
4615
- const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
4616
- const recordedFailure = takeRecordedCommandFailureTelemetry();
4617
- const success = !error && exitCode === 0;
4618
- const terminalTelemetry = buildCommandTerminalTelemetryProperties({
4619
- error,
4620
- exitCode,
4621
- recordedFailure,
4622
- pollSignal: context.pollSignal
4623
- });
4624
- const commandParams = extractCommandParams(command);
4625
- if (props) {
4626
- for (const key of Object.keys(props)) {
4627
- delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
4628
- }
4629
- }
4630
- const baseProperties = redactProperties({
4631
- ...commandParams,
4632
- ...props,
4633
- ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
4634
- command: "true",
4635
- ...terminalTelemetry,
4636
- ...errorMessage ? { errorMessage } : {}
4637
- });
4638
- telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
5437
+ if (terminalTelemetry.error_class === "internal" && error) {
5438
+ telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { command_name: telemetryName }, getInvocationRequestContext());
5439
+ }
5440
+ const commandParams = extractCommandParams(command);
5441
+ if (props) {
5442
+ for (const key of Object.keys(props)) {
5443
+ delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
5444
+ }
5445
+ }
5446
+ const baseProperties = redactProperties({
5447
+ ...commandParams,
5448
+ ...props,
5449
+ ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
5450
+ command: "true",
5451
+ ...terminalTelemetry,
5452
+ ...errorMessage ? { errorMessage } : {}
5453
+ });
5454
+ emitInvocationRequest(telemetryName, success, baseProperties);
5455
+ } finally {
5456
+ releaseSuppliedArgumentValues(supplied);
5457
+ }
4639
5458
  });
4640
5459
  };
4641
5460
  // ../common/src/completer.ts
@@ -4658,6 +5477,204 @@ var guardInstalledSlot = singleton("ConsoleGuardInstalled");
4658
5477
  var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
4659
5478
  // ../common/src/constants.ts
4660
5479
  var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
5480
+ // ../common/src/entity-name-rules.ts
5481
+ var RESERVED_SQL_KEYWORDS_LOWER = new Set(["group", "order"]);
5482
+ var RESERVED_FIELD_NAMES_LOWER = new Set([
5483
+ "id",
5484
+ "createdby",
5485
+ "createtime",
5486
+ "updatedby",
5487
+ "updatetime",
5488
+ "recordowner",
5489
+ "version"
5490
+ ]);
5491
+ var RESERVED_KEYWORDS_LOWER = new Set([
5492
+ "abstract",
5493
+ "as",
5494
+ "base",
5495
+ "bool",
5496
+ "break",
5497
+ "byte",
5498
+ "case",
5499
+ "catch",
5500
+ "char",
5501
+ "checked",
5502
+ "class",
5503
+ "const",
5504
+ "continue",
5505
+ "decimal",
5506
+ "default",
5507
+ "delegate",
5508
+ "do",
5509
+ "double",
5510
+ "else",
5511
+ "enum",
5512
+ "event",
5513
+ "explicit",
5514
+ "extern",
5515
+ "false",
5516
+ "finally",
5517
+ "fixed",
5518
+ "float",
5519
+ "for",
5520
+ "foreach",
5521
+ "goto",
5522
+ "if",
5523
+ "implicit",
5524
+ "in",
5525
+ "int",
5526
+ "interface",
5527
+ "internal",
5528
+ "is",
5529
+ "lock",
5530
+ "long",
5531
+ "namespace",
5532
+ "new",
5533
+ "null",
5534
+ "object",
5535
+ "operator",
5536
+ "out",
5537
+ "override",
5538
+ "params",
5539
+ "private",
5540
+ "protected",
5541
+ "public",
5542
+ "readonly",
5543
+ "ref",
5544
+ "return",
5545
+ "sbyte",
5546
+ "sealed",
5547
+ "short",
5548
+ "sizeof",
5549
+ "stackalloc",
5550
+ "static",
5551
+ "string",
5552
+ "struct",
5553
+ "switch",
5554
+ "this",
5555
+ "throw",
5556
+ "true",
5557
+ "try",
5558
+ "typeof",
5559
+ "uint",
5560
+ "ulong",
5561
+ "unchecked",
5562
+ "unsafe",
5563
+ "ushort",
5564
+ "using",
5565
+ "virtual",
5566
+ "void",
5567
+ "volatile",
5568
+ "while",
5569
+ "addhandler",
5570
+ "addressof",
5571
+ "alias",
5572
+ "and",
5573
+ "andalso",
5574
+ "boolean",
5575
+ "byref",
5576
+ "byval",
5577
+ "call",
5578
+ "cbool",
5579
+ "cbyte",
5580
+ "cchar",
5581
+ "cdate",
5582
+ "cdbl",
5583
+ "cdec",
5584
+ "cint",
5585
+ "clng",
5586
+ "cobj",
5587
+ "csbyte",
5588
+ "cshort",
5589
+ "csng",
5590
+ "cstr",
5591
+ "ctype",
5592
+ "cuint",
5593
+ "culng",
5594
+ "cushort",
5595
+ "date",
5596
+ "declare",
5597
+ "dim",
5598
+ "directcast",
5599
+ "each",
5600
+ "elseif",
5601
+ "end",
5602
+ "endif",
5603
+ "erase",
5604
+ "error",
5605
+ "exit",
5606
+ "friend",
5607
+ "function",
5608
+ "get",
5609
+ "gettype",
5610
+ "getxmlnamespace",
5611
+ "global",
5612
+ "gosub",
5613
+ "goto",
5614
+ "handles",
5615
+ "implements",
5616
+ "imports",
5617
+ "inherits",
5618
+ "integer",
5619
+ "isnot",
5620
+ "let",
5621
+ "lib",
5622
+ "like",
5623
+ "loop",
5624
+ "me",
5625
+ "mod",
5626
+ "module",
5627
+ "mustinherit",
5628
+ "mustoverride",
5629
+ "mybase",
5630
+ "myclass",
5631
+ "narrowing",
5632
+ "next",
5633
+ "not",
5634
+ "nothing",
5635
+ "notinheritable",
5636
+ "notoverridable",
5637
+ "of",
5638
+ "on",
5639
+ "option",
5640
+ "optional",
5641
+ "or",
5642
+ "orelse",
5643
+ "overloads",
5644
+ "overridable",
5645
+ "overrides",
5646
+ "paramarray",
5647
+ "partial",
5648
+ "property",
5649
+ "raiseevent",
5650
+ "redim",
5651
+ "rem",
5652
+ "removehandler",
5653
+ "resume",
5654
+ "select",
5655
+ "set",
5656
+ "shadows",
5657
+ "shared",
5658
+ "single",
5659
+ "step",
5660
+ "stop",
5661
+ "structure",
5662
+ "sub",
5663
+ "synclock",
5664
+ "then",
5665
+ "to",
5666
+ "trycast",
5667
+ "uinteger",
5668
+ "ushort",
5669
+ "variant",
5670
+ "wend",
5671
+ "when",
5672
+ "widening",
5673
+ "with",
5674
+ "withevents",
5675
+ "writeonly",
5676
+ "xor"
5677
+ ]);
4661
5678
  // ../common/src/error-instructions.ts
4662
5679
  function extractHttpStatus(err) {
4663
5680
  if (!err || typeof err !== "object")
@@ -4689,16 +5706,31 @@ function instructionsFor(ctx, err) {
4689
5706
  return "Re-authenticate with 'uip login' — your session is invalid or expired";
4690
5707
  }
4691
5708
  if (status === 403) {
4692
- return "Confirm your user has access to the folder and the required permissions";
5709
+ return "Confirm your user has access to the resource, and the required permissions in this folder or tenant";
4693
5710
  }
4694
5711
  if (status === 404) {
4695
5712
  return "Verify the resource exists in the current folder/tenant";
4696
5713
  }
4697
- if (status === 400) {
5714
+ if (status === 400 || status === 422) {
4698
5715
  return "Request was rejected — check flag values and inputs";
4699
5716
  }
5717
+ if (status === 405) {
5718
+ return "Check the command name and the base URL in use — the endpoint may not exist";
5719
+ }
5720
+ if (status === 408) {
5721
+ return "The request timed out — retry; if it persists, narrow the request (e.g. --limit on list commands)";
5722
+ }
5723
+ if (status === 409) {
5724
+ return "The resource already exists, or changed since it was read — list it to see the current state";
5725
+ }
5726
+ if (status === 413) {
5727
+ return "The upload is over the size limit — exclude unused dependencies or drop large files, then retry";
5728
+ }
5729
+ if (status === 429) {
5730
+ return "Rate limit reached — wait and retry; when the service suggests a delay, Retry and Context.retryAfter carry it";
5731
+ }
4700
5732
  if (status !== undefined && status >= 500 && status < 600) {
4701
- return "Orchestrator returned a server error — retry; if it persists, check service status";
5733
+ return "The service returned a server error — retry; if it persists, check service status";
4702
5734
  }
4703
5735
  const permission = describePermissionError(err);
4704
5736
  if (permission) {
@@ -4806,6 +5838,40 @@ var ScreenLogger;
4806
5838
  var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
4807
5839
  // ../common/src/tool-provider.ts
4808
5840
  var factorySlot = singleton("PackagerFactoryProvider");
5841
+ // ../auth/src/catch-error.ts
5842
+ function isPromiseLike2(value) {
5843
+ return value !== null && typeof value === "object" && typeof value.then === "function";
5844
+ }
5845
+ function catchError2(fnOrPromise) {
5846
+ if (isPromiseLike2(fnOrPromise)) {
5847
+ return settlePromiseLike2(fnOrPromise);
5848
+ }
5849
+ try {
5850
+ const result = fnOrPromise();
5851
+ if (isPromiseLike2(result)) {
5852
+ return settlePromiseLike2(result);
5853
+ }
5854
+ return [undefined, result];
5855
+ } catch (error) {
5856
+ return [
5857
+ error instanceof Error ? error : new Error(String(error)),
5858
+ undefined
5859
+ ];
5860
+ }
5861
+ }
5862
+ function settlePromiseLike2(thenable) {
5863
+ return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
5864
+ error instanceof Error ? error : new Error(String(error)),
5865
+ undefined
5866
+ ]);
5867
+ }
5868
+
5869
+ // ../auth/src/constants.ts
5870
+ var UIPATH_HOME_DIR = ".uipath";
5871
+ var AUTH_FILENAME = ".auth";
5872
+ var DEFAULT_BASE_URL = "https://cloud.uipath.com";
5873
+ var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
5874
+
4809
5875
  // ../auth/src/authProfile.ts
4810
5876
  var DEFAULT_AUTH_PROFILE = "default";
4811
5877
  var PROFILE_DIR = "profiles";
@@ -4817,7 +5883,7 @@ function isAuthProfileStorage(value) {
4817
5883
  return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
4818
5884
  }
4819
5885
  function createProfileStorage() {
4820
- const [error, mod] = catchError(() => __require("node:async_hooks"));
5886
+ const [error, mod] = catchError2(() => __require("node:async_hooks"));
4821
5887
  if (error || typeof mod?.AsyncLocalStorage !== "function") {
4822
5888
  return {
4823
5889
  getStore: () => {
@@ -4833,9 +5899,9 @@ function getProfileStorage() {
4833
5899
  if (isAuthProfileStorage(existing)) {
4834
5900
  return existing;
4835
5901
  }
4836
- const storage = createProfileStorage();
4837
- globalSlot[AUTH_PROFILE_STORAGE_KEY] = storage;
4838
- return storage;
5902
+ const storage2 = createProfileStorage();
5903
+ globalSlot[AUTH_PROFILE_STORAGE_KEY] = storage2;
5904
+ return storage2;
4839
5905
  }
4840
5906
  var profileStorage = getProfileStorage();
4841
5907
 
@@ -4866,8 +5932,8 @@ function resolveAuthProfileFilePath(profile) {
4866
5932
  if (normalized === undefined) {
4867
5933
  throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
4868
5934
  }
4869
- const fs = getFileSystem();
4870
- return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
5935
+ const fs2 = getFileSystem();
5936
+ return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
4871
5937
  }
4872
5938
  function getActiveAuthProfileFilePath() {
4873
5939
  const profile = getActiveAuthProfile();
@@ -4887,7 +5953,7 @@ class InvalidBaseUrlError extends Error {
4887
5953
  super(`Invalid base URL: "${url}"
4888
5954
  ` + `Reason: ${reason}
4889
5955
 
4890
- ` + `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>).
5956
+ ` + `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>).
4891
5957
  ` + `You can specify the URL via:
4892
5958
  ` + ` • --authority flag
4893
5959
  ` + ` • UIPATH_URL environment variable
@@ -4908,10 +5974,16 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
4908
5974
  while (baseUrl.endsWith("/")) {
4909
5975
  baseUrl = baseUrl.slice(0, -1);
4910
5976
  }
5977
+ const hasScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(baseUrl);
5978
+ const [hostCandidate] = baseUrl.split(/[/?#]/, 1);
5979
+ if (!hasScheme && hostCandidate.includes(".")) {
5980
+ baseUrl = `https://${baseUrl}`;
5981
+ }
4911
5982
  const resolvedBaseUrl = baseUrl;
4912
- const [urlError, url] = catchError(() => new URL(resolvedBaseUrl));
5983
+ const [urlError, url] = catchError2(() => new URL(resolvedBaseUrl));
4913
5984
  if (urlError) {
4914
- throw new InvalidBaseUrlError(baseUrl, `Malformed URL. ${urlError instanceof Error ? urlError.message : "Unknown error"}`);
5985
+ 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"}`;
5986
+ throw new InvalidBaseUrlError(baseUrl, `Malformed URL.${shapeHint}`);
4915
5987
  }
4916
5988
  if (url.protocol !== "https:") {
4917
5989
  throw new InvalidBaseUrlError(baseUrl, `Authority must use https:// scheme, got ${url.protocol}//. OIDC token exchange requires TLS end-to-end.`);
@@ -4966,6 +6038,11 @@ var resolveConfigAsync = async ({
4966
6038
  };
4967
6039
  };
4968
6040
 
6041
+ // ../auth/src/utils/platform.ts
6042
+ function isBrowser() {
6043
+ return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
6044
+ }
6045
+
4969
6046
  // ../auth/src/utils/jwt.ts
4970
6047
  class InvalidIssuerError extends Error {
4971
6048
  expected;
@@ -5040,7 +6117,7 @@ var getTokenExpiration = (accessToken) => {
5040
6117
  // ../auth/src/sessionIdentity.ts
5041
6118
  var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
5042
6119
  var decodeClaims = (accessToken) => {
5043
- const [error, claims] = catchError(() => parseJWT(accessToken));
6120
+ const [error, claims] = catchError2(() => parseJWT(accessToken));
5044
6121
  return error ? undefined : claims;
5045
6122
  };
5046
6123
  var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
@@ -5124,27 +6201,48 @@ var requireEnv = (name) => {
5124
6201
  }
5125
6202
  return value;
5126
6203
  };
6204
+ var OPAQUE_TOKEN_BASE_URL_VAR = "UIPATH_URL";
6205
+ var resolveBaseUrl = (rawUrl, failureContext) => {
6206
+ const [baseUrlError, baseUrl] = catchError2(() => normalizeAndValidateBaseUrl(rawUrl));
6207
+ if (baseUrlError) {
6208
+ if (baseUrlError instanceof InvalidBaseUrlError) {
6209
+ throw baseUrlError;
6210
+ }
6211
+ throw new EnvAuthConfigError(`${failureContext}: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
6212
+ }
6213
+ return baseUrl;
6214
+ };
5127
6215
  var readAuthFromEnv = () => {
5128
6216
  const accessToken = requireEnv(ENV_AUTH_VARS.token);
5129
6217
  const organizationName = requireEnv(ENV_AUTH_VARS.organizationName);
5130
6218
  const organizationId = requireEnv(ENV_AUTH_VARS.organizationId);
5131
6219
  const tenantName = requireEnv(ENV_AUTH_VARS.tenantName);
5132
6220
  const tenantId = requireEnv(ENV_AUTH_VARS.tenantId);
5133
- const [parseError, payload] = catchError(() => parseJWT(accessToken));
6221
+ const [parseError, payload] = catchError2(() => parseJWT(accessToken));
5134
6222
  if (parseError) {
5135
- throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} is not a valid JWT: ` + `${parseError instanceof Error ? parseError.message : String(parseError)}`);
6223
+ const parseErrorMessage = parseError instanceof Error ? parseError.message : String(parseError);
6224
+ const rawUrl = process.env[OPAQUE_TOKEN_BASE_URL_VAR];
6225
+ if (!rawUrl) {
6226
+ 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}).`);
6227
+ }
6228
+ const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
6229
+ return {
6230
+ loginStatus: "Logged in",
6231
+ accessToken,
6232
+ baseUrl: baseUrl2,
6233
+ organizationName,
6234
+ organizationId,
6235
+ tenantName,
6236
+ tenantId,
6237
+ source: "env-vars" /* EnvironmentVariables */,
6238
+ 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}`
6239
+ };
5136
6240
  }
5137
6241
  const iss = payload.iss;
5138
6242
  if (typeof iss !== "string" || iss.length === 0) {
5139
6243
  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.`);
5140
6244
  }
5141
- const [baseUrlError, baseUrl] = catchError(() => normalizeAndValidateBaseUrl(iss));
5142
- if (baseUrlError) {
5143
- if (baseUrlError instanceof InvalidBaseUrlError) {
5144
- throw baseUrlError;
5145
- }
5146
- throw new EnvAuthConfigError(`Failed to derive server URL from token 'iss' claim: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
5147
- }
6245
+ const baseUrl = resolveBaseUrl(iss, "Failed to derive server URL from token 'iss' claim");
5148
6246
  const expiration = getTokenExpiration(accessToken);
5149
6247
  const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
5150
6248
  const identity = resolveSessionIdentity(accessToken);
@@ -5170,8 +6268,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
5170
6268
  async function refreshTokenFingerprint(refreshToken) {
5171
6269
  const bytes = new TextEncoder().encode(refreshToken);
5172
6270
  if (globalThis.crypto?.subtle) {
5173
- const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
5174
- return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
6271
+ const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
6272
+ return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
5175
6273
  }
5176
6274
  const { createHash } = await import("node:crypto");
5177
6275
  return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
@@ -5180,9 +6278,9 @@ function breakerPathFor(authPath) {
5180
6278
  return `${authPath}${BREAKER_SUFFIX}`;
5181
6279
  }
5182
6280
  async function loadRefreshBreaker(authPath) {
5183
- const fs = getFileSystem();
6281
+ const fs2 = getFileSystem();
5184
6282
  try {
5185
- const content = await fs.readFile(breakerPathFor(authPath), "utf-8");
6283
+ const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
5186
6284
  if (!content)
5187
6285
  return {};
5188
6286
  const parsed = JSON.parse(content);
@@ -5193,20 +6291,20 @@ async function loadRefreshBreaker(authPath) {
5193
6291
  }
5194
6292
  async function saveRefreshBreaker(authPath, state) {
5195
6293
  try {
5196
- const fs = getFileSystem();
5197
- const path = breakerPathFor(authPath);
5198
- await fs.mkdir(fs.path.dirname(path));
5199
- const tempPath = `${path}.tmp`;
5200
- await fs.writeFile(tempPath, JSON.stringify(state));
5201
- await fs.rename(tempPath, path);
6294
+ const fs2 = getFileSystem();
6295
+ const path2 = breakerPathFor(authPath);
6296
+ await fs2.mkdir(fs2.path.dirname(path2));
6297
+ const tempPath = `${path2}.tmp`;
6298
+ await fs2.writeFile(tempPath, JSON.stringify(state));
6299
+ await fs2.rename(tempPath, path2);
5202
6300
  } catch {}
5203
6301
  }
5204
6302
  async function clearRefreshBreaker(authPath) {
5205
- const fs = getFileSystem();
5206
- const path = breakerPathFor(authPath);
6303
+ const fs2 = getFileSystem();
6304
+ const path2 = breakerPathFor(authPath);
5207
6305
  try {
5208
- if (await fs.exists(path)) {
5209
- await fs.rm(path);
6306
+ if (await fs2.exists(path2)) {
6307
+ await fs2.rm(path2);
5210
6308
  }
5211
6309
  } catch {}
5212
6310
  }
@@ -5227,43 +6325,43 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
5227
6325
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
5228
6326
  var PIPE_NAME_MAX_LENGTH = 103;
5229
6327
  var getRobotIpcPipeNames = async () => {
5230
- const fs = getFileSystem();
5231
- const username = fs.env.getenv("USER") ?? fs.env.getenv("USERNAME");
6328
+ const fs2 = getFileSystem();
6329
+ const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
5232
6330
  if (!username) {
5233
6331
  throw new Error("Unable to determine current username");
5234
6332
  }
5235
- const tempPath = fs.env.getenv("TMPDIR") ?? "/tmp/";
5236
- return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
6333
+ const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
6334
+ return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
5237
6335
  };
5238
6336
  var defaultIsRobotIpcAvailable = async () => {
5239
6337
  if (process.platform === "win32") {
5240
6338
  return true;
5241
6339
  }
5242
- const [pipeNamesError, pipeNames] = await catchError(getRobotIpcPipeNames());
6340
+ const [pipeNamesError, pipeNames] = await catchError2(getRobotIpcPipeNames());
5243
6341
  if (pipeNamesError || !pipeNames) {
5244
6342
  return false;
5245
6343
  }
5246
- const fs = getFileSystem();
6344
+ const fs2 = getFileSystem();
5247
6345
  for (const pipeName of pipeNames) {
5248
- const [existsError, exists] = await catchError(fs.exists(pipeName));
6346
+ const [existsError, exists] = await catchError2(fs2.exists(pipeName));
5249
6347
  if (!existsError && exists === true) {
5250
6348
  return true;
5251
6349
  }
5252
6350
  }
5253
6351
  return false;
5254
6352
  };
5255
- var withTimeout = (promise, timeoutMs) => new Promise((resolve, reject) => {
6353
+ var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
5256
6354
  const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
5257
6355
  promise.then((value) => {
5258
6356
  clearTimeout(timer);
5259
- resolve(value);
6357
+ resolve2(value);
5260
6358
  }, (error) => {
5261
6359
  clearTimeout(timer);
5262
6360
  reject(error);
5263
6361
  });
5264
6362
  });
5265
6363
  var parseResourceUrl = (url) => {
5266
- const [error, parsed] = catchError(() => new URL(url));
6364
+ const [error, parsed] = catchError2(() => new URL(url));
5267
6365
  if (error || !parsed)
5268
6366
  return;
5269
6367
  const segments = parsed.pathname.split("/").filter(Boolean);
@@ -5283,7 +6381,7 @@ var defaultLoadModule = async () => {
5283
6381
  if (!hostLoader) {
5284
6382
  return;
5285
6383
  }
5286
- const [error, mod] = await catchError(() => hostLoader());
6384
+ const [error, mod] = await catchError2(() => hostLoader());
5287
6385
  if (error || !mod) {
5288
6386
  return;
5289
6387
  }
@@ -5309,7 +6407,7 @@ var tryRobotClientFallback = async (options = {}) => {
5309
6407
  const mod = await loadModule();
5310
6408
  if (!mod)
5311
6409
  return;
5312
- const [ctorError, proxy] = catchError(() => new mod.RobotProxyConstructor);
6410
+ const [ctorError, proxy] = catchError2(() => new mod.RobotProxyConstructor);
5313
6411
  if (ctorError || !proxy) {
5314
6412
  return;
5315
6413
  }
@@ -5332,7 +6430,7 @@ var tryRobotClientFallback = async (options = {}) => {
5332
6430
  let organizationIdFromToken;
5333
6431
  let tenantIdFromToken;
5334
6432
  let issuerFromToken;
5335
- const [jwtError, claims] = catchError(() => parseJWT(accessToken));
6433
+ const [jwtError, claims] = catchError2(() => parseJWT(accessToken));
5336
6434
  if (!jwtError && claims) {
5337
6435
  const rawOrgId = claims.prtId ?? claims.organizationId ?? claims.prt_id;
5338
6436
  if (typeof rawOrgId === "string" && rawOrgId.length > 0) {
@@ -5359,7 +6457,7 @@ var tryRobotClientFallback = async (options = {}) => {
5359
6457
  } catch {
5360
6458
  return;
5361
6459
  } finally {
5362
- await catchError(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
6460
+ await catchError2(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
5363
6461
  }
5364
6462
  };
5365
6463
 
@@ -5429,9 +6527,9 @@ var errorCode = (err) => {
5429
6527
  }
5430
6528
  return "EUNKNOWN";
5431
6529
  };
5432
- var probeAsync = async (fs, candidate) => {
6530
+ var probeAsync = async (fs2, candidate) => {
5433
6531
  try {
5434
- const stats = await fs.stat(candidate);
6532
+ const stats = await fs2.stat(candidate);
5435
6533
  if (stats === null) {
5436
6534
  return { exists: false };
5437
6535
  }
@@ -5458,9 +6556,9 @@ var probeAsync = async (fs, candidate) => {
5458
6556
  }
5459
6557
  };
5460
6558
  var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
5461
- const fs = getFileSystem();
5462
- if (fs.path.isAbsolute(envFilePath)) {
5463
- const probe2 = await probeAsync(fs, envFilePath);
6559
+ const fs2 = getFileSystem();
6560
+ if (fs2.path.isAbsolute(envFilePath)) {
6561
+ const probe2 = await probeAsync(fs2, envFilePath);
5464
6562
  return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
5465
6563
  exists: false,
5466
6564
  absolutePath: envFilePath,
@@ -5468,11 +6566,11 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
5468
6566
  ...probe2.unusable ? { unusable: probe2.unusable } : {}
5469
6567
  };
5470
6568
  }
5471
- const cwd = opts?.cwd ?? fs.env.cwd();
6569
+ const cwd = opts?.cwd ?? fs2.env.cwd();
5472
6570
  let searchDir = cwd;
5473
6571
  while (true) {
5474
- const candidate = fs.path.join(searchDir, envFilePath);
5475
- const probe2 = await probeAsync(fs, candidate);
6572
+ const candidate = fs2.path.join(searchDir, envFilePath);
6573
+ const probe2 = await probeAsync(fs2, candidate);
5476
6574
  if (probe2.exists) {
5477
6575
  return {
5478
6576
  exists: true,
@@ -5480,14 +6578,14 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
5480
6578
  source: searchDir === cwd ? "cwd" : "ancestor"
5481
6579
  };
5482
6580
  }
5483
- const parentDir = fs.path.dirname(searchDir);
6581
+ const parentDir = fs2.path.dirname(searchDir);
5484
6582
  if (parentDir === searchDir) {
5485
6583
  break;
5486
6584
  }
5487
6585
  searchDir = parentDir;
5488
6586
  }
5489
- const homePath = fs.path.join(fs.env.homedir(), envFilePath);
5490
- const probe = await probeAsync(fs, homePath);
6587
+ const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
6588
+ const probe = await probeAsync(fs2, homePath);
5491
6589
  if (probe.exists) {
5492
6590
  return { exists: true, absolutePath: homePath, source: "home" };
5493
6591
  }
@@ -5509,12 +6607,12 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
5509
6607
  };
5510
6608
  };
5511
6609
  var loadEnvFileAsync = async ({ envPath }) => {
5512
- const fs = getFileSystem();
5513
- const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.cwd(), envPath);
5514
- if (!await fs.exists(absolutePath)) {
6610
+ const fs2 = getFileSystem();
6611
+ const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
6612
+ if (!await fs2.exists(absolutePath)) {
5515
6613
  throw new Error(`Environment file not found: ${envPath}`);
5516
6614
  }
5517
- const content = await fs.readFile(absolutePath, "utf-8");
6615
+ const content = await fs2.readFile(absolutePath, "utf-8");
5518
6616
  if (content === null) {
5519
6617
  throw new Error(`Environment file not found: ${envPath}`);
5520
6618
  }
@@ -5543,10 +6641,10 @@ var saveEnvFileAsync = async ({
5543
6641
  data,
5544
6642
  merge = true
5545
6643
  }) => {
5546
- const fs = getFileSystem();
5547
- const absolutePath = fs.path.isAbsolute(envPath) ? envPath : fs.path.join(fs.env.homedir(), envPath);
6644
+ const fs2 = getFileSystem();
6645
+ const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
5548
6646
  let existingData = {};
5549
- if (merge && await fs.exists(absolutePath)) {
6647
+ if (merge && await fs2.exists(absolutePath)) {
5550
6648
  try {
5551
6649
  existingData = await loadEnvFileAsync({ envPath: absolutePath });
5552
6650
  } catch {}
@@ -5564,11 +6662,11 @@ var saveEnvFileAsync = async ({
5564
6662
  const content = `${lines.join(`
5565
6663
  `)}
5566
6664
  `;
5567
- const dir = fs.path.dirname(absolutePath);
5568
- await fs.mkdir(dir);
6665
+ const dir = fs2.path.dirname(absolutePath);
6666
+ await fs2.mkdir(dir);
5569
6667
  const tempPath = `${absolutePath}.tmp`;
5570
- await fs.writeFile(tempPath, content);
5571
- await fs.rename(tempPath, absolutePath);
6668
+ await fs2.writeFile(tempPath, content);
6669
+ await fs2.rename(tempPath, absolutePath);
5572
6670
  };
5573
6671
 
5574
6672
  // ../auth/src/loginStatus.ts
@@ -5682,11 +6780,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
5682
6780
  return { credentials };
5683
6781
  }
5684
6782
  async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
5685
- const fs = getFs();
5686
- const globalPath = fs.path.join(fs.env.homedir(), envFilePath);
6783
+ const fs2 = getFs();
6784
+ const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
5687
6785
  if (absolutePath === globalPath)
5688
6786
  return;
5689
- if (!await fs.exists(globalPath))
6787
+ if (!await fs2.exists(globalPath))
5690
6788
  return;
5691
6789
  try {
5692
6790
  const globalCreds = await loadEnvFile({ envPath: globalPath });
@@ -6059,6 +7157,6 @@ var TENANT_SELECTION_CODES = new Set([
6059
7157
  // src/api/external-user-id.ts
6060
7158
  var CLI_EXTERNAL_USER_ID = "app-user-cli-cas";
6061
7159
 
6062
- export { package_default, catchError2 as catchError, extractErrorDetails, extractErrorMessageSync, InvalidArgumentError, Command, RESULTS, EXIT_CODES, OutputFormatter, processContext, requireConfirmation, instructionsFor, canPrompt, parseBoundedInt, getSdkUserAgentToken, addSdkUserAgentHeader, getLoginStatusAsync, CLI_EXTERNAL_USER_ID };
7160
+ export { package_default, getFileSystem, catchError, extractErrorDetails, extractErrorMessageSync, RESULTS, EXIT_CODES, OutputFormatter, InvalidArgumentError, Command, processContext, requireConfirmation, instructionsFor, canPrompt, parseBoundedInt, getSdkUserAgentToken, addSdkUserAgentHeader, getLoginStatusAsync, CLI_EXTERNAL_USER_ID };
6063
7161
 
6064
- //# debugId=B4EEDCBB327B8D7864756E2164756E21
7162
+ //# debugId=1614BA43C013DCAF64756E2164756E21