@uipath/llm-gateway-tool 1.201.0 → 1.202.0-preview.136

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