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