@uipath/llmgw-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.
@@ -2,10 +2,10 @@ import {
2
2
  __commonJS,
3
3
  __require,
4
4
  __toESM
5
- } from "./tool-0v6na3yp.js";
5
+ } from "./tool-1de529jm.js";
6
6
 
7
7
  // ../../../node_modules/commander/lib/error.js
8
- var require_error = __commonJS((exports) => {
8
+ var require_error = __commonJS(function(exports) {
9
9
  class CommanderError extends Error {
10
10
  constructor(exitCode, code, message) {
11
11
  super(message);
@@ -29,7 +29,7 @@ var require_error = __commonJS((exports) => {
29
29
  });
30
30
 
31
31
  // ../../../node_modules/commander/lib/argument.js
32
- var require_argument = __commonJS((exports) => {
32
+ var require_argument = __commonJS(function(exports) {
33
33
  var { InvalidArgumentError } = require_error();
34
34
 
35
35
  class Argument {
@@ -109,7 +109,7 @@ var require_argument = __commonJS((exports) => {
109
109
  });
110
110
 
111
111
  // ../../../node_modules/commander/lib/help.js
112
- var require_help = __commonJS((exports) => {
112
+ var require_help = __commonJS(function(exports) {
113
113
  var { humanReadableArgName } = require_argument();
114
114
 
115
115
  class Help {
@@ -466,7 +466,7 @@ ${itemIndentStr}`);
466
466
  });
467
467
 
468
468
  // ../../../node_modules/commander/lib/option.js
469
- var require_option = __commonJS((exports) => {
469
+ var require_option = __commonJS(function(exports) {
470
470
  var { InvalidArgumentError } = require_error();
471
471
 
472
472
  class Option {
@@ -650,7 +650,7 @@ var require_option = __commonJS((exports) => {
650
650
  });
651
651
 
652
652
  // ../../../node_modules/commander/lib/suggestSimilar.js
653
- var require_suggestSimilar = __commonJS((exports) => {
653
+ var require_suggestSimilar = __commonJS(function(exports) {
654
654
  var maxDistance = 3;
655
655
  function editDistance(a, b) {
656
656
  if (Math.abs(a.length - b.length) > maxDistance)
@@ -723,7 +723,7 @@ var require_suggestSimilar = __commonJS((exports) => {
723
723
  });
724
724
 
725
725
  // ../../../node_modules/commander/lib/command.js
726
- var require_command = __commonJS((exports) => {
726
+ var require_command = __commonJS(function(exports) {
727
727
  var EventEmitter = __require("node:events").EventEmitter;
728
728
  var childProcess = __require("node:child_process");
729
729
  var path2 = __require("node:path");
@@ -2078,7 +2078,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2078
2078
  });
2079
2079
 
2080
2080
  // ../../../node_modules/commander/index.js
2081
- var require_commander = __commonJS((exports) => {
2081
+ var require_commander = __commonJS(function(exports) {
2082
2082
  var { Argument } = require_argument();
2083
2083
  var { Command } = require_command();
2084
2084
  var { CommanderError, InvalidArgumentError } = require_error();
@@ -2100,7 +2100,7 @@ var require_commander = __commonJS((exports) => {
2100
2100
  var package_default = {
2101
2101
  name: "@uipath/llmgw-tool",
2102
2102
  license: "MIT",
2103
- version: "1.201.0",
2103
+ version: "1.202.0-preview.136",
2104
2104
  description: "CLI plugin for UiPath AI Trust Layer Bring-Your-Own LLM connections.",
2105
2105
  private: false,
2106
2106
  repository: {
@@ -2169,7 +2169,7 @@ class NodeFileSystem {
2169
2169
  };
2170
2170
  utils = {
2171
2171
  open: async (url) => {
2172
- const { default: open } = await import("./index-91ejywfm.js");
2172
+ const { default: open } = await import("./index-xnzgkhtg.js");
2173
2173
  await open(url);
2174
2174
  }
2175
2175
  };
@@ -2369,7 +2369,519 @@ class NodeFileSystem {
2369
2369
  var fsInstance = new NodeFileSystem;
2370
2370
  var getFileSystem = () => fsInstance;
2371
2371
 
2372
+ // ../../common/src/telemetry/pseudonymize.ts
2373
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2374
+ var PSEUDONYM_HEX_LENGTH = 32;
2375
+ var SHA256_K = new Uint32Array([
2376
+ 1116352408,
2377
+ 1899447441,
2378
+ 3049323471,
2379
+ 3921009573,
2380
+ 961987163,
2381
+ 1508970993,
2382
+ 2453635748,
2383
+ 2870763221,
2384
+ 3624381080,
2385
+ 310598401,
2386
+ 607225278,
2387
+ 1426881987,
2388
+ 1925078388,
2389
+ 2162078206,
2390
+ 2614888103,
2391
+ 3248222580,
2392
+ 3835390401,
2393
+ 4022224774,
2394
+ 264347078,
2395
+ 604807628,
2396
+ 770255983,
2397
+ 1249150122,
2398
+ 1555081692,
2399
+ 1996064986,
2400
+ 2554220882,
2401
+ 2821834349,
2402
+ 2952996808,
2403
+ 3210313671,
2404
+ 3336571891,
2405
+ 3584528711,
2406
+ 113926993,
2407
+ 338241895,
2408
+ 666307205,
2409
+ 773529912,
2410
+ 1294757372,
2411
+ 1396182291,
2412
+ 1695183700,
2413
+ 1986661051,
2414
+ 2177026350,
2415
+ 2456956037,
2416
+ 2730485921,
2417
+ 2820302411,
2418
+ 3259730800,
2419
+ 3345764771,
2420
+ 3516065817,
2421
+ 3600352804,
2422
+ 4094571909,
2423
+ 275423344,
2424
+ 430227734,
2425
+ 506948616,
2426
+ 659060556,
2427
+ 883997877,
2428
+ 958139571,
2429
+ 1322822218,
2430
+ 1537002063,
2431
+ 1747873779,
2432
+ 1955562222,
2433
+ 2024104815,
2434
+ 2227730452,
2435
+ 2361852424,
2436
+ 2428436474,
2437
+ 2756734187,
2438
+ 3204031479,
2439
+ 3329325298
2440
+ ]);
2441
+ var SHA256_INITIAL_STATE = new Uint32Array([
2442
+ 1779033703,
2443
+ 3144134277,
2444
+ 1013904242,
2445
+ 2773480762,
2446
+ 1359893119,
2447
+ 2600822924,
2448
+ 528734635,
2449
+ 1541459225
2450
+ ]);
2451
+ function rotr(value, bits) {
2452
+ return (value >>> bits | value << 32 - bits) >>> 0;
2453
+ }
2454
+ function sha256Hex(input) {
2455
+ const bytes = new TextEncoder().encode(input);
2456
+ const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
2457
+ const buffer = new Uint8Array(paddedLength);
2458
+ buffer.set(bytes);
2459
+ buffer[bytes.length] = 128;
2460
+ const view = new DataView(buffer.buffer);
2461
+ const bitLength = bytes.length * 8;
2462
+ view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
2463
+ view.setUint32(paddedLength - 4, bitLength >>> 0);
2464
+ const state = SHA256_INITIAL_STATE.slice();
2465
+ const schedule = new Uint32Array(64);
2466
+ for (let offset = 0;offset < paddedLength; offset += 64) {
2467
+ for (let i = 0;i < 16; i++) {
2468
+ schedule[i] = view.getUint32(offset + i * 4);
2469
+ }
2470
+ for (let i = 16;i < 64; i++) {
2471
+ const x = schedule[i - 15];
2472
+ const y = schedule[i - 2];
2473
+ const s0 = (rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3) >>> 0;
2474
+ const s1 = (rotr(y, 17) ^ rotr(y, 19) ^ y >>> 10) >>> 0;
2475
+ schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1 >>> 0;
2476
+ }
2477
+ let a = state[0];
2478
+ let b = state[1];
2479
+ let c = state[2];
2480
+ let d = state[3];
2481
+ let e = state[4];
2482
+ let f = state[5];
2483
+ let g = state[6];
2484
+ let h = state[7];
2485
+ for (let i = 0;i < 64; i++) {
2486
+ const s1 = (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) >>> 0;
2487
+ const ch = (e & f ^ ~e & g) >>> 0;
2488
+ const temp1 = h + s1 + ch + SHA256_K[i] + schedule[i] >>> 0;
2489
+ const s0 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) >>> 0;
2490
+ const maj = (a & b ^ a & c ^ b & c) >>> 0;
2491
+ const temp2 = s0 + maj >>> 0;
2492
+ h = g;
2493
+ g = f;
2494
+ f = e;
2495
+ e = d + temp1 >>> 0;
2496
+ d = c;
2497
+ c = b;
2498
+ b = a;
2499
+ a = temp1 + temp2 >>> 0;
2500
+ }
2501
+ state[0] = state[0] + a >>> 0;
2502
+ state[1] = state[1] + b >>> 0;
2503
+ state[2] = state[2] + c >>> 0;
2504
+ state[3] = state[3] + d >>> 0;
2505
+ state[4] = state[4] + e >>> 0;
2506
+ state[5] = state[5] + f >>> 0;
2507
+ state[6] = state[6] + g >>> 0;
2508
+ state[7] = state[7] + h >>> 0;
2509
+ }
2510
+ let hex = "";
2511
+ for (const word of state) {
2512
+ hex += word.toString(16).padStart(8, "0");
2513
+ }
2514
+ return hex;
2515
+ }
2516
+ function resolveSha256Hex() {
2517
+ try {
2518
+ const nodeCrypto = __require("node:crypto");
2519
+ const createHash = nodeCrypto?.createHash;
2520
+ if (typeof createHash !== "function") {
2521
+ return sha256Hex;
2522
+ }
2523
+ const native = (input) => createHash("sha256").update(input, "utf8").digest("hex");
2524
+ return native("abc") === sha256Hex("abc") ? native : sha256Hex;
2525
+ } catch {
2526
+ return sha256Hex;
2527
+ }
2528
+ }
2529
+ var cachedSha256Hex;
2530
+ function digest(input) {
2531
+ cachedSha256Hex ??= resolveSha256Hex();
2532
+ return cachedSha256Hex(input);
2533
+ }
2534
+ function pseudonymize(input) {
2535
+ return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
2536
+ }
2537
+
2538
+ // ../../common/src/singleton.ts
2539
+ var PREFIX = "@uipath/common/";
2540
+ var _g = globalThis;
2541
+ function singleton(ctorOrName) {
2542
+ const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
2543
+ const key = Symbol.for(PREFIX + name);
2544
+ return {
2545
+ get(fallback) {
2546
+ return _g[key] ?? fallback;
2547
+ },
2548
+ set(value) {
2549
+ _g[key] = value;
2550
+ },
2551
+ clear() {
2552
+ delete _g[key];
2553
+ },
2554
+ getOrInit(factory, guard) {
2555
+ const existing = _g[key];
2556
+ if (existing != null && typeof existing === "object") {
2557
+ if (!guard || guard(existing)) {
2558
+ return existing;
2559
+ }
2560
+ }
2561
+ const instance = factory();
2562
+ _g[key] = instance;
2563
+ return instance;
2564
+ }
2565
+ };
2566
+ }
2567
+
2568
+ // ../../common/src/telemetry/supplied-values.ts
2569
+ var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
2570
+ function activeEntries() {
2571
+ const existing = suppliedValuesSlot.get();
2572
+ return Array.isArray(existing) ? existing : [];
2573
+ }
2574
+ var MIN_SCRUBBABLE_LENGTH = 4;
2575
+ function recordSuppliedArgumentValues(values) {
2576
+ const flat = [];
2577
+ const push = (value) => {
2578
+ if (Array.isArray(value)) {
2579
+ for (const item of value) {
2580
+ push(item);
2581
+ }
2582
+ return;
2583
+ }
2584
+ if (typeof value === "string" && value.length >= MIN_SCRUBBABLE_LENGTH) {
2585
+ flat.push(value);
2586
+ }
2587
+ };
2588
+ push(values);
2589
+ const entry = { values: flat };
2590
+ suppliedValuesSlot.set([...activeEntries(), entry]);
2591
+ return entry;
2592
+ }
2593
+ function releaseSuppliedArgumentValues(entry) {
2594
+ suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
2595
+ }
2596
+ function getSuppliedArgumentValues() {
2597
+ const all = new Set;
2598
+ for (const entry of activeEntries()) {
2599
+ for (const value of entry.values) {
2600
+ all.add(value);
2601
+ }
2602
+ }
2603
+ return [...all].sort((a, b) => b.length - a.length);
2604
+ }
2605
+
2606
+ // ../../common/src/telemetry/pii-redactor.ts
2607
+ var REDACTED = "[REDACTED]";
2608
+ var MAX_VALUE_LENGTH = 280;
2609
+ var MAX_STACK_LENGTH = 4096;
2610
+ var MAX_SCAN_LENGTH = MAX_STACK_LENGTH;
2611
+ function truncate(value, maxLength) {
2612
+ return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;
2613
+ }
2614
+ var SENSITIVE_NAME_TOKENS = new Set([
2615
+ "token",
2616
+ "tokens",
2617
+ "secret",
2618
+ "secrets",
2619
+ "password",
2620
+ "passwords",
2621
+ "pwd",
2622
+ "credential",
2623
+ "credentials",
2624
+ "auth",
2625
+ "authentication",
2626
+ "authorization",
2627
+ "authority",
2628
+ "cert",
2629
+ "certificate",
2630
+ "certificates"
2631
+ ]);
2632
+ var SENSITIVE_KEY_PREFIXES = new Set([
2633
+ "api",
2634
+ "access",
2635
+ "client",
2636
+ "private",
2637
+ "public",
2638
+ "signing",
2639
+ "encryption",
2640
+ "session",
2641
+ "master",
2642
+ "shared",
2643
+ "root",
2644
+ "ssh",
2645
+ "rsa",
2646
+ "aes",
2647
+ "hmac",
2648
+ "oauth"
2649
+ ]);
2650
+ 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;
2651
+ var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
2652
+ var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
2653
+ var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
2654
+ var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
2655
+ var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
2656
+ var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
2657
+ var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
2658
+ 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;
2659
+ var SOURCE_FILE_EXTENSIONS = new Set([
2660
+ "ts",
2661
+ "tsx",
2662
+ "js",
2663
+ "jsx",
2664
+ "mjs",
2665
+ "cjs",
2666
+ "cts",
2667
+ "mts",
2668
+ "py",
2669
+ "cs",
2670
+ "java",
2671
+ "go",
2672
+ "rs",
2673
+ "rb",
2674
+ "php",
2675
+ "sh",
2676
+ "ps1",
2677
+ "json",
2678
+ "jsonc",
2679
+ "yaml",
2680
+ "yml",
2681
+ "xml",
2682
+ "xaml",
2683
+ "md",
2684
+ "txt",
2685
+ "log",
2686
+ "css",
2687
+ "html",
2688
+ "htm",
2689
+ "csproj",
2690
+ "nuspec",
2691
+ "sql"
2692
+ ]);
2693
+ var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
2694
+ var QUOTED_LITERAL_MAX_SPAN = 200;
2695
+ var QUOTED_LITERAL_PATTERN = new RegExp([
2696
+ `(?<![A-Za-z0-9])'(?:[^\\
2697
+ ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
2698
+ `(?<![A-Za-z0-9])"(?:[^\\
2699
+ ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
2700
+ ].join("|"), "g");
2701
+ var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
2702
+ var COLLAPSED_BODY = "{…}";
2703
+ var COLLAPSED_BODY_MARKER = "\x01body\x01";
2704
+ var MAX_BODY_NESTING = 8;
2705
+ function collapseJsonBodies(text) {
2706
+ let out = text;
2707
+ for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
2708
+ const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
2709
+ if (next === out) {
2710
+ break;
2711
+ }
2712
+ out = next;
2713
+ }
2714
+ return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
2715
+ }
2716
+ var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
2717
+ function peelTrailingPunctuation(match) {
2718
+ const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
2719
+ return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
2720
+ }
2721
+ function redactUrl(raw) {
2722
+ try {
2723
+ const url = new URL(raw);
2724
+ return `${url.protocol}//${url.host}`;
2725
+ } catch {
2726
+ return `url#${pseudonymize(raw)}`;
2727
+ }
2728
+ }
2729
+ function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
2730
+ let out = truncate(value, MAX_SCAN_LENGTH);
2731
+ out = out.replace(JWT_PATTERN, () => REDACTED);
2732
+ out = out.replace(URL_PATTERN, (match) => {
2733
+ const [core, trailing] = peelTrailingPunctuation(match);
2734
+ return `${redactUrl(core)}${trailing}`;
2735
+ });
2736
+ out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
2737
+ out = out.replace(UNC_PATH_PATTERN, (_match, before, path2) => {
2738
+ const [core, trailing] = peelTrailingPunctuation(path2);
2739
+ return `${before}unc#${pseudonymize(core)}${trailing}`;
2740
+ });
2741
+ out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
2742
+ out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
2743
+ out = out.replace(HOST_PORT_PATTERN, (match) => {
2744
+ const split = match.lastIndexOf(":");
2745
+ const host = match.slice(0, split);
2746
+ const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
2747
+ if (SOURCE_FILE_EXTENSIONS.has(extension)) {
2748
+ return match;
2749
+ }
2750
+ return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
2751
+ });
2752
+ out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
2753
+ out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
2754
+ out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
2755
+ return truncate(out, maxLength);
2756
+ }
2757
+ function redactSpanName(name) {
2758
+ return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
2759
+ }
2760
+ var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
2761
+ function redactHttpDependencyName(name) {
2762
+ const parts = HTTP_DEPENDENCY_NAME.exec(name);
2763
+ if (!parts) {
2764
+ return redactMessage(name);
2765
+ }
2766
+ return `${parts[1]} ${redactMessage(parts[2])}`;
2767
+ }
2768
+ function redactMessage(value) {
2769
+ let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
2770
+ for (const supplied of getSuppliedArgumentValues()) {
2771
+ out = out.split(supplied).join(REDACTED);
2772
+ }
2773
+ return redactValueDetectors(out);
2774
+ }
2775
+ var MESSAGE_NAMES = new Set([
2776
+ "message",
2777
+ "errormessage",
2778
+ "errmessage",
2779
+ "error_message",
2780
+ "msg",
2781
+ "detail",
2782
+ "details",
2783
+ "reason",
2784
+ "instructions",
2785
+ "warning"
2786
+ ]);
2787
+ function isFreeFormValue(name, value) {
2788
+ return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
2789
+ }
2790
+ function redactError(error) {
2791
+ const safe = new Error(redactMessage(error.message ?? ""));
2792
+ safe.name = error.name;
2793
+ safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
2794
+ return safe;
2795
+ }
2796
+ function redactStack(stack) {
2797
+ const bounded = truncate(stack, MAX_STACK_LENGTH);
2798
+ const firstBreak = bounded.indexOf(`
2799
+ `);
2800
+ if (firstBreak === -1) {
2801
+ return redactMessage(bounded);
2802
+ }
2803
+ return `${redactMessage(bounded.slice(0, firstBreak))}
2804
+ ${redactValueDetectors(bounded.slice(firstBreak + 1), MAX_STACK_LENGTH)}`;
2805
+ }
2806
+ function nameTokens(name) {
2807
+ 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);
2808
+ }
2809
+ function isSensitiveName(name) {
2810
+ const tokens = nameTokens(name);
2811
+ for (let i = 0;i < tokens.length; i++) {
2812
+ const token = tokens[i];
2813
+ if (SENSITIVE_NAME_TOKENS.has(token)) {
2814
+ return true;
2815
+ }
2816
+ if (token === "key" || token === "keys") {
2817
+ const prev = tokens[i - 1];
2818
+ if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
2819
+ return true;
2820
+ }
2821
+ }
2822
+ }
2823
+ return false;
2824
+ }
2825
+ function redactProperty(name, value) {
2826
+ if (value === undefined || value === null) {
2827
+ return;
2828
+ }
2829
+ if (isSensitiveName(name)) {
2830
+ return REDACTED;
2831
+ }
2832
+ if (typeof value === "boolean" || typeof value === "number") {
2833
+ return value;
2834
+ }
2835
+ if (typeof value !== "string") {
2836
+ return "[OBJECT]";
2837
+ }
2838
+ return isFreeFormValue(name, value) ? redactMessage(value) : redactValueDetectors(value);
2839
+ }
2840
+ function redactProperties(properties) {
2841
+ const out = {};
2842
+ for (const [name, value] of Object.entries(properties)) {
2843
+ const redacted = redactProperty(name, value);
2844
+ if (redacted !== undefined) {
2845
+ out[name] = redacted;
2846
+ }
2847
+ }
2848
+ return out;
2849
+ }
2850
+
2372
2851
  // ../../common/src/catch-error.ts
2852
+ var MAX_SERIALIZED_LENGTH = 500;
2853
+ var TRUNCATION_SUFFIX = "…(truncated)";
2854
+ var REDACTED2 = "[REDACTED]";
2855
+ function cap(text) {
2856
+ return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
2857
+ }
2858
+ function omitSensitive(key, value) {
2859
+ return key.length > 0 && isSensitiveName(key) ? REDACTED2 : value;
2860
+ }
2861
+ function describeThrownValue(value) {
2862
+ if (typeof value !== "object" || value === null) {
2863
+ return String(value);
2864
+ }
2865
+ let message;
2866
+ try {
2867
+ message = value.message;
2868
+ } catch {
2869
+ message = undefined;
2870
+ }
2871
+ if (typeof message === "string" && message.length > 0) {
2872
+ return cap(message);
2873
+ }
2874
+ try {
2875
+ const json = JSON.stringify(value, omitSensitive);
2876
+ if (json !== undefined) {
2877
+ return cap(json);
2878
+ }
2879
+ } catch {}
2880
+ return String(value);
2881
+ }
2882
+ function toError(error) {
2883
+ return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
2884
+ }
2373
2885
  function isPromiseLike(value) {
2374
2886
  return value !== null && typeof value === "object" && typeof value.then === "function";
2375
2887
  }
@@ -2384,17 +2896,11 @@ function catchError(fnOrPromise) {
2384
2896
  }
2385
2897
  return [undefined, result];
2386
2898
  } catch (error) {
2387
- return [
2388
- error instanceof Error ? error : new Error(String(error)),
2389
- undefined
2390
- ];
2899
+ return [toError(error), undefined];
2391
2900
  }
2392
2901
  }
2393
2902
  function settlePromiseLike(thenable) {
2394
- return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
2395
- error instanceof Error ? error : new Error(String(error)),
2396
- undefined
2397
- ]);
2903
+ return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
2398
2904
  }
2399
2905
 
2400
2906
  // ../../common/src/error-handler.ts
@@ -2699,7 +3205,7 @@ async function extractErrorDetails(error, options) {
2699
3205
  } else if (typeof err.message === "string") {
2700
3206
  details = err.message;
2701
3207
  } else {
2702
- details = String(error);
3208
+ details = describeThrownValue(error);
2703
3209
  }
2704
3210
  const context = {};
2705
3211
  if (status) {
@@ -2775,69 +3281,10 @@ async function extractErrorMessage(error, options) {
2775
3281
  const { message } = await extractErrorDetails(error, options);
2776
3282
  return message;
2777
3283
  }
2778
- // ../../../node_modules/commander/esm.mjs
2779
- var import__ = __toESM(require_commander(), 1);
2780
- var {
2781
- program,
2782
- createCommand,
2783
- createArgument,
2784
- createOption,
2785
- CommanderError,
2786
- InvalidArgumentError,
2787
- InvalidOptionArgumentError,
2788
- Command,
2789
- Argument,
2790
- Option,
2791
- Help
2792
- } = import__.default;
2793
-
2794
- // ../../common/src/command-examples.ts
2795
- var examplesByCommand = new WeakMap;
2796
- Command.prototype.examples = function(examples) {
2797
- examplesByCommand.set(this, examples);
2798
- return this;
2799
- };
2800
- // ../../common/src/singleton.ts
2801
- var PREFIX = "@uipath/common/";
2802
- var _g = globalThis;
2803
- function singleton(ctorOrName) {
2804
- const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
2805
- const key = Symbol.for(PREFIX + name);
2806
- return {
2807
- get(fallback) {
2808
- return _g[key] ?? fallback;
2809
- },
2810
- set(value) {
2811
- _g[key] = value;
2812
- },
2813
- clear() {
2814
- delete _g[key];
2815
- },
2816
- getOrInit(factory, guard) {
2817
- const existing = _g[key];
2818
- if (existing != null && typeof existing === "object") {
2819
- if (!guard || guard(existing)) {
2820
- return existing;
2821
- }
2822
- }
2823
- const instance = factory();
2824
- _g[key] = instance;
2825
- return instance;
2826
- }
2827
- };
2828
- }
2829
-
2830
- // ../../common/src/preview.ts
2831
- var previewSlot = singleton("PreviewBuild");
2832
- function isPreviewBuild() {
2833
- return previewSlot.get(false) ?? false;
3284
+ // ../../common/src/exit-code.ts
3285
+ function setExitCode(code) {
3286
+ process.exitCode = code;
2834
3287
  }
2835
- Command.prototype.previewCommand = function(nameAndArgs, opts) {
2836
- if (isPreviewBuild()) {
2837
- return this.command(nameAndArgs, opts);
2838
- }
2839
- return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
2840
- };
2841
3288
 
2842
3289
  // ../../common/src/output-context.ts
2843
3290
  function createStorage() {
@@ -2950,45 +3397,40 @@ class SimpleLogger {
2950
3397
  this.pendingInit
2951
3398
  ]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
2952
3399
  }
2953
- debug(message, ...args) {
2954
- if (this.level > 0 /* DEBUG */)
2955
- return;
2956
- const formatted = this.format(`[DEBUG] ${message}`, args);
3400
+ write(formatted) {
2957
3401
  if (this.isFileLoggingActive()) {
2958
3402
  this.writeToFile(formatted);
2959
3403
  } else {
2960
3404
  getOutputSink().writeErr(formatted);
2961
3405
  }
2962
3406
  }
3407
+ debug(message, ...args) {
3408
+ if (this.level > 0 /* DEBUG */)
3409
+ return;
3410
+ const formatted = this.format(`[DEBUG] ${message}`, args);
3411
+ this.write(formatted);
3412
+ }
2963
3413
  info(message, ...args) {
2964
3414
  if (this.level > 1 /* INFO */)
2965
3415
  return;
2966
3416
  const formatted = this.format(message, args);
2967
- if (this.isFileLoggingActive()) {
2968
- this.writeToFile(formatted);
2969
- } else {
2970
- getOutputSink().writeErr(formatted);
2971
- }
3417
+ this.write(formatted);
2972
3418
  }
2973
3419
  warn(message, ...args) {
2974
3420
  if (this.level > 2 /* WARN */)
2975
3421
  return;
2976
3422
  const formatted = this.format(`[WARN] ${message}`, args);
2977
- if (this.isFileLoggingActive()) {
2978
- this.writeToFile(formatted);
2979
- } else {
2980
- getOutputSink().writeErr(formatted);
2981
- }
3423
+ this.write(formatted);
2982
3424
  }
2983
3425
  error(message, ...args) {
2984
3426
  if (this.level > 3 /* ERROR */)
2985
3427
  return;
2986
3428
  const formatted = this.format(`[ERROR] ${message}`, args);
2987
- if (this.isFileLoggingActive()) {
2988
- this.writeToFile(formatted);
2989
- } else {
2990
- getOutputSink().writeErr(formatted);
2991
- }
3429
+ this.write(formatted);
3430
+ }
3431
+ report(message) {
3432
+ const formatted = this.format(message, []);
3433
+ this.write(formatted);
2992
3434
  }
2993
3435
  getLevel() {
2994
3436
  return this.level;
@@ -3067,12 +3509,12 @@ var jmespathSlot = singleton("JmespathCodec");
3067
3509
  async function loadOutputCodecsAsync(needed) {
3068
3510
  const loads = [];
3069
3511
  if (needed.yaml && yamlSlot.get() === undefined) {
3070
- loads.push(import("./js-yaml-eydtmn4r.js").then((mod) => {
3512
+ loads.push(import("./js-yaml-71wj4em9.js").then((mod) => {
3071
3513
  yamlSlot.set(mod);
3072
3514
  }));
3073
3515
  }
3074
3516
  if (needed.filter && jmespathSlot.get() === undefined) {
3075
- loads.push(import("./index-xaqpc626.js").then((mod) => {
3517
+ loads.push(import("./index-q6vc5bja.js").then((mod) => {
3076
3518
  jmespathSlot.set(mod);
3077
3519
  }));
3078
3520
  }
@@ -3350,27 +3792,41 @@ class LoggerTelemetryProvider {
3350
3792
  ...this.analyticsUniqueId ? { analyticsUniqueId: this.analyticsUniqueId } : {}
3351
3793
  };
3352
3794
  }
3353
- async trackEvent(eventName, properties) {
3354
- logger.debug(formatMessage("Event", eventName, this.enrich(properties)));
3795
+ async trackEvent({ name, properties }) {
3796
+ logger.debug(formatMessage("Event", name, this.enrich(properties)));
3355
3797
  }
3356
- async trackException(error, properties) {
3798
+ async trackException({
3799
+ error,
3800
+ properties
3801
+ }) {
3357
3802
  logger.error(formatMessage("Exception", error.message, this.enrich({
3358
3803
  ...properties,
3359
3804
  stack: error.stack
3360
3805
  })));
3361
3806
  }
3362
- async trackRequest(name, duration, success, properties) {
3807
+ async trackRequest({
3808
+ name,
3809
+ durationMs,
3810
+ success,
3811
+ properties
3812
+ }) {
3363
3813
  logger.debug(formatMessage("Request", name, this.enrich({
3364
3814
  ...properties,
3365
- duration: `${duration}ms`,
3815
+ duration: `${durationMs}ms`,
3366
3816
  success
3367
3817
  })));
3368
3818
  }
3369
- async trackDependency(name, type, duration, success, properties) {
3819
+ async trackDependency({
3820
+ name,
3821
+ type,
3822
+ durationMs,
3823
+ success,
3824
+ properties
3825
+ }) {
3370
3826
  logger.debug(formatMessage("Dependency", name, this.enrich({
3371
3827
  ...properties,
3372
3828
  type,
3373
- duration: `${duration}ms`,
3829
+ duration: `${durationMs}ms`,
3374
3830
  success
3375
3831
  })));
3376
3832
  }
@@ -3567,203 +4023,75 @@ var INHERITED_SESSION_SOURCES = [
3567
4023
  var telemetrySessionSlot = singleton("TelemetrySession");
3568
4024
  var telemetryOperationIdSlot = singleton("TelemetryOperationId");
3569
4025
  function getProcessEnv2() {
3570
- return globalThis.process?.env;
3571
- }
3572
- function normalizeSessionId(value) {
3573
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
3574
- return;
3575
- }
3576
- const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
3577
- return cleaned || undefined;
3578
- }
3579
- function getConfiguredTelemetrySessionId() {
3580
- return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
3581
- }
3582
- function getInheritedSession(env) {
3583
- for (const candidate of INHERITED_SESSION_SOURCES) {
3584
- const handle = normalizeSessionId(env[candidate.envVar]);
3585
- if (handle) {
3586
- return { id: handle, source: candidate.source };
3587
- }
3588
- }
3589
- return;
3590
- }
3591
- function generateRandomSession() {
3592
- const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
3593
- crypto.getRandomValues(bytes);
3594
- let hex = "";
3595
- for (const byte of bytes) {
3596
- hex += byte.toString(16).padStart(2, "0");
3597
- }
3598
- return { id: hex, source: "random" };
3599
- }
3600
- function resolveTelemetrySession() {
3601
- const existing = telemetrySessionSlot.get();
3602
- if (existing) {
3603
- return existing;
3604
- }
3605
- const declaredHandle = getConfiguredTelemetrySessionId();
3606
- const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
3607
- telemetrySessionSlot.set(resolved);
3608
- return resolved;
3609
- }
3610
- function getTelemetrySessionSource() {
3611
- return resolveTelemetrySession().source;
3612
- }
3613
- function getTelemetryOperationId() {
3614
- const existing = telemetryOperationIdSlot.get();
3615
- if (existing) {
3616
- return existing;
3617
- }
3618
- const inboundTraceId = getInboundTraceContext()?.traceId;
3619
- const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
3620
- telemetryOperationIdSlot.set(generated);
3621
- return generated;
3622
- }
3623
- // ../../common/src/telemetry/global-telemetry-properties.ts
3624
- var telemetryPropsSlot = singleton("TelemetryDefaultProps");
3625
- function getGlobalTelemetryProperties() {
3626
- return telemetryPropsSlot.get();
3627
- }
3628
-
3629
- // ../../common/src/telemetry/pii-redactor.ts
3630
- var REDACTED = "[REDACTED]";
3631
- var MAX_VALUE_LENGTH = 200;
3632
- var SENSITIVE_NAME_TOKENS = new Set([
3633
- "token",
3634
- "tokens",
3635
- "secret",
3636
- "secrets",
3637
- "password",
3638
- "passwords",
3639
- "pwd",
3640
- "credential",
3641
- "credentials",
3642
- "auth",
3643
- "authentication",
3644
- "authorization",
3645
- "authority",
3646
- "cert",
3647
- "certificate",
3648
- "certificates"
3649
- ]);
3650
- var SENSITIVE_KEY_PREFIXES = new Set([
3651
- "api",
3652
- "access",
3653
- "client",
3654
- "private",
3655
- "public",
3656
- "signing",
3657
- "encryption",
3658
- "session",
3659
- "master",
3660
- "shared",
3661
- "root",
3662
- "ssh",
3663
- "rsa",
3664
- "aes",
3665
- "hmac",
3666
- "oauth"
3667
- ]);
3668
- 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;
3669
- var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
3670
- var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
3671
- var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
3672
- var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
3673
- var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
3674
- var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
3675
- function shortHash(input) {
3676
- let hash = 2166136261;
3677
- for (let i = 0;i < input.length; i++) {
3678
- hash ^= input.charCodeAt(i);
3679
- hash = Math.imul(hash, 16777619);
3680
- }
3681
- return (hash >>> 0).toString(16).padStart(8, "0");
3682
- }
3683
- function redactUrl(raw) {
3684
- try {
3685
- const url = new URL(raw);
3686
- return `${url.protocol}//${url.host}`;
3687
- } catch {
3688
- return `url#${shortHash(raw)}`;
3689
- }
3690
- }
3691
- function redactValueDetectors(value) {
3692
- let out = value;
3693
- out = out.replace(JWT_PATTERN, () => REDACTED);
3694
- out = out.replace(URL_PATTERN, (match) => {
3695
- const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
3696
- const core = trailing ? match.slice(0, -trailing.length) : match;
3697
- return `${redactUrl(core)}${trailing}`;
3698
- });
3699
- out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
3700
- out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
3701
- out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
3702
- out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
3703
- if (out.length > MAX_VALUE_LENGTH) {
3704
- out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
3705
- }
3706
- return out;
3707
- }
3708
- function redactValue(value) {
3709
- return redactValueDetectors(value);
3710
- }
3711
- function redactError(error) {
3712
- const safe = new Error(redactValueDetectors(error.message ?? ""));
3713
- safe.name = error.name;
3714
- safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
3715
- return safe;
3716
- }
3717
- function nameTokens(name) {
3718
- 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);
3719
- }
3720
- function isSensitiveName(name) {
3721
- const tokens = nameTokens(name);
3722
- for (let i = 0;i < tokens.length; i++) {
3723
- const token = tokens[i];
3724
- if (SENSITIVE_NAME_TOKENS.has(token)) {
3725
- return true;
3726
- }
3727
- if (token === "key" || token === "keys") {
3728
- const prev = tokens[i - 1];
3729
- if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
3730
- return true;
3731
- }
3732
- }
3733
- }
3734
- return false;
4026
+ return globalThis.process?.env;
3735
4027
  }
3736
- function redactProperty(name, value) {
3737
- if (value === undefined || value === null) {
4028
+ function normalizeSessionId(value) {
4029
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
3738
4030
  return;
3739
4031
  }
3740
- if (isSensitiveName(name)) {
3741
- return REDACTED;
4032
+ const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
4033
+ return cleaned || undefined;
4034
+ }
4035
+ function getConfiguredTelemetrySessionId() {
4036
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
4037
+ }
4038
+ function getInheritedSession(env) {
4039
+ for (const candidate of INHERITED_SESSION_SOURCES) {
4040
+ const handle = normalizeSessionId(env[candidate.envVar]);
4041
+ if (handle) {
4042
+ return { id: handle, source: candidate.source };
4043
+ }
3742
4044
  }
3743
- if (typeof value === "boolean" || typeof value === "number") {
3744
- return value;
4045
+ return;
4046
+ }
4047
+ function generateRandomSession() {
4048
+ const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
4049
+ crypto.getRandomValues(bytes);
4050
+ let hex = "";
4051
+ for (const byte of bytes) {
4052
+ hex += byte.toString(16).padStart(2, "0");
3745
4053
  }
3746
- if (typeof value !== "string") {
3747
- return "[OBJECT]";
4054
+ return { id: hex, source: "random" };
4055
+ }
4056
+ function resolveTelemetrySession() {
4057
+ const existing = telemetrySessionSlot.get();
4058
+ if (existing) {
4059
+ return existing;
3748
4060
  }
3749
- return redactValueDetectors(value);
4061
+ const declaredHandle = getConfiguredTelemetrySessionId();
4062
+ const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
4063
+ telemetrySessionSlot.set(resolved);
4064
+ return resolved;
3750
4065
  }
3751
- function redactProperties(properties) {
3752
- const out = {};
3753
- for (const [name, value] of Object.entries(properties)) {
3754
- const redacted = redactProperty(name, value);
3755
- if (redacted !== undefined) {
3756
- out[name] = redacted;
3757
- }
4066
+ function getTelemetrySessionSource() {
4067
+ return resolveTelemetrySession().source;
4068
+ }
4069
+ function getTelemetryOperationId() {
4070
+ const existing = telemetryOperationIdSlot.get();
4071
+ if (existing) {
4072
+ return existing;
3758
4073
  }
3759
- return out;
4074
+ const inboundTraceId = getInboundTraceContext()?.traceId;
4075
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
4076
+ telemetryOperationIdSlot.set(generated);
4077
+ return generated;
4078
+ }
4079
+ // ../../common/src/telemetry/global-telemetry-properties.ts
4080
+ var telemetryPropsSlot = singleton("TelemetryDefaultProps");
4081
+ function getGlobalTelemetryProperties() {
4082
+ return telemetryPropsSlot.get();
3760
4083
  }
3761
4084
 
3762
- // ../../common/src/telemetry/telemetry-service.ts
3763
- var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
3764
- var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
3765
- var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
4085
+ // ../../common/src/telemetry/span-clock.ts
4086
+ function startSpanClock() {
4087
+ const started = performance.now();
4088
+ return {
4089
+ startedAt: new Date(performance.timeOrigin + started),
4090
+ elapsedMs: () => performance.now() - started
4091
+ };
4092
+ }
3766
4093
 
4094
+ // ../../common/src/telemetry/telemetry-service.ts
3767
4095
  class TelemetryService {
3768
4096
  telemetryProvider;
3769
4097
  contextStorage;
@@ -3783,36 +4111,39 @@ class TelemetryService {
3783
4111
  this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
3784
4112
  }
3785
4113
  trackEvent(name, properties) {
3786
- const context = this.getCurrentContext();
3787
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3788
- this.telemetryProvider.trackEvent(name, enrichedProperties);
4114
+ this.telemetryProvider.trackEvent({
4115
+ name: redactSpanName(name),
4116
+ properties: this.enrichProperties(properties),
4117
+ ...this.leafCorrelation()
4118
+ });
3789
4119
  }
3790
- trackException(error, properties) {
3791
- const context = this.getCurrentContext();
3792
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3793
- this.telemetryProvider.trackException(redactError(error), enrichedProperties);
4120
+ trackException(error, properties, context) {
4121
+ this.telemetryProvider.trackException({
4122
+ error: redactError(error),
4123
+ properties: this.enrichProperties(properties),
4124
+ ...this.leafCorrelation(context)
4125
+ });
3794
4126
  }
3795
4127
  async trackRequest(name, fn, properties) {
3796
- const parentContext = this.getCurrentContext();
4128
+ const parentContext = this.getActiveContext();
3797
4129
  const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
3798
4130
  const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
4131
+ const clock = startSpanClock();
3799
4132
  const context = {
3800
4133
  operationId,
3801
4134
  ...parentId !== undefined ? { parentId } : {},
3802
- id: this.generateId()
4135
+ id: this.generateId(),
4136
+ startedAt: clock.startedAt
3803
4137
  };
3804
- const startTime = performance.now();
3805
4138
  try {
3806
4139
  const result = await this.contextStorage.run(context, fn);
3807
- const durationMs = performance.now() - startTime;
3808
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3809
- await this.telemetryProvider.trackRequest(name, durationMs, true, enrichedProperties);
4140
+ const durationMs = clock.elapsedMs();
4141
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, true, properties, context));
3810
4142
  return result;
3811
4143
  } catch (error) {
3812
- const durationMs = performance.now() - startTime;
4144
+ const durationMs = clock.elapsedMs();
3813
4145
  const err = error instanceof Error ? error : new Error(String(error));
3814
- const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, context);
3815
- await this.telemetryProvider.trackRequest(name, durationMs, false, enrichedProperties);
4146
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, context));
3816
4147
  throw error;
3817
4148
  }
3818
4149
  }
@@ -3821,8 +4152,7 @@ class TelemetryService {
3821
4152
  operationId: this.operationId ?? getTelemetryOperationId(),
3822
4153
  id: this.generateId()
3823
4154
  };
3824
- const enrichedProperties = this.enrichPropertiesWithContext(properties, requestContext);
3825
- this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
4155
+ this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, success, properties, requestContext));
3826
4156
  }
3827
4157
  createRequestContext() {
3828
4158
  const operationId = this.operationId ?? getTelemetryOperationId();
@@ -3830,7 +4160,8 @@ class TelemetryService {
3830
4160
  return {
3831
4161
  operationId,
3832
4162
  ...parentId !== undefined ? { parentId } : {},
3833
- id: this.generateId()
4163
+ id: this.generateId(),
4164
+ startedAt: startSpanClock().startedAt
3834
4165
  };
3835
4166
  }
3836
4167
  inboundParentIdFor(operationId) {
@@ -3841,58 +4172,84 @@ class TelemetryService {
3841
4172
  return this.contextStorage.run(context, fn);
3842
4173
  }
3843
4174
  createDependencyContext() {
3844
- const parentContext = this.getCurrentContext();
4175
+ const parentContext = this.getActiveContext();
3845
4176
  if (!parentContext) {
3846
4177
  return;
3847
4178
  }
3848
4179
  return {
3849
4180
  operationId: parentContext.operationId,
3850
4181
  parentId: parentContext.id,
3851
- id: this.generateId()
4182
+ id: this.generateId(),
4183
+ startedAt: startSpanClock().startedAt
3852
4184
  };
3853
4185
  }
3854
4186
  trackDependencyResult(name, type, durationMs, success, properties, context, resultCode) {
3855
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3856
- this.telemetryProvider.trackDependency(redactValue(name), type, durationMs, success, enrichedProperties, resultCode);
4187
+ this.telemetryProvider.trackDependency({
4188
+ ...this.spanFor(redactHttpDependencyName(name), durationMs, success, properties, context),
4189
+ type,
4190
+ ...resultCode !== undefined ? { resultCode } : {}
4191
+ });
3857
4192
  }
3858
4193
  async trackDependencyOperation(name, type, fn, properties) {
3859
- const parentContext = this.getCurrentContext();
4194
+ const clock = startSpanClock();
4195
+ const parentContext = this.getActiveContext();
3860
4196
  const childContext = parentContext !== undefined ? {
3861
4197
  operationId: parentContext.operationId,
3862
4198
  parentId: parentContext.id,
3863
- id: this.generateId()
3864
- } : this.createRequestContext();
3865
- const startTime = performance.now();
4199
+ id: this.generateId(),
4200
+ startedAt: clock.startedAt
4201
+ } : {
4202
+ ...this.createRequestContext(),
4203
+ startedAt: clock.startedAt
4204
+ };
3866
4205
  try {
3867
4206
  const result = await this.contextStorage.run(childContext, fn);
3868
- const durationMs = performance.now() - startTime;
3869
- const enrichedProperties = this.enrichPropertiesWithContext(properties, childContext);
3870
- await this.telemetryProvider.trackDependency(name, type, durationMs, true, enrichedProperties);
4207
+ const durationMs = clock.elapsedMs();
4208
+ await this.telemetryProvider.trackDependency({
4209
+ ...this.spanFor(name, durationMs, true, properties, childContext),
4210
+ type
4211
+ });
3871
4212
  return result;
3872
4213
  } catch (error) {
3873
- const durationMs = performance.now() - startTime;
4214
+ const durationMs = clock.elapsedMs();
3874
4215
  const err = error instanceof Error ? error : new Error(String(error));
3875
- const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, childContext);
3876
- await this.telemetryProvider.trackDependency(name, type, durationMs, false, enrichedProperties);
4216
+ await this.telemetryProvider.trackDependency({
4217
+ ...this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, childContext),
4218
+ type
4219
+ });
3877
4220
  throw error;
3878
4221
  }
3879
4222
  }
3880
- getCurrentContext() {
4223
+ getActiveContext() {
3881
4224
  return this.contextStorage.getContext();
3882
4225
  }
3883
- enrichPropertiesWithContext(properties, context) {
4226
+ leafCorrelation(explicit) {
4227
+ const context = explicit ?? this.getActiveContext();
4228
+ return {
4229
+ operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
4230
+ ...context !== undefined ? { parentId: context.id } : {}
4231
+ };
4232
+ }
4233
+ spanFor(name, durationMs, success, properties, context) {
4234
+ return {
4235
+ name: redactSpanName(name),
4236
+ durationMs,
4237
+ success,
4238
+ properties: this.enrichProperties(properties),
4239
+ operationId: context.operationId,
4240
+ ...context.parentId !== undefined ? { parentId: context.parentId } : {},
4241
+ id: context.id,
4242
+ ...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
4243
+ };
4244
+ }
4245
+ enrichProperties(properties) {
3884
4246
  const globalProperties = getGlobalTelemetryProperties();
3885
4247
  const enriched = {
3886
4248
  ...getExecutionContextTelemetryProperties(),
3887
4249
  ...globalProperties,
3888
4250
  ...this.defaultProperties,
3889
4251
  ...redactProperties(properties ?? {}),
3890
- [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
3891
- ...context ? {
3892
- [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
3893
- ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
3894
- [TELEMETRY_SPAN_ID_PROPERTY]: context.id
3895
- } : {}
4252
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
3896
4253
  };
3897
4254
  return enriched;
3898
4255
  }
@@ -3909,6 +4266,81 @@ class TelemetryService {
3909
4266
  return hex;
3910
4267
  }
3911
4268
  }
4269
+ // ../../common/src/timings.ts
4270
+ var TIMINGS_ENV_VAR = "UIP_TIMINGS";
4271
+ function createStorage2() {
4272
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
4273
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
4274
+ return {
4275
+ getStore: () => {
4276
+ return;
4277
+ },
4278
+ run: (_store, fn) => fn()
4279
+ };
4280
+ }
4281
+ return new mod.AsyncLocalStorage;
4282
+ }
4283
+ var storageSlot = singleton("TimingStorage");
4284
+ var stateSlot = singleton("Timings");
4285
+ var rootStartedSlot = singleton("TimingsRootStarted");
4286
+ var longLivedHostSlot = singleton("TimingsLongLivedHost");
4287
+ var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
4288
+ function newState(baseline) {
4289
+ return { baseline, httpMs: 0, httpCalls: 0 };
4290
+ }
4291
+ function getState() {
4292
+ const scoped = storage.getStore();
4293
+ if (scoped) {
4294
+ return scoped;
4295
+ }
4296
+ const pinned = livePinnedState();
4297
+ if (pinned !== undefined) {
4298
+ return pinned;
4299
+ }
4300
+ return newState(processStartIsInvocationStart() ? 0 : performance.now());
4301
+ }
4302
+ function livePinnedState() {
4303
+ const pinned = stateSlot.get();
4304
+ return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
4305
+ }
4306
+ function processStartIsInvocationStart() {
4307
+ return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
4308
+ }
4309
+ function timingsEnabled() {
4310
+ if (typeof process === "undefined") {
4311
+ return false;
4312
+ }
4313
+ const value = process.env?.[TIMINGS_ENV_VAR];
4314
+ if (value === undefined) {
4315
+ return false;
4316
+ }
4317
+ const normalized = value.trim().toLowerCase();
4318
+ return normalized === "1" || normalized === "true";
4319
+ }
4320
+ function recordExitCode(exitCode) {
4321
+ if (!timingsEnabled()) {
4322
+ return;
4323
+ }
4324
+ getState().exitCode = exitCode;
4325
+ }
4326
+ function invocationStartedAt() {
4327
+ return new Date(performance.timeOrigin + getState().baseline);
4328
+ }
4329
+ function invocationElapsedMs() {
4330
+ return performance.now() - getState().baseline;
4331
+ }
4332
+ function markCommandStart() {
4333
+ if (!timingsEnabled()) {
4334
+ return;
4335
+ }
4336
+ getState().commandStart = performance.now();
4337
+ }
4338
+ function recordCommandDuration(durationMs) {
4339
+ if (!timingsEnabled()) {
4340
+ return;
4341
+ }
4342
+ getState().commandMs = durationMs;
4343
+ }
3912
4344
  // ../../common/src/telemetry/proxy-http-agent.ts
3913
4345
  var slot = singleton("ProxyAuthHttpsAgent");
3914
4346
 
@@ -3929,6 +4361,9 @@ function getGlobalTelemetryInstance() {
3929
4361
  }
3930
4362
  return;
3931
4363
  }
4364
+ function setGlobalTelemetryInstance(instance) {
4365
+ telemetryInstanceSlot.set(instance);
4366
+ }
3932
4367
  var _localTelemetryInstance;
3933
4368
  function getTelemetryInstance() {
3934
4369
  const global = getGlobalTelemetryInstance();
@@ -3936,6 +4371,7 @@ function getTelemetryInstance() {
3936
4371
  return global;
3937
4372
  if (!_localTelemetryInstance) {
3938
4373
  _localTelemetryInstance = new TelemetryService(new LoggerTelemetryProvider, new NodeContextStorage);
4374
+ setGlobalTelemetryInstance(_localTelemetryInstance);
3939
4375
  }
3940
4376
  return _localTelemetryInstance;
3941
4377
  }
@@ -3948,6 +4384,14 @@ var telemetry = new Proxy({}, {
3948
4384
  });
3949
4385
 
3950
4386
  // ../../common/src/formatter.ts
4387
+ var ANSI_STYLES = {
4388
+ red: "\x1B[31m",
4389
+ dim: "\x1B[2m"
4390
+ };
4391
+ var ANSI_RESET = "\x1B[0m";
4392
+ function styleLine(line, style) {
4393
+ return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
4394
+ }
3951
4395
  var CLI_ERROR_CODES = [
3952
4396
  "invalid_argument",
3953
4397
  "authentication_required",
@@ -3986,22 +4430,6 @@ var EXIT_CODES = {
3986
4430
  ValidationError: 3,
3987
4431
  TimeoutError: 4
3988
4432
  };
3989
- class SuccessOutput {
3990
- Result = RESULTS.Success;
3991
- Code;
3992
- Data;
3993
- Pagination;
3994
- Instructions;
3995
- Log;
3996
- constructor(code, data) {
3997
- this.Code = code;
3998
- this.Data = data;
3999
- const logPath = getLogFilePath();
4000
- if (logPath) {
4001
- this.Log = logPath;
4002
- }
4003
- }
4004
- }
4005
4433
  function escapeNonAscii(jsonText) {
4006
4434
  return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
4007
4435
  const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
@@ -4066,19 +4494,45 @@ function toPascalCaseKey(key) {
4066
4494
  const lowerCamelKey = toLowerCamelCaseKey(key);
4067
4495
  return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
4068
4496
  }
4069
- function toPascalCaseData(value) {
4497
+ function collectVerbatimRefs(value, into) {
4498
+ if (typeof value !== "object" || value === null)
4499
+ return;
4500
+ if (into.has(value))
4501
+ return;
4502
+ into.add(value);
4503
+ for (const nested of Array.isArray(value) ? value : Object.values(value)) {
4504
+ collectVerbatimRefs(nested, into);
4505
+ }
4506
+ }
4507
+ function toPascalCaseData(value, verbatimKeys, subtrees) {
4508
+ if (subtrees?.mode === "skip" && typeof value === "object" && value !== null && subtrees.refs.has(value)) {
4509
+ return value;
4510
+ }
4070
4511
  if (Array.isArray(value))
4071
- return value.map(toPascalCaseData);
4512
+ return value.map((entry) => toPascalCaseData(entry, verbatimKeys, subtrees));
4072
4513
  if (!isPlainRecord(value))
4073
4514
  return value;
4074
4515
  const result = {};
4075
4516
  for (const [key, nestedValue] of Object.entries(value)) {
4076
- result[toPascalCaseKey(key)] = toPascalCaseData(nestedValue);
4517
+ const pascalKey = toPascalCaseKey(key);
4518
+ if (verbatimKeys?.has(pascalKey)) {
4519
+ result[pascalKey] = nestedValue;
4520
+ if (subtrees?.mode === "collect") {
4521
+ collectVerbatimRefs(nestedValue, subtrees.refs);
4522
+ }
4523
+ continue;
4524
+ }
4525
+ result[pascalKey] = toPascalCaseData(nestedValue, verbatimKeys, subtrees);
4077
4526
  }
4078
4527
  return result;
4079
4528
  }
4080
- function normalizeDataKeys(data) {
4081
- return toPascalCaseData(data);
4529
+ function normalizeDataKeys(data, verbatimKeys, subtrees) {
4530
+ return toPascalCaseData(data, verbatimKeys, subtrees);
4531
+ }
4532
+ function toVerbatimKeySet(preserve) {
4533
+ if (!Array.isArray(preserve))
4534
+ return;
4535
+ return new Set(preserve.map(toPascalCaseKey));
4082
4536
  }
4083
4537
  function normalizeOutputKeys(data) {
4084
4538
  const result = {};
@@ -4088,7 +4542,7 @@ function normalizeOutputKeys(data) {
4088
4542
  }
4089
4543
  return result;
4090
4544
  }
4091
- function printOutput(data, format = "json", logFn, asciiSafe = false) {
4545
+ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowStyle) {
4092
4546
  if (!data) {
4093
4547
  logFn("Empty response object. No data to display.");
4094
4548
  return;
@@ -4123,7 +4577,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
4123
4577
  if (hasData && !(rows !== null && rows.length === 0)) {
4124
4578
  const logValue = data.Log;
4125
4579
  if (rows !== null) {
4126
- printResizableTable(rows, logFn, logValue);
4580
+ printResizableTable(rows, logFn, logValue, undefined, tableRowStyle);
4127
4581
  } else {
4128
4582
  printVerticalTable(data.Data, logFn, logValue);
4129
4583
  }
@@ -4134,10 +4588,11 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
4134
4588
  }
4135
4589
  }
4136
4590
  }
4137
- function logOutput(data, format = "json") {
4591
+ function logOutput(data, format = "json", tableRowStyle) {
4138
4592
  const sink = getOutputSink();
4593
+ const styleFn = sink.capabilities.isInteractive && sink.capabilities.supportsColor ? tableRowStyle : undefined;
4139
4594
  printOutput(data, format, (msg) => sink.writeOut(`${msg}
4140
- `), needsAsciiSafeJson(sink));
4595
+ `), needsAsciiSafeJson(sink), styleFn);
4141
4596
  }
4142
4597
  function cellToString(val) {
4143
4598
  return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
@@ -4151,7 +4606,7 @@ function wrapText(text, width) {
4151
4606
  }
4152
4607
  return lines;
4153
4608
  }
4154
- function printTable(data, logFn, externalLogValue) {
4609
+ function printTable(data, logFn, externalLogValue, tableRowStyle) {
4155
4610
  if (data.length === 0)
4156
4611
  return;
4157
4612
  const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
@@ -4161,7 +4616,7 @@ function printTable(data, logFn, externalLogValue) {
4161
4616
  logFn(keys.map((_, i) => "-".repeat(maxWidths[i])).join("-|-"));
4162
4617
  data.forEach((item) => {
4163
4618
  const row = keys.map((key, i) => cellToString(item[key]).padEnd(maxWidths[i])).join(" | ");
4164
- logFn(row);
4619
+ logFn(styleLine(row, tableRowStyle?.(item)));
4165
4620
  });
4166
4621
  if (externalLogValue) {
4167
4622
  logFn("");
@@ -4204,14 +4659,14 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
4204
4659
  logFn(`Log: ${externalLogValue}`);
4205
4660
  }
4206
4661
  }
4207
- function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth) {
4662
+ function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
4208
4663
  if (data.length === 0)
4209
4664
  return;
4210
4665
  const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
4211
4666
  if (keys.length === 0)
4212
4667
  return;
4213
4668
  if (!process.stdout.isTTY) {
4214
- printTable(data, logFn, externalLogValue);
4669
+ printTable(data, logFn, externalLogValue, tableRowStyle);
4215
4670
  return;
4216
4671
  }
4217
4672
  const naturalWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
@@ -4219,7 +4674,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
4219
4674
  const totalWidth = naturalWidths.reduce((a, b) => a + b, 0) + separatorTotal;
4220
4675
  const termWidth = availableWidth ?? (process.stdout.columns || 120);
4221
4676
  if (totalWidth <= termWidth) {
4222
- printTable(data, logFn, externalLogValue);
4677
+ printTable(data, logFn, externalLogValue, tableRowStyle);
4223
4678
  return;
4224
4679
  }
4225
4680
  const overflow = totalWidth - termWidth;
@@ -4265,6 +4720,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
4265
4720
  logFn(header);
4266
4721
  logFn(keys.map((_, i) => "-".repeat(finalWidths[i])).join("-|-"));
4267
4722
  data.forEach((item) => {
4723
+ const style = tableRowStyle?.(item);
4268
4724
  const cellLines = keys.map((key, i) => wrapText(cellToString(item[key]), finalWidths[i]));
4269
4725
  const lineCount = Math.max(...cellLines.map((l) => l.length));
4270
4726
  for (let line = 0;line < lineCount; line++) {
@@ -4272,7 +4728,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
4272
4728
  const val = line < cellLines[i].length ? cellLines[i][line] : "";
4273
4729
  return val.padEnd(finalWidths[i]);
4274
4730
  }).join(" | ");
4275
- logFn(row);
4731
+ logFn(styleLine(row, style));
4276
4732
  }
4277
4733
  });
4278
4734
  if (externalLogValue) {
@@ -4416,30 +4872,36 @@ var OutputFormatter;
4416
4872
  ((OutputFormatter) => {
4417
4873
  function success(data, options) {
4418
4874
  data.Log ??= getLogFilePath() || undefined;
4419
- const normalize = !options?.preserveDataKeys;
4875
+ const normalize = options?.preserveDataKeys !== true;
4876
+ const verbatim = toVerbatimKeySet(options?.preserveDataKeys);
4877
+ const subtrees = verbatim && {
4878
+ refs: new Set,
4879
+ mode: "collect"
4880
+ };
4420
4881
  if (normalize) {
4421
- data.Data = normalizeDataKeys(data.Data);
4882
+ data.Data = normalizeDataKeys(data.Data, verbatim, subtrees);
4422
4883
  }
4423
4884
  const filter = getOutputFilter();
4424
4885
  if (filter) {
4425
4886
  const filtered = applyFilter(data.Data, filter);
4426
- data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
4887
+ data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
4427
4888
  }
4428
- logOutput(normalizeOutputKeys(data), getOutputFormat());
4889
+ logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4429
4890
  }
4430
4891
  OutputFormatter.success = success;
4431
4892
  function error(data) {
4432
4893
  data.Log ??= getLogFilePath() || undefined;
4433
4894
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
4434
4895
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
4435
- process.exitCode = EXIT_CODES[data.Result] ?? 1;
4896
+ const exitCode = EXIT_CODES[data.Result] ?? 1;
4897
+ setExitCode(exitCode);
4436
4898
  recordCommandFailureTelemetry({
4437
4899
  result: data.Result,
4438
4900
  errorCode: data.ErrorCode,
4439
4901
  retry: data.Retry,
4440
4902
  message: data.Message,
4441
4903
  context: data.Context,
4442
- exitCode: process.exitCode,
4904
+ exitCode,
4443
4905
  errorClass: data.TelemetryErrorClass,
4444
4906
  terminalOutcome: data.TelemetryTerminalOutcome,
4445
4907
  terminalSignal: data.TelemetryTerminalSignal
@@ -4515,6 +4977,39 @@ var OutputFormatter;
4515
4977
  }
4516
4978
  OutputFormatter.formatToString = formatToString;
4517
4979
  })(OutputFormatter ||= {});
4980
+ // ../../../node_modules/commander/esm.mjs
4981
+ var import__ = __toESM(require_commander(), 1);
4982
+ var {
4983
+ program,
4984
+ createCommand,
4985
+ createArgument,
4986
+ createOption,
4987
+ CommanderError,
4988
+ InvalidArgumentError,
4989
+ InvalidOptionArgumentError,
4990
+ Command,
4991
+ Argument,
4992
+ Option,
4993
+ Help
4994
+ } = import__.default;
4995
+
4996
+ // ../../common/src/command-examples.ts
4997
+ var examplesByCommand = new WeakMap;
4998
+ Command.prototype.examples = function(examples) {
4999
+ examplesByCommand.set(this, examples);
5000
+ return this;
5001
+ };
5002
+ // ../../common/src/preview.ts
5003
+ var previewSlot = singleton("PreviewBuild");
5004
+ function isPreviewBuild() {
5005
+ return previewSlot.get(false) ?? false;
5006
+ }
5007
+ Command.prototype.previewCommand = function(nameAndArgs, opts) {
5008
+ if (isPreviewBuild()) {
5009
+ return this.command(nameAndArgs, opts);
5010
+ }
5011
+ return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
5012
+ };
4518
5013
 
4519
5014
  // ../../common/src/telemetry/command-attribution.ts
4520
5015
  var LEGACY_SKILL_NAMESPACE = "uipath:";
@@ -4669,6 +5164,57 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
4669
5164
  };
4670
5165
  }
4671
5166
 
5167
+ // ../../common/src/telemetry/command-name.ts
5168
+ var TELEMETRY_COMMAND_ROOT = "uip";
5169
+ function commandTelemetryName(parts) {
5170
+ const tokens = [];
5171
+ for (const part of parts) {
5172
+ const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== TELEMETRY_COMMAND_ROOT);
5173
+ if (pieces.every(isCommandToken)) {
5174
+ tokens.push(...pieces);
5175
+ continue;
5176
+ }
5177
+ tokens.push(UNKNOWN_TOKEN);
5178
+ }
5179
+ return [TELEMETRY_COMMAND_ROOT, ...tokens].join(".");
5180
+ }
5181
+ var COMMAND_TOKEN_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
5182
+ var MAX_COMMAND_TOKEN_LENGTH = 32;
5183
+ var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
5184
+ function isCommandToken(token) {
5185
+ return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token) && !/^\d+$/.test(token);
5186
+ }
5187
+ var UNKNOWN_TOKEN = "<unknown>";
5188
+
5189
+ // ../../common/src/telemetry/invocation-request.ts
5190
+ var requestContextSlot = singleton("TelemetryInvocationRequestContext");
5191
+ function activeContext() {
5192
+ return telemetry.getActiveContext?.();
5193
+ }
5194
+ function runWithInvocationRequest(fn) {
5195
+ const context = telemetry.createRequestContext();
5196
+ context.startedAt = invocationStartedAt();
5197
+ requestContextSlot.set(context);
5198
+ return telemetry.runWithContext(context, fn);
5199
+ }
5200
+ function ensureInvocationRequestScope(fn) {
5201
+ if (activeContext() !== undefined) {
5202
+ return fn();
5203
+ }
5204
+ const kept = requestContextSlot.get();
5205
+ return kept === undefined ? runWithInvocationRequest(fn) : telemetry.runWithContext(kept, fn);
5206
+ }
5207
+ function getInvocationRequestContext() {
5208
+ return activeContext() ?? requestContextSlot.get();
5209
+ }
5210
+ function emitInvocationRequest(name, success, properties) {
5211
+ const context = getInvocationRequestContext();
5212
+ telemetry.trackRequestResult(name, invocationElapsedMs(), success, properties, context);
5213
+ if (context !== undefined && requestContextSlot.get() === context) {
5214
+ requestContextSlot.clear();
5215
+ }
5216
+ }
5217
+
4672
5218
  // ../../common/src/trackedAction.ts
4673
5219
  var pollSignalSlot = singleton("PollSignal");
4674
5220
  var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
@@ -4676,28 +5222,74 @@ var retryHintValues = new Set(RETRY_HINTS);
4676
5222
  var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
4677
5223
  var processContext = {
4678
5224
  exit: (code) => {
4679
- process.exitCode = code;
5225
+ recordExitCode(code);
5226
+ setExitCode(code);
4680
5227
  },
4681
5228
  get pollSignal() {
4682
5229
  return pollSignalSlot.get();
4683
5230
  }
4684
5231
  };
5232
+ var TELEMETRY_ARG_VALUE_WITHHELD = "<provided>";
5233
+ var TELEMETRY_ARG_VALUE_DEFAULTED = "<default>";
5234
+ function recordableArgValue(value, choices) {
5235
+ if (typeof value === "boolean" || typeof value === "number") {
5236
+ return value;
5237
+ }
5238
+ if (choices && choices.length > 0) {
5239
+ if (typeof value === "string" && choices.includes(value)) {
5240
+ return value;
5241
+ }
5242
+ if (Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string" && choices.includes(entry))) {
5243
+ return value.join(",");
5244
+ }
5245
+ }
5246
+ return TELEMETRY_ARG_VALUE_WITHHELD;
5247
+ }
4685
5248
  function extractCommandParams(cmd) {
4686
5249
  const params = {};
4687
- const add = (name, value) => {
4688
- if (name && value !== undefined) {
4689
- params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = value;
4690
- }
4691
- };
5250
+ forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
5251
+ const recordable = recordableArgValue(value, choices);
5252
+ params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
5253
+ });
5254
+ return params;
5255
+ }
5256
+ function isDefaultedOption(cmd, name) {
5257
+ const source = cmd.getOptionValueSource?.(name);
5258
+ return source === "default" || source === "implied";
5259
+ }
5260
+ function isDefaultedPositional(cmd, index) {
5261
+ return index >= (cmd.args?.length ?? 0);
5262
+ }
5263
+ function forEachSuppliedArgument(cmd, visit) {
4692
5264
  const registered = cmd.registeredArguments ?? [];
4693
5265
  const processed = cmd.processedArgs ?? [];
4694
5266
  for (let i = 0;i < registered.length; i++) {
4695
- add(registered[i].name(), processed[i]);
5267
+ const name = registered[i].name();
5268
+ if (name && processed[i] !== undefined) {
5269
+ visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
5270
+ }
5271
+ }
5272
+ const choicesByAttribute = new Map;
5273
+ for (const option of cmd.options) {
5274
+ choicesByAttribute.set(option.attributeName(), option.argChoices);
4696
5275
  }
4697
5276
  for (const [key, value] of Object.entries(cmd.opts())) {
4698
- add(key, value);
5277
+ if (key && value !== undefined) {
5278
+ visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
5279
+ }
4699
5280
  }
4700
- return params;
5281
+ }
5282
+ function withheldArgumentValues(cmd) {
5283
+ const values = [];
5284
+ forEachSuppliedArgument(cmd, (_name, value, choices, defaulted) => {
5285
+ if (defaulted) {
5286
+ return;
5287
+ }
5288
+ if (recordableArgValue(value, choices) === TELEMETRY_ARG_VALUE_WITHHELD) {
5289
+ values.push(value);
5290
+ }
5291
+ });
5292
+ return values;
4701
5293
  }
4702
5294
  function deriveCommandPath(cmd) {
4703
5295
  const parts = [];
@@ -4712,7 +5304,7 @@ function deriveCommandPath(cmd) {
4712
5304
  if (parts.length > 1) {
4713
5305
  parts.shift();
4714
5306
  }
4715
- return ["uip", ...parts.filter((p) => p !== "uip")].join(".");
5307
+ return commandTelemetryName(parts);
4716
5308
  }
4717
5309
  function isCliErrorCode(value) {
4718
5310
  return typeof value === "string" && cliErrorCodeValues.has(value);
@@ -4752,68 +5344,77 @@ Command.prototype.trackedAction = function(context, fn, properties) {
4752
5344
  });
4753
5345
  const telemetryName = deriveCommandPath(command);
4754
5346
  const props = typeof properties === "function" ? properties(...args) : properties;
4755
- const requestContext = telemetry.createRequestContext();
4756
- const startTime = performance.now();
4757
- let errorMessage;
4758
- let fallbackExitCode = EXIT_CODES.Success;
4759
- clearRecordedCommandFailureTelemetry();
4760
- const [error] = await catchError(telemetry.runWithContext(requestContext, () => {
4761
- const violation = implicitLimitViolation(command);
4762
- if (violation) {
4763
- return Promise.reject(violation);
4764
- }
4765
- return fn(...args);
4766
- }));
4767
- if (error) {
4768
- errorMessage = error instanceof Error ? error.message : String(error);
4769
- logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
4770
- const typed = error;
4771
- const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
4772
- const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
4773
- const finalResult = customResult ?? RESULTS.Failure;
4774
- const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
4775
- const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
4776
- const typedRetry = typed.retry ?? typed.Retry;
4777
- const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
4778
- const typedContext = typed.context ?? typed.Context;
4779
- const customContext = isErrorContext(typedContext) ? typedContext : undefined;
4780
- const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
4781
- fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
4782
- OutputFormatter.error({
4783
- Result: finalResult,
4784
- ...customErrorCode ? { ErrorCode: customErrorCode } : {},
4785
- Message: errorMessage,
4786
- Instructions: customInstructions ?? commandHelpHint(telemetryName),
4787
- ...customRetry ? { Retry: customRetry } : {},
4788
- ...customContext ? { Context: customContext } : {}
5347
+ markCommandStart();
5348
+ const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
5349
+ try {
5350
+ const startTime = performance.now();
5351
+ let errorMessage;
5352
+ let fallbackExitCode = EXIT_CODES.Success;
5353
+ clearRecordedCommandFailureTelemetry();
5354
+ const [error] = await catchError(ensureInvocationRequestScope(() => {
5355
+ const violation = implicitLimitViolation(command);
5356
+ if (violation) {
5357
+ return Promise.reject(violation);
5358
+ }
5359
+ return fn(...args);
5360
+ }));
5361
+ if (error) {
5362
+ errorMessage = error instanceof Error ? error.message : String(error);
5363
+ logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
5364
+ const typed = error;
5365
+ const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
5366
+ const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
5367
+ const finalResult = customResult ?? RESULTS.Failure;
5368
+ const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
5369
+ const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
5370
+ const typedRetry = typed.retry ?? typed.Retry;
5371
+ const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
5372
+ const typedContext = typed.context ?? typed.Context;
5373
+ const customContext = isErrorContext(typedContext) ? typedContext : undefined;
5374
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
5375
+ fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
5376
+ OutputFormatter.error({
5377
+ Result: finalResult,
5378
+ ...customErrorCode ? { ErrorCode: customErrorCode } : {},
5379
+ Message: errorMessage,
5380
+ Instructions: customInstructions ?? commandHelpHint(telemetryName),
5381
+ ...customRetry ? { Retry: customRetry } : {},
5382
+ ...customContext ? { Context: customContext } : {}
5383
+ });
5384
+ context.exit(fallbackExitCode);
5385
+ }
5386
+ const durationMs = performance.now() - startTime;
5387
+ recordCommandDuration(durationMs);
5388
+ const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
5389
+ const recordedFailure = takeRecordedCommandFailureTelemetry();
5390
+ const success = !error && exitCode === 0;
5391
+ const terminalTelemetry = buildCommandTerminalTelemetryProperties({
5392
+ error,
5393
+ exitCode,
5394
+ recordedFailure,
5395
+ pollSignal: context.pollSignal
4789
5396
  });
4790
- context.exit(fallbackExitCode);
4791
- }
4792
- const durationMs = performance.now() - startTime;
4793
- const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
4794
- const recordedFailure = takeRecordedCommandFailureTelemetry();
4795
- const success = !error && exitCode === 0;
4796
- const terminalTelemetry = buildCommandTerminalTelemetryProperties({
4797
- error,
4798
- exitCode,
4799
- recordedFailure,
4800
- pollSignal: context.pollSignal
4801
- });
4802
- const commandParams = extractCommandParams(command);
4803
- if (props) {
4804
- for (const key of Object.keys(props)) {
4805
- delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
4806
- }
4807
- }
4808
- const baseProperties = redactProperties({
4809
- ...commandParams,
4810
- ...props,
4811
- ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
4812
- command: "true",
4813
- ...terminalTelemetry,
4814
- ...errorMessage ? { errorMessage } : {}
4815
- });
4816
- telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
5397
+ if (terminalTelemetry.error_class === "internal" && error) {
5398
+ telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { command_name: telemetryName }, getInvocationRequestContext());
5399
+ }
5400
+ const commandParams = extractCommandParams(command);
5401
+ if (props) {
5402
+ for (const key of Object.keys(props)) {
5403
+ delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
5404
+ }
5405
+ }
5406
+ const baseProperties = redactProperties({
5407
+ ...commandParams,
5408
+ ...props,
5409
+ ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
5410
+ command: "true",
5411
+ ...terminalTelemetry,
5412
+ ...errorMessage ? { errorMessage } : {}
5413
+ });
5414
+ emitInvocationRequest(telemetryName, success, baseProperties);
5415
+ } finally {
5416
+ releaseSuppliedArgumentValues(supplied);
5417
+ }
4817
5418
  });
4818
5419
  };
4819
5420
  // ../../common/src/completer.ts
@@ -4823,6 +5424,204 @@ var guardInstalledSlot = singleton("ConsoleGuardInstalled");
4823
5424
  var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
4824
5425
  // ../../common/src/constants.ts
4825
5426
  var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
5427
+ // ../../common/src/entity-name-rules.ts
5428
+ var RESERVED_SQL_KEYWORDS_LOWER = new Set(["group", "order"]);
5429
+ var RESERVED_FIELD_NAMES_LOWER = new Set([
5430
+ "id",
5431
+ "createdby",
5432
+ "createtime",
5433
+ "updatedby",
5434
+ "updatetime",
5435
+ "recordowner",
5436
+ "version"
5437
+ ]);
5438
+ var RESERVED_KEYWORDS_LOWER = new Set([
5439
+ "abstract",
5440
+ "as",
5441
+ "base",
5442
+ "bool",
5443
+ "break",
5444
+ "byte",
5445
+ "case",
5446
+ "catch",
5447
+ "char",
5448
+ "checked",
5449
+ "class",
5450
+ "const",
5451
+ "continue",
5452
+ "decimal",
5453
+ "default",
5454
+ "delegate",
5455
+ "do",
5456
+ "double",
5457
+ "else",
5458
+ "enum",
5459
+ "event",
5460
+ "explicit",
5461
+ "extern",
5462
+ "false",
5463
+ "finally",
5464
+ "fixed",
5465
+ "float",
5466
+ "for",
5467
+ "foreach",
5468
+ "goto",
5469
+ "if",
5470
+ "implicit",
5471
+ "in",
5472
+ "int",
5473
+ "interface",
5474
+ "internal",
5475
+ "is",
5476
+ "lock",
5477
+ "long",
5478
+ "namespace",
5479
+ "new",
5480
+ "null",
5481
+ "object",
5482
+ "operator",
5483
+ "out",
5484
+ "override",
5485
+ "params",
5486
+ "private",
5487
+ "protected",
5488
+ "public",
5489
+ "readonly",
5490
+ "ref",
5491
+ "return",
5492
+ "sbyte",
5493
+ "sealed",
5494
+ "short",
5495
+ "sizeof",
5496
+ "stackalloc",
5497
+ "static",
5498
+ "string",
5499
+ "struct",
5500
+ "switch",
5501
+ "this",
5502
+ "throw",
5503
+ "true",
5504
+ "try",
5505
+ "typeof",
5506
+ "uint",
5507
+ "ulong",
5508
+ "unchecked",
5509
+ "unsafe",
5510
+ "ushort",
5511
+ "using",
5512
+ "virtual",
5513
+ "void",
5514
+ "volatile",
5515
+ "while",
5516
+ "addhandler",
5517
+ "addressof",
5518
+ "alias",
5519
+ "and",
5520
+ "andalso",
5521
+ "boolean",
5522
+ "byref",
5523
+ "byval",
5524
+ "call",
5525
+ "cbool",
5526
+ "cbyte",
5527
+ "cchar",
5528
+ "cdate",
5529
+ "cdbl",
5530
+ "cdec",
5531
+ "cint",
5532
+ "clng",
5533
+ "cobj",
5534
+ "csbyte",
5535
+ "cshort",
5536
+ "csng",
5537
+ "cstr",
5538
+ "ctype",
5539
+ "cuint",
5540
+ "culng",
5541
+ "cushort",
5542
+ "date",
5543
+ "declare",
5544
+ "dim",
5545
+ "directcast",
5546
+ "each",
5547
+ "elseif",
5548
+ "end",
5549
+ "endif",
5550
+ "erase",
5551
+ "error",
5552
+ "exit",
5553
+ "friend",
5554
+ "function",
5555
+ "get",
5556
+ "gettype",
5557
+ "getxmlnamespace",
5558
+ "global",
5559
+ "gosub",
5560
+ "goto",
5561
+ "handles",
5562
+ "implements",
5563
+ "imports",
5564
+ "inherits",
5565
+ "integer",
5566
+ "isnot",
5567
+ "let",
5568
+ "lib",
5569
+ "like",
5570
+ "loop",
5571
+ "me",
5572
+ "mod",
5573
+ "module",
5574
+ "mustinherit",
5575
+ "mustoverride",
5576
+ "mybase",
5577
+ "myclass",
5578
+ "narrowing",
5579
+ "next",
5580
+ "not",
5581
+ "nothing",
5582
+ "notinheritable",
5583
+ "notoverridable",
5584
+ "of",
5585
+ "on",
5586
+ "option",
5587
+ "optional",
5588
+ "or",
5589
+ "orelse",
5590
+ "overloads",
5591
+ "overridable",
5592
+ "overrides",
5593
+ "paramarray",
5594
+ "partial",
5595
+ "property",
5596
+ "raiseevent",
5597
+ "redim",
5598
+ "rem",
5599
+ "removehandler",
5600
+ "resume",
5601
+ "select",
5602
+ "set",
5603
+ "shadows",
5604
+ "shared",
5605
+ "single",
5606
+ "step",
5607
+ "stop",
5608
+ "structure",
5609
+ "sub",
5610
+ "synclock",
5611
+ "then",
5612
+ "to",
5613
+ "trycast",
5614
+ "uinteger",
5615
+ "ushort",
5616
+ "variant",
5617
+ "wend",
5618
+ "when",
5619
+ "widening",
5620
+ "with",
5621
+ "withevents",
5622
+ "writeonly",
5623
+ "xor"
5624
+ ]);
4826
5625
  // ../../common/src/host-global-options.ts
4827
5626
  var HOST_GLOBAL_OPTIONS_WITH_VALUE = [
4828
5627
  "--output",
@@ -5290,9 +6089,9 @@ var init_is_in_ssh = __esm(() => {
5290
6089
  });
5291
6090
  var exports_open = {};
5292
6091
  __export(exports_open, {
5293
- openApp: () => openApp,
6092
+ apps: () => apps,
5294
6093
  default: () => open_default,
5295
- apps: () => apps
6094
+ openApp: () => openApp
5296
6095
  });
5297
6096
  function detectArchBinary(binary) {
5298
6097
  if (typeof binary === "string" || Array.isArray(binary)) {
@@ -5841,7 +6640,7 @@ class InvalidBaseUrlError extends Error {
5841
6640
  super(`Invalid base URL: "${url}"
5842
6641
  ` + `Reason: ${reason}
5843
6642
 
5844
- ` + `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>).
6643
+ ` + `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>).
5845
6644
  ` + `You can specify the URL via:
5846
6645
  ` + ` • --authority flag
5847
6646
  ` + ` • UIPATH_URL environment variable
@@ -5862,10 +6661,16 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
5862
6661
  while (baseUrl.endsWith("/")) {
5863
6662
  baseUrl = baseUrl.slice(0, -1);
5864
6663
  }
6664
+ const hasScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(baseUrl);
6665
+ const [hostCandidate] = baseUrl.split(/[/?#]/, 1);
6666
+ if (!hasScheme && hostCandidate.includes(".")) {
6667
+ baseUrl = `https://${baseUrl}`;
6668
+ }
5865
6669
  const resolvedBaseUrl = baseUrl;
5866
6670
  const [urlError, url] = catchError2(() => new URL(resolvedBaseUrl));
5867
6671
  if (urlError) {
5868
- throw new InvalidBaseUrlError(baseUrl, `Malformed URL. ${urlError instanceof Error ? urlError.message : "Unknown error"}`);
6672
+ 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"}`;
6673
+ throw new InvalidBaseUrlError(baseUrl, `Malformed URL.${shapeHint}`);
5869
6674
  }
5870
6675
  if (url.protocol !== "https:") {
5871
6676
  throw new InvalidBaseUrlError(baseUrl, `Authority must use https:// scheme, got ${url.protocol}//. OIDC token exchange requires TLS end-to-end.`);
@@ -5949,9 +6754,9 @@ function getProfileStorage() {
5949
6754
  if (isAuthProfileStorage(existing)) {
5950
6755
  return existing;
5951
6756
  }
5952
- const storage = createProfileStorage();
5953
- globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
5954
- return storage;
6757
+ const storage2 = createProfileStorage();
6758
+ globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage2;
6759
+ return storage2;
5955
6760
  }
5956
6761
  var profileStorage = getProfileStorage();
5957
6762
 
@@ -6143,6 +6948,17 @@ var requireEnv = (name) => {
6143
6948
  }
6144
6949
  return value;
6145
6950
  };
6951
+ var OPAQUE_TOKEN_BASE_URL_VAR = "UIPATH_URL";
6952
+ var resolveBaseUrl = (rawUrl, failureContext) => {
6953
+ const [baseUrlError, baseUrl] = catchError2(() => normalizeAndValidateBaseUrl(rawUrl));
6954
+ if (baseUrlError) {
6955
+ if (baseUrlError instanceof InvalidBaseUrlError) {
6956
+ throw baseUrlError;
6957
+ }
6958
+ throw new EnvAuthConfigError(`${failureContext}: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
6959
+ }
6960
+ return baseUrl;
6961
+ };
6146
6962
  var readAuthFromEnv = () => {
6147
6963
  const accessToken = requireEnv(ENV_AUTH_VARS.token);
6148
6964
  const organizationName = requireEnv(ENV_AUTH_VARS.organizationName);
@@ -6151,19 +6967,29 @@ var readAuthFromEnv = () => {
6151
6967
  const tenantId = requireEnv(ENV_AUTH_VARS.tenantId);
6152
6968
  const [parseError, payload] = catchError2(() => parseJWT(accessToken));
6153
6969
  if (parseError) {
6154
- throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} is not a valid JWT: ` + `${parseError instanceof Error ? parseError.message : String(parseError)}`);
6970
+ const parseErrorMessage = parseError instanceof Error ? parseError.message : String(parseError);
6971
+ const rawUrl = process.env[OPAQUE_TOKEN_BASE_URL_VAR];
6972
+ if (!rawUrl) {
6973
+ 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}).`);
6974
+ }
6975
+ const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
6976
+ return {
6977
+ loginStatus: "Logged in",
6978
+ accessToken,
6979
+ baseUrl: baseUrl2,
6980
+ organizationName,
6981
+ organizationId,
6982
+ tenantName,
6983
+ tenantId,
6984
+ source: "env-vars",
6985
+ 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}`
6986
+ };
6155
6987
  }
6156
6988
  const iss = payload.iss;
6157
6989
  if (typeof iss !== "string" || iss.length === 0) {
6158
6990
  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.`);
6159
6991
  }
6160
- const [baseUrlError, baseUrl] = catchError2(() => normalizeAndValidateBaseUrl(iss));
6161
- if (baseUrlError) {
6162
- if (baseUrlError instanceof InvalidBaseUrlError) {
6163
- throw baseUrlError;
6164
- }
6165
- throw new EnvAuthConfigError(`Failed to derive server URL from token 'iss' claim: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
6166
- }
6992
+ const baseUrl = resolveBaseUrl(iss, "Failed to derive server URL from token 'iss' claim");
6167
6993
  const expiration = getTokenExpiration(accessToken);
6168
6994
  const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
6169
6995
  const identity = resolveSessionIdentity(accessToken);
@@ -6188,8 +7014,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
6188
7014
  async function refreshTokenFingerprint(refreshToken) {
6189
7015
  const bytes = new TextEncoder().encode(refreshToken);
6190
7016
  if (globalThis.crypto?.subtle) {
6191
- const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
6192
- return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
7017
+ const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
7018
+ return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
6193
7019
  }
6194
7020
  const { createHash } = await import("node:crypto");
6195
7021
  return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
@@ -7059,6 +7885,7 @@ function errorMessage(error) {
7059
7885
  }
7060
7886
  init_constants();
7061
7887
  init_src();
7888
+ init_constants();
7062
7889
  var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
7063
7890
  var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
7064
7891
  var INVALID_TENANT_CODE = "INVALID_TENANT";
@@ -8439,4 +9266,4 @@ var registerCommands = async (program2) => {
8439
9266
 
8440
9267
  export { Command, metadata, registerCommands };
8441
9268
 
8442
- //# debugId=75913A1D064EFF9364756E2164756E21
9269
+ //# debugId=D23AB7B33280E41064756E2164756E21