@uipath/case-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.
Files changed (96) hide show
  1. package/dist/{authoring-aaaqwck3.js → authoring-cvjhkfxp.js} +74 -48
  2. package/dist/{browser-strategy-rkcvc6tn.js → browser-strategy-6atc7v8s.js} +3 -3
  3. package/dist/case-api-bwcxsbxe.js +381 -0
  4. package/dist/case-debug-studio-web-service-qcb328bt.js +335 -0
  5. package/dist/{case-pack-service-bxas5bxz.js → case-pack-service-txby2znw.js} +11 -18
  6. package/dist/case-validate-service-0q8krj2a.js +2114 -0
  7. package/dist/connector-enrichment-service-agqxam5y.js +60 -0
  8. package/dist/connector-lookup-service-ycgk77n0.js +22 -0
  9. package/dist/connector-task-spec-kdx5bv87.js +1250 -0
  10. package/dist/{de-5KVP66U6-t37qr521.js → de-5KVP66U6-1bnf4zt5.js} +54 -54
  11. package/dist/{de-5HU6GFWV-zheyw6d2.js → de-7XQXX2DK-tqdy5n2b.js} +857 -845
  12. package/dist/debug-service-dxx5pfev.js +57 -0
  13. package/dist/{en-MABQK6C4-nkzq2j8t.js → en-5ZGC5VQ3-h581y30k.js} +897 -897
  14. package/dist/{en-4KXU7N7B-24v330b5.js → en-X3S6IZ5J-nhkg6pwn.js} +55 -61
  15. package/dist/enrichment-service-ebz1f4ds.js +421 -0
  16. package/dist/{es-MX-POESXYP2-9538722k.js → es-MX-U2VN3SZW-anynsmd8.js} +857 -845
  17. package/dist/{es-MX-XAVLOQW3-47a405kf.js → es-MX-XAVLOQW3-q00km2y7.js} +54 -54
  18. package/dist/{es-VFPNVMP5-6sftsdxe.js → es-VFPNVMP5-bx2c337j.js} +54 -54
  19. package/dist/{es-LUTYN7U7-ye5zn4sn.js → es-ZGCPPOME-8gazspjj.js} +857 -845
  20. package/dist/{fr-E5MDO4EG-f3x1jeqw.js → fr-E5MDO4EG-c3mkty2t.js} +54 -54
  21. package/dist/{fr-LJIK56LW-xf3xf2kh.js → fr-T3G5GZCT-y3f7xb1q.js} +857 -845
  22. package/dist/{index-cncq089f.js → index-7s201ka0.js} +163 -80
  23. package/dist/{index-hsadteg4.js → index-h8cph72k.js} +4 -4
  24. package/dist/index-k4xz16db.js +63712 -0
  25. package/dist/{index-p50kx6jv.js → index-k5tbd184.js} +276 -276
  26. package/dist/index-kwxe1vep.js +143 -0
  27. package/dist/{index-9f8q2ege.js → index-p3vk57z7.js} +27 -27
  28. package/dist/index-qyf1dee9.js +630 -0
  29. package/dist/index.js +16 -17
  30. package/dist/{index.umd.min-drpc57vn.js → index.umd.min-fqefd9kn.js} +3 -3
  31. package/dist/input-reader-xb9vecxv.js +11 -0
  32. package/dist/{ja-FGEGLBJ3-w9byjhze.js → ja-BI5K3JDZ-77zat4z2.js} +857 -845
  33. package/dist/{ja-DPO5PPLO-fmbg7zt2.js → ja-DPO5PPLO-mysfmznx.js} +54 -54
  34. package/dist/{js-yaml-cggj6w7q.js → js-yaml-87cdx6bm.js} +27 -19
  35. package/dist/known-types-qryebm95.js +15 -0
  36. package/dist/{ko-ITOPNIYI-aqy82jk8.js → ko-ITOPNIYI-hmxd2asd.js} +54 -54
  37. package/dist/{ko-TUAK3G3A-s25w0ckg.js → ko-JOBF5V7N-4bv0mjje.js} +857 -845
  38. package/dist/{node-strategy-8gzp67xs.js → node-strategy-0267x5e5.js} +130 -14
  39. package/dist/node-sync-service-9a9ksj9s.js +38 -0
  40. package/dist/{packager-tool-9qecd4wb.js → packager-tool-0gctz400.js} +5 -2
  41. package/dist/packager-tool-0mj06yen.js +65 -0
  42. package/dist/{packager-tool-1cb0d5e0.js → packager-tool-0v3s8r01.js} +2 -2
  43. package/dist/packager-tool-134mvmcm.js +3040 -0
  44. package/dist/{packager-tool-wckvcay0.js → packager-tool-1yh8g550.js} +9 -7
  45. package/dist/{packager-tool-zqa5k9f7.js → packager-tool-37zvccmt.js} +990 -2287
  46. package/dist/packager-tool-3ze5vt52.js +54 -0
  47. package/dist/{packager-tool-w3h8xrnv.js → packager-tool-56j6keqr.js} +71 -3
  48. package/dist/{packager-tool-3wygxefb.js → packager-tool-58q3tvh7.js} +10 -10
  49. package/dist/{packager-tool-zx48pq4v.js → packager-tool-5ax2ywcg.js} +1997 -1174
  50. package/dist/{packager-tool-we1phz71.js → packager-tool-885mmrvr.js} +31 -3
  51. package/dist/packager-tool-9scn4b15.js +852 -0
  52. package/dist/{packager-tool-p9j43p8h.js → packager-tool-a42jnpy5.js} +3 -9
  53. package/dist/packager-tool-ajvse9r3.js +356 -0
  54. package/dist/{packager-tool-jysvpt8p.js → packager-tool-c23zrhj8.js} +2 -2
  55. package/dist/packager-tool-dqs5qy9s.js +2327 -0
  56. package/dist/packager-tool-ee5dhff3.js +6717 -0
  57. package/dist/{packager-tool-wvqz81mx.js → packager-tool-gtzs471w.js} +3 -2
  58. package/dist/packager-tool-hrr0efqc.js +546 -0
  59. package/dist/packager-tool-j9rfdrdm.js +1125 -0
  60. package/dist/{packager-tool-gq6952nc.js → packager-tool-jhdf8gt1.js} +5054 -17851
  61. package/dist/packager-tool-mp59jtpm.js +6865 -0
  62. package/dist/packager-tool-njzcfve1.js +77 -0
  63. package/dist/packager-tool-p7jgrm5r.js +15 -0
  64. package/dist/packager-tool-r84ng21s.js +57 -0
  65. package/dist/packager-tool-rqvr63x5.js +1217 -0
  66. package/dist/packager-tool-s12392rd.js +80 -0
  67. package/dist/packager-tool-sv0d6wb6.js +173 -0
  68. package/dist/packager-tool-ty1t2byf.js +27 -0
  69. package/dist/packager-tool-vepqrsse.js +23 -0
  70. package/dist/packager-tool-w5ek334f.js +4892 -0
  71. package/dist/{packager-tool-5arsyj36.js → packager-tool-yc4kw997.js} +4 -2
  72. package/dist/packager-tool.js +91 -5
  73. package/dist/project-artifacts-vhanbtw5.js +14 -0
  74. package/dist/{pt-BR-7XGDXRDJ-espnkgrj.js → pt-BR-7DYX2YPT-fqxqzqtf.js} +857 -845
  75. package/dist/{pt-BR-BXURWX4W-xzyndmrx.js → pt-BR-BXURWX4W-bwfcwhk1.js} +54 -54
  76. package/dist/{pt-TMVOOITK-myha14p9.js → pt-HTXGGX6Y-97t21dty.js} +857 -845
  77. package/dist/{pt-YI4VE4YQ-521681zf.js → pt-YI4VE4YQ-wdkn2dcf.js} +54 -54
  78. package/dist/resourcesSyncService-mrmmwaqr.js +683 -0
  79. package/dist/{ro-2VALF3S5-cdz5afkr.js → ro-KTNQ3MNU-y08n1x5g.js} +857 -845
  80. package/dist/{ro-RKXZUG7Z-pdztdafr.js → ro-RKXZUG7Z-nndrrsq7.js} +54 -54
  81. package/dist/{ru-GSCT4ARZ-qj8dm4dp.js → ru-GSCT4ARZ-1sa9wbr8.js} +1 -1
  82. package/dist/ru-WBLQ5B2U-8r3c7v6d.js +10 -0
  83. package/dist/strict-case-rules-303vjvas.js +377 -0
  84. package/dist/strict-sdd-audit-qdmc9e1y.js +1024 -0
  85. package/dist/tool.js +17 -18
  86. package/dist/{tr-AA6O2WSR-bj9n80k8.js → tr-AA6O2WSR-86ba4bdf.js} +54 -54
  87. package/dist/{tr-RIFCEXFH-hgkb4g8y.js → tr-XHSSPNK7-cmqyc4wd.js} +857 -845
  88. package/dist/trigger-enrichment-service-zdx4x92j.js +340 -0
  89. package/dist/{zh-CN-IP3FMXWM-1cfarhcp.js → zh-CN-2EHQT23P-mr63c4xz.js} +857 -845
  90. package/dist/{zh-CN-R2KLHXQV-x6gnk2n0.js → zh-CN-R2KLHXQV-agqr45ds.js} +54 -54
  91. package/dist/{zh-TW-AGIDXIPF-n6r6w7vy.js → zh-TW-MGZCE5BT-c4ekmrz9.js} +857 -845
  92. package/dist/{zh-TW-RJGCQANM-tt8j5wv2.js → zh-TW-RJGCQANM-w0x3qc1p.js} +54 -54
  93. package/package.json +2 -2
  94. package/dist/index-8bsngk9y.js +0 -247140
  95. package/dist/packager-tool-axcdppp9.js +0 -13607
  96. package/dist/ru-WBLQ5B2U-8xd4gpv2.js +0 -10
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  getFileSystem
3
- } from "./packager-tool-1cb0d5e0.js";
3
+ } from "./packager-tool-0v3s8r01.js";
4
4
  import {
5
5
  __commonJS,
6
6
  __require,
7
7
  __toESM
8
- } from "./packager-tool-wckvcay0.js";
8
+ } from "./packager-tool-1yh8g550.js";
9
9
 
10
10
  // ../../node_modules/commander/lib/error.js
11
- var require_error = __commonJS((exports) => {
11
+ var require_error = __commonJS(function(exports) {
12
12
  class CommanderError extends Error {
13
13
  constructor(exitCode, code, message) {
14
14
  super(message);
@@ -32,7 +32,7 @@ var require_error = __commonJS((exports) => {
32
32
  });
33
33
 
34
34
  // ../../node_modules/commander/lib/argument.js
35
- var require_argument = __commonJS((exports) => {
35
+ var require_argument = __commonJS(function(exports) {
36
36
  var { InvalidArgumentError } = require_error();
37
37
 
38
38
  class Argument {
@@ -112,7 +112,7 @@ var require_argument = __commonJS((exports) => {
112
112
  });
113
113
 
114
114
  // ../../node_modules/commander/lib/help.js
115
- var require_help = __commonJS((exports) => {
115
+ var require_help = __commonJS(function(exports) {
116
116
  var { humanReadableArgName } = require_argument();
117
117
 
118
118
  class Help {
@@ -469,7 +469,7 @@ ${itemIndentStr}`);
469
469
  });
470
470
 
471
471
  // ../../node_modules/commander/lib/option.js
472
- var require_option = __commonJS((exports) => {
472
+ var require_option = __commonJS(function(exports) {
473
473
  var { InvalidArgumentError } = require_error();
474
474
 
475
475
  class Option {
@@ -653,7 +653,7 @@ var require_option = __commonJS((exports) => {
653
653
  });
654
654
 
655
655
  // ../../node_modules/commander/lib/suggestSimilar.js
656
- var require_suggestSimilar = __commonJS((exports) => {
656
+ var require_suggestSimilar = __commonJS(function(exports) {
657
657
  var maxDistance = 3;
658
658
  function editDistance(a, b) {
659
659
  if (Math.abs(a.length - b.length) > maxDistance)
@@ -726,7 +726,7 @@ var require_suggestSimilar = __commonJS((exports) => {
726
726
  });
727
727
 
728
728
  // ../../node_modules/commander/lib/command.js
729
- var require_command = __commonJS((exports) => {
729
+ var require_command = __commonJS(function(exports) {
730
730
  var EventEmitter = __require("node:events").EventEmitter;
731
731
  var childProcess = __require("node:child_process");
732
732
  var path = __require("node:path");
@@ -2081,7 +2081,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2081
2081
  });
2082
2082
 
2083
2083
  // ../../node_modules/commander/index.js
2084
- var require_commander = __commonJS((exports) => {
2084
+ var require_commander = __commonJS(function(exports) {
2085
2085
  var { Argument } = require_argument();
2086
2086
  var { Command } = require_command();
2087
2087
  var { CommanderError, InvalidArgumentError } = require_error();
@@ -2100,49 +2100,171 @@ var require_commander = __commonJS((exports) => {
2100
2100
  exports.InvalidOptionArgumentError = InvalidArgumentError;
2101
2101
  });
2102
2102
 
2103
- // ../common/src/catch-error.ts
2104
- function isPromiseLike(value) {
2105
- return value !== null && typeof value === "object" && typeof value.then === "function";
2106
- }
2107
- function catchError(fnOrPromise) {
2108
- if (isPromiseLike(fnOrPromise)) {
2109
- return settlePromiseLike(fnOrPromise);
2103
+ // ../common/src/telemetry/pseudonymize.ts
2104
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2105
+ var PSEUDONYM_HEX_LENGTH = 32;
2106
+ var SHA256_K = new Uint32Array([
2107
+ 1116352408,
2108
+ 1899447441,
2109
+ 3049323471,
2110
+ 3921009573,
2111
+ 961987163,
2112
+ 1508970993,
2113
+ 2453635748,
2114
+ 2870763221,
2115
+ 3624381080,
2116
+ 310598401,
2117
+ 607225278,
2118
+ 1426881987,
2119
+ 1925078388,
2120
+ 2162078206,
2121
+ 2614888103,
2122
+ 3248222580,
2123
+ 3835390401,
2124
+ 4022224774,
2125
+ 264347078,
2126
+ 604807628,
2127
+ 770255983,
2128
+ 1249150122,
2129
+ 1555081692,
2130
+ 1996064986,
2131
+ 2554220882,
2132
+ 2821834349,
2133
+ 2952996808,
2134
+ 3210313671,
2135
+ 3336571891,
2136
+ 3584528711,
2137
+ 113926993,
2138
+ 338241895,
2139
+ 666307205,
2140
+ 773529912,
2141
+ 1294757372,
2142
+ 1396182291,
2143
+ 1695183700,
2144
+ 1986661051,
2145
+ 2177026350,
2146
+ 2456956037,
2147
+ 2730485921,
2148
+ 2820302411,
2149
+ 3259730800,
2150
+ 3345764771,
2151
+ 3516065817,
2152
+ 3600352804,
2153
+ 4094571909,
2154
+ 275423344,
2155
+ 430227734,
2156
+ 506948616,
2157
+ 659060556,
2158
+ 883997877,
2159
+ 958139571,
2160
+ 1322822218,
2161
+ 1537002063,
2162
+ 1747873779,
2163
+ 1955562222,
2164
+ 2024104815,
2165
+ 2227730452,
2166
+ 2361852424,
2167
+ 2428436474,
2168
+ 2756734187,
2169
+ 3204031479,
2170
+ 3329325298
2171
+ ]);
2172
+ var SHA256_INITIAL_STATE = new Uint32Array([
2173
+ 1779033703,
2174
+ 3144134277,
2175
+ 1013904242,
2176
+ 2773480762,
2177
+ 1359893119,
2178
+ 2600822924,
2179
+ 528734635,
2180
+ 1541459225
2181
+ ]);
2182
+ function rotr(value, bits) {
2183
+ return (value >>> bits | value << 32 - bits) >>> 0;
2184
+ }
2185
+ function sha256Hex(input) {
2186
+ const bytes = new TextEncoder().encode(input);
2187
+ const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
2188
+ const buffer = new Uint8Array(paddedLength);
2189
+ buffer.set(bytes);
2190
+ buffer[bytes.length] = 128;
2191
+ const view = new DataView(buffer.buffer);
2192
+ const bitLength = bytes.length * 8;
2193
+ view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
2194
+ view.setUint32(paddedLength - 4, bitLength >>> 0);
2195
+ const state = SHA256_INITIAL_STATE.slice();
2196
+ const schedule = new Uint32Array(64);
2197
+ for (let offset = 0;offset < paddedLength; offset += 64) {
2198
+ for (let i = 0;i < 16; i++) {
2199
+ schedule[i] = view.getUint32(offset + i * 4);
2200
+ }
2201
+ for (let i = 16;i < 64; i++) {
2202
+ const x = schedule[i - 15];
2203
+ const y = schedule[i - 2];
2204
+ const s0 = (rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3) >>> 0;
2205
+ const s1 = (rotr(y, 17) ^ rotr(y, 19) ^ y >>> 10) >>> 0;
2206
+ schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1 >>> 0;
2207
+ }
2208
+ let a = state[0];
2209
+ let b = state[1];
2210
+ let c = state[2];
2211
+ let d = state[3];
2212
+ let e = state[4];
2213
+ let f = state[5];
2214
+ let g = state[6];
2215
+ let h = state[7];
2216
+ for (let i = 0;i < 64; i++) {
2217
+ const s1 = (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) >>> 0;
2218
+ const ch = (e & f ^ ~e & g) >>> 0;
2219
+ const temp1 = h + s1 + ch + SHA256_K[i] + schedule[i] >>> 0;
2220
+ const s0 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) >>> 0;
2221
+ const maj = (a & b ^ a & c ^ b & c) >>> 0;
2222
+ const temp2 = s0 + maj >>> 0;
2223
+ h = g;
2224
+ g = f;
2225
+ f = e;
2226
+ e = d + temp1 >>> 0;
2227
+ d = c;
2228
+ c = b;
2229
+ b = a;
2230
+ a = temp1 + temp2 >>> 0;
2231
+ }
2232
+ state[0] = state[0] + a >>> 0;
2233
+ state[1] = state[1] + b >>> 0;
2234
+ state[2] = state[2] + c >>> 0;
2235
+ state[3] = state[3] + d >>> 0;
2236
+ state[4] = state[4] + e >>> 0;
2237
+ state[5] = state[5] + f >>> 0;
2238
+ state[6] = state[6] + g >>> 0;
2239
+ state[7] = state[7] + h >>> 0;
2240
+ }
2241
+ let hex = "";
2242
+ for (const word of state) {
2243
+ hex += word.toString(16).padStart(8, "0");
2110
2244
  }
2245
+ return hex;
2246
+ }
2247
+ function resolveSha256Hex() {
2111
2248
  try {
2112
- const result = fnOrPromise();
2113
- if (isPromiseLike(result)) {
2114
- return settlePromiseLike(result);
2249
+ const nodeCrypto = __require("node:crypto");
2250
+ const createHash = nodeCrypto?.createHash;
2251
+ if (typeof createHash !== "function") {
2252
+ return sha256Hex;
2115
2253
  }
2116
- return [undefined, result];
2117
- } catch (error) {
2118
- return [
2119
- error instanceof Error ? error : new Error(String(error)),
2120
- undefined
2121
- ];
2254
+ const native = (input) => createHash("sha256").update(input, "utf8").digest("hex");
2255
+ return native("abc") === sha256Hex("abc") ? native : sha256Hex;
2256
+ } catch {
2257
+ return sha256Hex;
2122
2258
  }
2123
2259
  }
2124
- function settlePromiseLike(thenable) {
2125
- return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
2126
- error instanceof Error ? error : new Error(String(error)),
2127
- undefined
2128
- ]);
2260
+ var cachedSha256Hex;
2261
+ function digest(input) {
2262
+ cachedSha256Hex ??= resolveSha256Hex();
2263
+ return cachedSha256Hex(input);
2264
+ }
2265
+ function pseudonymize(input) {
2266
+ return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
2129
2267
  }
2130
-
2131
- // ../../node_modules/commander/esm.mjs
2132
- var import__ = __toESM(require_commander(), 1);
2133
- var {
2134
- program,
2135
- createCommand,
2136
- createArgument,
2137
- createOption,
2138
- CommanderError,
2139
- InvalidArgumentError,
2140
- InvalidOptionArgumentError,
2141
- Command,
2142
- Argument,
2143
- Option,
2144
- Help
2145
- } = import__.default;
2146
2268
 
2147
2269
  // ../common/src/singleton.ts
2148
2270
  var PREFIX = "@uipath/common/";
@@ -2174,17 +2296,343 @@ function singleton(ctorOrName) {
2174
2296
  };
2175
2297
  }
2176
2298
 
2177
- // ../common/src/preview.ts
2178
- var previewSlot = singleton("PreviewBuild");
2179
- function isPreviewBuild() {
2180
- return previewSlot.get(false) ?? false;
2299
+ // ../common/src/telemetry/supplied-values.ts
2300
+ var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
2301
+ function activeEntries() {
2302
+ const existing = suppliedValuesSlot.get();
2303
+ return Array.isArray(existing) ? existing : [];
2304
+ }
2305
+ var MIN_SCRUBBABLE_LENGTH = 4;
2306
+ function recordSuppliedArgumentValues(values) {
2307
+ const flat = [];
2308
+ const push = (value) => {
2309
+ if (Array.isArray(value)) {
2310
+ for (const item of value) {
2311
+ push(item);
2312
+ }
2313
+ return;
2314
+ }
2315
+ if (typeof value === "string" && value.length >= MIN_SCRUBBABLE_LENGTH) {
2316
+ flat.push(value);
2317
+ }
2318
+ };
2319
+ push(values);
2320
+ const entry = { values: flat };
2321
+ suppliedValuesSlot.set([...activeEntries(), entry]);
2322
+ return entry;
2181
2323
  }
2182
- Command.prototype.previewCommand = function(nameAndArgs, opts) {
2183
- if (isPreviewBuild()) {
2184
- return this.command(nameAndArgs, opts);
2324
+ function releaseSuppliedArgumentValues(entry) {
2325
+ suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
2326
+ }
2327
+ function getSuppliedArgumentValues() {
2328
+ const all = new Set;
2329
+ for (const entry of activeEntries()) {
2330
+ for (const value of entry.values) {
2331
+ all.add(value);
2332
+ }
2185
2333
  }
2186
- return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
2187
- };
2334
+ return [...all].sort((a, b) => b.length - a.length);
2335
+ }
2336
+
2337
+ // ../common/src/telemetry/pii-redactor.ts
2338
+ var REDACTED = "[REDACTED]";
2339
+ var MAX_VALUE_LENGTH = 280;
2340
+ var MAX_STACK_LENGTH = 4096;
2341
+ var MAX_SCAN_LENGTH = MAX_STACK_LENGTH;
2342
+ function truncate(value, maxLength) {
2343
+ return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;
2344
+ }
2345
+ var SENSITIVE_NAME_TOKENS = new Set([
2346
+ "token",
2347
+ "tokens",
2348
+ "secret",
2349
+ "secrets",
2350
+ "password",
2351
+ "passwords",
2352
+ "pwd",
2353
+ "credential",
2354
+ "credentials",
2355
+ "auth",
2356
+ "authentication",
2357
+ "authorization",
2358
+ "authority",
2359
+ "cert",
2360
+ "certificate",
2361
+ "certificates"
2362
+ ]);
2363
+ var SENSITIVE_KEY_PREFIXES = new Set([
2364
+ "api",
2365
+ "access",
2366
+ "client",
2367
+ "private",
2368
+ "public",
2369
+ "signing",
2370
+ "encryption",
2371
+ "session",
2372
+ "master",
2373
+ "shared",
2374
+ "root",
2375
+ "ssh",
2376
+ "rsa",
2377
+ "aes",
2378
+ "hmac",
2379
+ "oauth"
2380
+ ]);
2381
+ 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;
2382
+ var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
2383
+ var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
2384
+ var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
2385
+ var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
2386
+ var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
2387
+ var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
2388
+ var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
2389
+ 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;
2390
+ var SOURCE_FILE_EXTENSIONS = new Set([
2391
+ "ts",
2392
+ "tsx",
2393
+ "js",
2394
+ "jsx",
2395
+ "mjs",
2396
+ "cjs",
2397
+ "cts",
2398
+ "mts",
2399
+ "py",
2400
+ "cs",
2401
+ "java",
2402
+ "go",
2403
+ "rs",
2404
+ "rb",
2405
+ "php",
2406
+ "sh",
2407
+ "ps1",
2408
+ "json",
2409
+ "jsonc",
2410
+ "yaml",
2411
+ "yml",
2412
+ "xml",
2413
+ "xaml",
2414
+ "md",
2415
+ "txt",
2416
+ "log",
2417
+ "css",
2418
+ "html",
2419
+ "htm",
2420
+ "csproj",
2421
+ "nuspec",
2422
+ "sql"
2423
+ ]);
2424
+ var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
2425
+ var QUOTED_LITERAL_MAX_SPAN = 200;
2426
+ var QUOTED_LITERAL_PATTERN = new RegExp([
2427
+ `(?<![A-Za-z0-9])'(?:[^\\
2428
+ ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
2429
+ `(?<![A-Za-z0-9])"(?:[^\\
2430
+ ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
2431
+ ].join("|"), "g");
2432
+ var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
2433
+ var COLLAPSED_BODY = "{…}";
2434
+ var COLLAPSED_BODY_MARKER = "\x01body\x01";
2435
+ var MAX_BODY_NESTING = 8;
2436
+ function collapseJsonBodies(text) {
2437
+ let out = text;
2438
+ for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
2439
+ const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
2440
+ if (next === out) {
2441
+ break;
2442
+ }
2443
+ out = next;
2444
+ }
2445
+ return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
2446
+ }
2447
+ var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
2448
+ function peelTrailingPunctuation(match) {
2449
+ const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
2450
+ return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
2451
+ }
2452
+ function redactUrl(raw) {
2453
+ try {
2454
+ const url = new URL(raw);
2455
+ return `${url.protocol}//${url.host}`;
2456
+ } catch {
2457
+ return `url#${pseudonymize(raw)}`;
2458
+ }
2459
+ }
2460
+ function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
2461
+ let out = truncate(value, MAX_SCAN_LENGTH);
2462
+ out = out.replace(JWT_PATTERN, () => REDACTED);
2463
+ out = out.replace(URL_PATTERN, (match) => {
2464
+ const [core, trailing] = peelTrailingPunctuation(match);
2465
+ return `${redactUrl(core)}${trailing}`;
2466
+ });
2467
+ out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
2468
+ out = out.replace(UNC_PATH_PATTERN, (_match, before, path) => {
2469
+ const [core, trailing] = peelTrailingPunctuation(path);
2470
+ return `${before}unc#${pseudonymize(core)}${trailing}`;
2471
+ });
2472
+ out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
2473
+ out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
2474
+ out = out.replace(HOST_PORT_PATTERN, (match) => {
2475
+ const split = match.lastIndexOf(":");
2476
+ const host = match.slice(0, split);
2477
+ const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
2478
+ if (SOURCE_FILE_EXTENSIONS.has(extension)) {
2479
+ return match;
2480
+ }
2481
+ return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
2482
+ });
2483
+ out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
2484
+ out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
2485
+ out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
2486
+ return truncate(out, maxLength);
2487
+ }
2488
+ function redactSpanName(name) {
2489
+ return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
2490
+ }
2491
+ var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
2492
+ function redactHttpDependencyName(name) {
2493
+ const parts = HTTP_DEPENDENCY_NAME.exec(name);
2494
+ if (!parts) {
2495
+ return redactMessage(name);
2496
+ }
2497
+ return `${parts[1]} ${redactMessage(parts[2])}`;
2498
+ }
2499
+ function redactMessage(value) {
2500
+ let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
2501
+ for (const supplied of getSuppliedArgumentValues()) {
2502
+ out = out.split(supplied).join(REDACTED);
2503
+ }
2504
+ return redactValueDetectors(out);
2505
+ }
2506
+ var MESSAGE_NAMES = new Set([
2507
+ "message",
2508
+ "errormessage",
2509
+ "errmessage",
2510
+ "error_message",
2511
+ "msg",
2512
+ "detail",
2513
+ "details",
2514
+ "reason",
2515
+ "instructions",
2516
+ "warning"
2517
+ ]);
2518
+ function isFreeFormValue(name, value) {
2519
+ return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
2520
+ }
2521
+ function redactError(error) {
2522
+ const safe = new Error(redactMessage(error.message ?? ""));
2523
+ safe.name = error.name;
2524
+ safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
2525
+ return safe;
2526
+ }
2527
+ function redactStack(stack) {
2528
+ const bounded = truncate(stack, MAX_STACK_LENGTH);
2529
+ const firstBreak = bounded.indexOf(`
2530
+ `);
2531
+ if (firstBreak === -1) {
2532
+ return redactMessage(bounded);
2533
+ }
2534
+ return `${redactMessage(bounded.slice(0, firstBreak))}
2535
+ ${redactValueDetectors(bounded.slice(firstBreak + 1), MAX_STACK_LENGTH)}`;
2536
+ }
2537
+ function nameTokens(name) {
2538
+ 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);
2539
+ }
2540
+ function isSensitiveName(name) {
2541
+ const tokens = nameTokens(name);
2542
+ for (let i = 0;i < tokens.length; i++) {
2543
+ const token = tokens[i];
2544
+ if (SENSITIVE_NAME_TOKENS.has(token)) {
2545
+ return true;
2546
+ }
2547
+ if (token === "key" || token === "keys") {
2548
+ const prev = tokens[i - 1];
2549
+ if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
2550
+ return true;
2551
+ }
2552
+ }
2553
+ }
2554
+ return false;
2555
+ }
2556
+ function redactProperty(name, value) {
2557
+ if (value === undefined || value === null) {
2558
+ return;
2559
+ }
2560
+ if (isSensitiveName(name)) {
2561
+ return REDACTED;
2562
+ }
2563
+ if (typeof value === "boolean" || typeof value === "number") {
2564
+ return value;
2565
+ }
2566
+ if (typeof value !== "string") {
2567
+ return "[OBJECT]";
2568
+ }
2569
+ return isFreeFormValue(name, value) ? redactMessage(value) : redactValueDetectors(value);
2570
+ }
2571
+ function redactProperties(properties) {
2572
+ const out = {};
2573
+ for (const [name, value] of Object.entries(properties)) {
2574
+ const redacted = redactProperty(name, value);
2575
+ if (redacted !== undefined) {
2576
+ out[name] = redacted;
2577
+ }
2578
+ }
2579
+ return out;
2580
+ }
2581
+
2582
+ // ../common/src/catch-error.ts
2583
+ var MAX_SERIALIZED_LENGTH = 500;
2584
+ var TRUNCATION_SUFFIX = "…(truncated)";
2585
+ var REDACTED2 = "[REDACTED]";
2586
+ function cap(text) {
2587
+ return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
2588
+ }
2589
+ function omitSensitive(key, value) {
2590
+ return key.length > 0 && isSensitiveName(key) ? REDACTED2 : value;
2591
+ }
2592
+ function describeThrownValue(value) {
2593
+ if (typeof value !== "object" || value === null) {
2594
+ return String(value);
2595
+ }
2596
+ let message;
2597
+ try {
2598
+ message = value.message;
2599
+ } catch {
2600
+ message = undefined;
2601
+ }
2602
+ if (typeof message === "string" && message.length > 0) {
2603
+ return cap(message);
2604
+ }
2605
+ try {
2606
+ const json = JSON.stringify(value, omitSensitive);
2607
+ if (json !== undefined) {
2608
+ return cap(json);
2609
+ }
2610
+ } catch {}
2611
+ return String(value);
2612
+ }
2613
+ function toError(error) {
2614
+ return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
2615
+ }
2616
+ function isPromiseLike(value) {
2617
+ return value !== null && typeof value === "object" && typeof value.then === "function";
2618
+ }
2619
+ function catchError(fnOrPromise) {
2620
+ if (isPromiseLike(fnOrPromise)) {
2621
+ return settlePromiseLike(fnOrPromise);
2622
+ }
2623
+ try {
2624
+ const result = fnOrPromise();
2625
+ if (isPromiseLike(result)) {
2626
+ return settlePromiseLike(result);
2627
+ }
2628
+ return [undefined, result];
2629
+ } catch (error) {
2630
+ return [toError(error), undefined];
2631
+ }
2632
+ }
2633
+ function settlePromiseLike(thenable) {
2634
+ return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
2635
+ }
2188
2636
 
2189
2637
  // ../common/src/output-context.ts
2190
2638
  function createStorage() {
@@ -2297,45 +2745,40 @@ class SimpleLogger {
2297
2745
  this.pendingInit
2298
2746
  ]).then(() => getFileSystem().appendFile(path, `${timestamp} ${formatted}`).catch(() => {}));
2299
2747
  }
2300
- debug(message, ...args) {
2301
- if (this.level > 0 /* DEBUG */)
2302
- return;
2303
- const formatted = this.format(`[DEBUG] ${message}`, args);
2748
+ write(formatted) {
2304
2749
  if (this.isFileLoggingActive()) {
2305
2750
  this.writeToFile(formatted);
2306
2751
  } else {
2307
2752
  getOutputSink().writeErr(formatted);
2308
2753
  }
2309
2754
  }
2755
+ debug(message, ...args) {
2756
+ if (this.level > 0 /* DEBUG */)
2757
+ return;
2758
+ const formatted = this.format(`[DEBUG] ${message}`, args);
2759
+ this.write(formatted);
2760
+ }
2310
2761
  info(message, ...args) {
2311
2762
  if (this.level > 1 /* INFO */)
2312
2763
  return;
2313
2764
  const formatted = this.format(message, args);
2314
- if (this.isFileLoggingActive()) {
2315
- this.writeToFile(formatted);
2316
- } else {
2317
- getOutputSink().writeErr(formatted);
2318
- }
2765
+ this.write(formatted);
2319
2766
  }
2320
2767
  warn(message, ...args) {
2321
2768
  if (this.level > 2 /* WARN */)
2322
2769
  return;
2323
2770
  const formatted = this.format(`[WARN] ${message}`, args);
2324
- if (this.isFileLoggingActive()) {
2325
- this.writeToFile(formatted);
2326
- } else {
2327
- getOutputSink().writeErr(formatted);
2328
- }
2771
+ this.write(formatted);
2329
2772
  }
2330
2773
  error(message, ...args) {
2331
2774
  if (this.level > 3 /* ERROR */)
2332
2775
  return;
2333
2776
  const formatted = this.format(`[ERROR] ${message}`, args);
2334
- if (this.isFileLoggingActive()) {
2335
- this.writeToFile(formatted);
2336
- } else {
2337
- getOutputSink().writeErr(formatted);
2338
- }
2777
+ this.write(formatted);
2778
+ }
2779
+ report(message) {
2780
+ const formatted = this.format(message, []);
2781
+ this.write(formatted);
2339
2782
  }
2340
2783
  getLevel() {
2341
2784
  return this.level;
@@ -2408,51 +2851,76 @@ function getLogFilePath() {
2408
2851
  return logger.getLogFilePath();
2409
2852
  }
2410
2853
 
2411
- // ../common/src/package-metadata-options.ts
2412
- function registerPackageMetadataOptions(command) {
2413
- return command.option("--author <author>", "Package author").option("--description <text>", "Package description").option("--repository-url <url>", "Source repository URL (recorded in the package for traceability)").option("--repository-commit <sha>", "Source repository commit hash (recorded in the package for traceability)").option("--repository-branch <branch>", "Source repository branch").option("--repository-type <type>", "Source repository type (defaults to 'git' when --repository-url is set)").option("--release-notes <text>", "Release notes for the package").option("--project-url <url>", "Automation Hub idea URL");
2414
- }
2415
- function mapPackageMetadataOptions(opts) {
2416
- const fields = {};
2417
- if (opts.author !== undefined)
2418
- fields.author = opts.author;
2419
- if (opts.description !== undefined)
2420
- fields.description = opts.description;
2421
- if (opts.releaseNotes !== undefined)
2422
- fields.releaseNotes = opts.releaseNotes;
2423
- if (opts.projectUrl !== undefined)
2424
- fields.projectUrl = opts.projectUrl;
2425
- if (opts.repositoryUrl !== undefined)
2426
- fields.repositoryUrl = opts.repositoryUrl;
2427
- if (opts.repositoryCommit !== undefined)
2428
- fields.repositoryCommit = opts.repositoryCommit;
2429
- if (opts.repositoryBranch !== undefined)
2430
- fields.repositoryBranch = opts.repositoryBranch;
2431
- if (opts.repositoryType !== undefined)
2432
- fields.repositoryType = opts.repositoryType;
2433
- if (fields.repositoryUrl !== undefined && fields.repositoryType === undefined) {
2434
- fields.repositoryType = "git";
2435
- }
2436
- return fields;
2854
+ // ../common/src/exit-code.ts
2855
+ function setExitCode(code) {
2856
+ process.exitCode = code;
2437
2857
  }
2438
2858
 
2439
- // ../common/src/error-handler.ts
2440
- var DEFAULT_401 = "Unauthorized (401). Run `uip login` to authenticate.";
2441
- var DEFAULT_403 = "Forbidden (403). Ensure the account has the required permissions.";
2442
- var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
2443
- var DEFAULT_413 = "Payload too large (413). The upload exceeded the server or CDN size limit. Reduce the package size — for example, exclude unused dependencies or remove large files from the project — and try again.";
2444
- var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
2445
- var NETWORK_ERROR_CODES = new Set([
2859
+ // ../common/src/output-codecs.ts
2860
+ var yamlSlot = singleton("YamlCodec");
2861
+ var jmespathSlot = singleton("JmespathCodec");
2862
+ async function loadOutputCodecsAsync(needed) {
2863
+ const loads = [];
2864
+ if (needed.yaml && yamlSlot.get() === undefined) {
2865
+ loads.push(import("./js-yaml-87cdx6bm.js").then((mod) => {
2866
+ yamlSlot.set(mod);
2867
+ }));
2868
+ }
2869
+ if (needed.filter && jmespathSlot.get() === undefined) {
2870
+ loads.push(import("./index-p3vk57z7.js").then((mod) => {
2871
+ jmespathSlot.set(mod);
2872
+ }));
2873
+ }
2874
+ await Promise.all(loads);
2875
+ }
2876
+ function getYamlCodec() {
2877
+ return yamlSlot.get();
2878
+ }
2879
+ function getJmespathCodec() {
2880
+ return jmespathSlot.get();
2881
+ }
2882
+
2883
+ // ../common/src/output-format-context.ts
2884
+ var formatSlot = singleton("OutputFormat");
2885
+ var formatExplicitSlot = singleton("OutputFormatExplicit");
2886
+ var helpRequestedSlot = singleton("HelpRequested");
2887
+ var filterSlot = singleton("OutputFilter");
2888
+ function getOutputFormat() {
2889
+ return formatSlot.get("json");
2890
+ }
2891
+ function getOutputFormatExplicit() {
2892
+ return formatExplicitSlot.get(false) ?? false;
2893
+ }
2894
+ function getOutputFilter() {
2895
+ return filterSlot.get();
2896
+ }
2897
+
2898
+ // ../common/src/telemetry/command-terminal.ts
2899
+ var recordedFailureSlot = singleton("CommandTelemetryFailure");
2900
+ var AUTH_ERROR_CODES = new Set([
2901
+ "authentication_required",
2902
+ "permission_denied"
2903
+ ]);
2904
+ var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
2905
+ var NETWORK_HTTP_ERROR_CODES = new Set([
2906
+ "network_error",
2907
+ "rate_limited",
2908
+ "server_error",
2909
+ "not_found",
2910
+ "method_not_allowed"
2911
+ ]);
2912
+ var TIMEOUT_ERROR_CODES = new Set(["timeout"]);
2913
+ var NETWORK_OS_ERROR_CODES = new Set([
2446
2914
  "ECONNREFUSED",
2447
2915
  "ECONNRESET",
2448
2916
  "ENOTFOUND",
2449
2917
  "EAI_AGAIN",
2450
- "ETIMEDOUT",
2451
2918
  "EPIPE",
2452
2919
  "EHOSTUNREACH",
2453
2920
  "ENETUNREACH",
2454
2921
  "EAI_FAIL"
2455
2922
  ]);
2923
+ var TIMEOUT_OS_ERROR_CODES = new Set(["ETIMEDOUT", "ESOCKETTIMEDOUT"]);
2456
2924
  var TLS_ERROR_CODES = new Set([
2457
2925
  "SELF_SIGNED_CERT_IN_CHAIN",
2458
2926
  "DEPTH_ZERO_SELF_SIGNED_CERT",
@@ -2463,544 +2931,112 @@ var TLS_ERROR_CODES = new Set([
2463
2931
  "CERT_UNTRUSTED",
2464
2932
  "ERR_TLS_CERT_ALTNAME_INVALID"
2465
2933
  ]);
2466
- var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
2467
- var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
2468
- var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
2469
- var LOCAL_PERMISSION_MESSAGE_PATTERN = /\b(EACCES|EPERM|EROFS)\b/;
2470
- function localPermissionInstructions(code, path) {
2471
- const target = path !== undefined ? `'${path}'` : "a local file or resource";
2472
- if (code === "EROFS") {
2473
- return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
2474
- }
2475
- const remedy = process.platform === "win32" ? "Re-run from an elevated terminal, close any program holding " + "the file open, or grant your user access to the path." : "Grant this user (or the sandbox the command runs in) access " + "to the path, or run the command outside the sandbox.";
2476
- return `The operating system denied access to ${target} (${code}). This is ` + "a local permission problem, not a UiPath service error — retrying " + `without a permission change will not help. ${remedy}`;
2477
- }
2478
- function describeConnectivityError(error) {
2479
- for (const cur of walkErrorGraph(error)) {
2480
- const code = typeof cur.code === "string" ? cur.code : undefined;
2481
- const message = typeof cur.message === "string" ? cur.message : undefined;
2482
- if (code && TLS_ERROR_CODES.has(code)) {
2483
- return {
2484
- code,
2485
- kind: "tls",
2486
- message: message ?? code,
2487
- instructions: TLS_INSTRUCTIONS
2488
- };
2489
- }
2490
- if (code && NETWORK_ERROR_CODES.has(code)) {
2491
- return {
2492
- code,
2493
- kind: "network",
2494
- message: message ?? code,
2495
- instructions: NETWORK_INSTRUCTIONS
2496
- };
2497
- }
2498
- }
2499
- return;
2934
+ var MISSING_DEPENDENCY_CODES = new Set([
2935
+ "MODULE_NOT_FOUND",
2936
+ "ERR_MODULE_NOT_FOUND"
2937
+ ]);
2938
+ var INTERNAL_ERROR_NAMES = new Set([
2939
+ "TypeError",
2940
+ "ReferenceError",
2941
+ "SyntaxError",
2942
+ "RangeError"
2943
+ ]);
2944
+ function isRecord(value) {
2945
+ return value !== null && typeof value === "object";
2500
2946
  }
2501
- function describePermissionError(error) {
2502
- for (const cur of walkErrorGraph(error)) {
2503
- const message = typeof cur.message === "string" ? cur.message : undefined;
2504
- const code = matchLocalPermissionCode(cur.code, message);
2505
- if (!code)
2506
- continue;
2507
- const path = localPermissionPath(cur.path, message);
2508
- return {
2509
- code,
2510
- message: message ?? code,
2511
- ...path !== undefined ? { path } : {},
2512
- instructions: localPermissionInstructions(code, path)
2513
- };
2947
+ function stringField(value, field) {
2948
+ if (!isRecord(value)) {
2949
+ return;
2514
2950
  }
2515
- return;
2951
+ const raw = value[field];
2952
+ return typeof raw === "string" ? raw : undefined;
2516
2953
  }
2517
- function matchLocalPermissionCode(code, message) {
2518
- if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
2519
- return code;
2954
+ function numberField(value, field) {
2955
+ if (!isRecord(value)) {
2956
+ return;
2520
2957
  }
2521
- const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
2522
- return match ? match[1] : undefined;
2523
- }
2524
- function localPermissionPath(path, message) {
2525
- if (typeof path === "string")
2526
- return path;
2527
- return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
2958
+ const raw = value[field];
2959
+ return typeof raw === "number" ? raw : undefined;
2528
2960
  }
2529
- function* walkErrorGraph(error) {
2530
- const queue = [error];
2531
- const seen = new Set;
2532
- for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
2533
- const current = queue.shift();
2534
- if (current === null || typeof current !== "object")
2535
- continue;
2536
- if (seen.has(current))
2537
- continue;
2538
- seen.add(current);
2539
- const cur = current;
2540
- yield cur;
2541
- if (cur.cause !== undefined)
2542
- queue.push(cur.cause);
2543
- if (Array.isArray(cur.errors))
2544
- queue.push(...cur.errors);
2961
+ function findStringInCauseChain(error, field) {
2962
+ let current = error;
2963
+ for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
2964
+ const value = stringField(current, field);
2965
+ if (value) {
2966
+ return value;
2967
+ }
2968
+ current = current.cause;
2545
2969
  }
2546
2970
  return;
2547
2971
  }
2548
- function parseHttpStatusFromMessage(message) {
2549
- const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
2550
- if (!match)
2551
- return;
2552
- const status = Number(match[1]);
2553
- return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
2972
+ function findCodeInCauseChain(error) {
2973
+ return findStringInCauseChain(error, "code");
2554
2974
  }
2555
- function isHtmlDocument(body) {
2556
- return /^\s*(<!doctype html|<html\b)/i.test(body);
2975
+ function isSpawnEnoent(error) {
2976
+ const code = findCodeInCauseChain(error);
2977
+ if (code !== "ENOENT") {
2978
+ return false;
2979
+ }
2980
+ const syscall = findStringInCauseChain(error, "syscall");
2981
+ return syscall?.startsWith("spawn") === true;
2557
2982
  }
2558
- function retryHintForRetryAfter(seconds) {
2559
- if (seconds <= 1) {
2560
- return "RetryAfter1Second";
2983
+ function isCancellationError(error, exitCode, pollSignal) {
2984
+ if (exitCode === 130) {
2985
+ return true;
2561
2986
  }
2562
- if (seconds <= 10) {
2563
- return "RetryAfter10Seconds";
2987
+ if (!isRecord(error)) {
2988
+ return false;
2564
2989
  }
2565
- if (seconds <= 30) {
2566
- return "RetryAfter30Seconds";
2990
+ if (numberField(error, "exitCode") === 130) {
2991
+ return true;
2567
2992
  }
2568
- return "RetryAfter60Seconds";
2569
- }
2570
- function classifyError(status, error) {
2571
- if (status === 400 || status === 409 || status === 422) {
2572
- return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
2993
+ const name = stringField(error, "name");
2994
+ if (name === "ExitPromptError") {
2995
+ return true;
2573
2996
  }
2574
- if (status === 401) {
2575
- return {
2576
- errorCode: "authentication_required",
2577
- retry: "RetryWillNotFix"
2578
- };
2997
+ if (name === "AbortError" && pollSignal?.aborted) {
2998
+ return true;
2579
2999
  }
2580
- if (status === 403) {
2581
- return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
3000
+ const message = stringField(error, "message");
3001
+ return message?.includes("SIGINT") === true;
3002
+ }
3003
+ function terminalSignalFor(input, outcome) {
3004
+ if (input.recordedFailure?.terminalSignal) {
3005
+ return input.recordedFailure.terminalSignal;
2582
3006
  }
2583
- if (status === 404) {
2584
- return { errorCode: "not_found", retry: "RetryWillNotFix" };
3007
+ const explicit = findStringInCauseChain(input.error, "terminalSignal") ?? findStringInCauseChain(input.error, "signal");
3008
+ if (explicit) {
3009
+ return explicit;
2585
3010
  }
2586
- if (status === 405) {
2587
- return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
3011
+ return outcome === "cancelled" ? "SIGINT" : undefined;
3012
+ }
3013
+ function classifyHttpStatus(status) {
3014
+ if (status === 401 || status === 403) {
3015
+ return "auth";
2588
3016
  }
2589
- if (status === 413) {
2590
- return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
3017
+ if (status === 400 || status === 409 || status === 422) {
3018
+ return "validation";
2591
3019
  }
2592
3020
  if (status === 408) {
2593
- return { errorCode: "timeout", retry: "RetryLater" };
3021
+ return "timeout";
2594
3022
  }
2595
- if (status === 429) {
2596
- return { errorCode: "rate_limited", retry: "RetryLater" };
3023
+ return "network_http";
3024
+ }
3025
+ function classifyFromResult(result) {
3026
+ switch (result) {
3027
+ case "AuthenticationError":
3028
+ return "auth";
3029
+ case "ValidationError":
3030
+ return "validation";
3031
+ case "TimeoutError":
3032
+ return "timeout";
3033
+ default:
3034
+ return;
2597
3035
  }
2598
- if (status !== undefined && status >= 500 && status < 600) {
2599
- return { errorCode: "server_error", retry: "RetryLater" };
2600
- }
2601
- if (status === undefined && describePermissionError(error)) {
2602
- return {
2603
- errorCode: "local_permission_denied",
2604
- retry: "RetryWillNotFix"
2605
- };
2606
- }
2607
- const connectivity = describeConnectivityError(error);
2608
- if (connectivity) {
2609
- return {
2610
- errorCode: "network_error",
2611
- retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
2612
- };
2613
- }
2614
- return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
2615
- }
2616
- function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
2617
- if (extractedMessage) {
2618
- return `HTTP ${status}: ${extractedMessage}`;
2619
- }
2620
- return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
2621
- }
2622
- async function extractErrorDetails(error, options) {
2623
- const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
2624
- const response = err.response;
2625
- const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
2626
- const explicitStatus = err.status ?? response?.status;
2627
- const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
2628
- const status = explicitStatus ?? inferredStatus;
2629
- const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
2630
- let rawBody;
2631
- let extractedMessage;
2632
- let parsedBody;
2633
- const textFn = response?.text?.bind(response);
2634
- if (textFn) {
2635
- const [bodyError, body] = await catchError((async () => textFn())());
2636
- if (!bodyError && body) {
2637
- rawBody = body;
2638
- const [parseError, parsed] = catchError(() => JSON.parse(body));
2639
- if (!parseError && parsed && typeof parsed === "object") {
2640
- parsedBody = parsed;
2641
- if (parsedBody.errors && typeof parsedBody.errors === "object") {
2642
- for (const field of Object.values(parsedBody.errors)) {
2643
- if (Array.isArray(field) && field.length > 0) {
2644
- const first = field[0];
2645
- if (first && typeof first.message === "string") {
2646
- extractedMessage = first.message;
2647
- break;
2648
- }
2649
- }
2650
- }
2651
- }
2652
- if (!extractedMessage) {
2653
- extractedMessage = typeof parsedBody.message === "string" ? parsedBody.message : typeof parsedBody.errorMessage === "string" ? parsedBody.errorMessage : typeof parsedBody.title === "string" ? parsedBody.title : undefined;
2654
- }
2655
- if (!extractedMessage) {
2656
- extractedMessage = body;
2657
- }
2658
- if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
2659
- extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
2660
- }
2661
- } else {
2662
- extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
2663
- }
2664
- }
2665
- }
2666
- let message;
2667
- let result = "Failure";
2668
- const classification = classifyError(status, error);
2669
- let retry = classification.retry;
2670
- if (status === 401) {
2671
- message = DEFAULT_401;
2672
- result = "AuthenticationError";
2673
- } else if (status === 403) {
2674
- message = options?.forbiddenMessage ?? DEFAULT_403;
2675
- result = "AuthenticationError";
2676
- } else if (status === 405) {
2677
- message = DEFAULT_405;
2678
- } else if (status === 413) {
2679
- message = DEFAULT_413;
2680
- } else if (status === 400 || status === 422) {
2681
- message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
2682
- result = "ValidationError";
2683
- } else if (status === 429) {
2684
- message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
2685
- } else if (extractedMessage) {
2686
- if (isSuccessfulResponse && rawMessage !== "Unknown error") {
2687
- message = rawMessage;
2688
- } else {
2689
- message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
2690
- }
2691
- } else if (status) {
2692
- if (inferredStatus !== undefined) {
2693
- message = rawMessage;
2694
- } else if (rawMessage === "Unknown error" && response) {
2695
- const statusText = response.statusText;
2696
- message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
2697
- } else {
2698
- message = `HTTP ${status}: ${rawMessage}`;
2699
- }
2700
- } else {
2701
- message = rawMessage;
2702
- }
2703
- if (status === undefined) {
2704
- const connectivity = describeConnectivityError(error);
2705
- if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
2706
- message = `${message}: ${connectivity.message}`;
2707
- }
2708
- }
2709
- const permission = status === undefined ? describePermissionError(error) : undefined;
2710
- if (permission) {
2711
- if (permission.message !== message && !message.includes(permission.message)) {
2712
- message = `${message}: ${permission.message}`;
2713
- }
2714
- if (!message.includes(permission.instructions)) {
2715
- const punctuated = message.endsWith(".") ? message : `${message}.`;
2716
- message = `${punctuated} ${permission.instructions}`;
2717
- }
2718
- }
2719
- let details = rawMessage;
2720
- if (rawBody) {
2721
- if (parsedBody) {
2722
- const extra = {};
2723
- if (parsedBody.errorCode)
2724
- extra.errorCode = parsedBody.errorCode;
2725
- if (parsedBody.detail)
2726
- extra.detail = parsedBody.detail;
2727
- if (parsedBody.details)
2728
- extra.details = parsedBody.details;
2729
- if (parsedBody.errors != null)
2730
- extra.errors = parsedBody.errors;
2731
- if (parsedBody.data && typeof parsedBody.data === "object" && Object.keys(parsedBody.data).length > 0) {
2732
- extra.data = parsedBody.data;
2733
- }
2734
- details = Object.keys(extra).length > 0 ? JSON.stringify(extra) : rawBody;
2735
- } else {
2736
- details = rawBody;
2737
- }
2738
- } else if (typeof err.message === "string") {
2739
- details = err.message;
2740
- } else {
2741
- details = String(error);
2742
- }
2743
- const context = {};
2744
- if (status) {
2745
- context.httpStatus = status;
2746
- }
2747
- if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
2748
- context.errorCode = parsedBody.errorCode;
2749
- } else if (parsedBody?.code && typeof parsedBody.code === "string") {
2750
- context.errorCode = parsedBody.code;
2751
- }
2752
- if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
2753
- context.requestId = parsedBody.requestId;
2754
- }
2755
- if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
2756
- context.traceId = parsedBody.traceId;
2757
- }
2758
- if (permission?.path !== undefined) {
2759
- context.path = permission.path;
2760
- }
2761
- if (status === 429) {
2762
- const resp = response;
2763
- const headersObj = resp?.headers;
2764
- let retryAfterValue;
2765
- if (headersObj && typeof headersObj === "object" && typeof headersObj.get === "function") {
2766
- retryAfterValue = headersObj.get("retry-after") ?? undefined;
2767
- }
2768
- if (!retryAfterValue && headersObj && typeof headersObj === "object") {
2769
- const headers = headersObj;
2770
- retryAfterValue = headers["retry-after"] ?? headers["Retry-After"];
2771
- }
2772
- if (retryAfterValue) {
2773
- const seconds = Number(retryAfterValue);
2774
- if (!Number.isNaN(seconds)) {
2775
- context.retryAfter = seconds;
2776
- retry = retryHintForRetryAfter(seconds);
2777
- }
2778
- }
2779
- }
2780
- const hasContext = Object.keys(context).length > 0;
2781
- let parsedErrors;
2782
- if (parsedBody?.errors && typeof parsedBody.errors === "object") {
2783
- const errors = {};
2784
- for (const [field, raw] of Object.entries(parsedBody.errors)) {
2785
- if (Array.isArray(raw)) {
2786
- const messages = raw.map((entry) => {
2787
- if (typeof entry === "string")
2788
- return entry;
2789
- if (entry && typeof entry === "object" && typeof entry.message === "string") {
2790
- return entry.message;
2791
- }
2792
- return String(entry);
2793
- }).filter(Boolean);
2794
- if (messages.length > 0)
2795
- errors[field] = messages;
2796
- } else if (typeof raw === "string") {
2797
- errors[field] = [raw];
2798
- }
2799
- }
2800
- if (Object.keys(errors).length > 0)
2801
- parsedErrors = errors;
2802
- }
2803
- return {
2804
- result,
2805
- errorCode: classification.errorCode,
2806
- message,
2807
- retry,
2808
- details,
2809
- ...hasContext ? { context } : {},
2810
- ...parsedErrors ? { parsedErrors } : {}
2811
- };
2812
- }
2813
- async function extractErrorMessage(error, options) {
2814
- const { message } = await extractErrorDetails(error, options);
2815
- return message;
2816
- }
2817
- // ../common/src/command-examples.ts
2818
- var examplesByCommand = new WeakMap;
2819
- Command.prototype.examples = function(examples) {
2820
- examplesByCommand.set(this, examples);
2821
- return this;
2822
- };
2823
- // ../common/src/output-codecs.ts
2824
- var yamlSlot = singleton("YamlCodec");
2825
- var jmespathSlot = singleton("JmespathCodec");
2826
- async function loadOutputCodecsAsync(needed) {
2827
- const loads = [];
2828
- if (needed.yaml && yamlSlot.get() === undefined) {
2829
- loads.push(import("./js-yaml-cggj6w7q.js").then((mod) => {
2830
- yamlSlot.set(mod);
2831
- }));
2832
- }
2833
- if (needed.filter && jmespathSlot.get() === undefined) {
2834
- loads.push(import("./index-9f8q2ege.js").then((mod) => {
2835
- jmespathSlot.set(mod);
2836
- }));
2837
- }
2838
- await Promise.all(loads);
2839
- }
2840
- function getYamlCodec() {
2841
- return yamlSlot.get();
2842
- }
2843
- function getJmespathCodec() {
2844
- return jmespathSlot.get();
2845
- }
2846
-
2847
- // ../common/src/output-format-context.ts
2848
- var formatSlot = singleton("OutputFormat");
2849
- var formatExplicitSlot = singleton("OutputFormatExplicit");
2850
- var helpRequestedSlot = singleton("HelpRequested");
2851
- var filterSlot = singleton("OutputFilter");
2852
- function getOutputFormat() {
2853
- return formatSlot.get("json");
2854
- }
2855
- function getOutputFormatExplicit() {
2856
- return formatExplicitSlot.get(false) ?? false;
2857
- }
2858
- function getOutputFilter() {
2859
- return filterSlot.get();
2860
- }
2861
-
2862
- // ../common/src/telemetry/command-terminal.ts
2863
- var recordedFailureSlot = singleton("CommandTelemetryFailure");
2864
- var AUTH_ERROR_CODES = new Set([
2865
- "authentication_required",
2866
- "permission_denied"
2867
- ]);
2868
- var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
2869
- var NETWORK_HTTP_ERROR_CODES = new Set([
2870
- "network_error",
2871
- "rate_limited",
2872
- "server_error",
2873
- "not_found",
2874
- "method_not_allowed"
2875
- ]);
2876
- var TIMEOUT_ERROR_CODES = new Set(["timeout"]);
2877
- var NETWORK_OS_ERROR_CODES = new Set([
2878
- "ECONNREFUSED",
2879
- "ECONNRESET",
2880
- "ENOTFOUND",
2881
- "EAI_AGAIN",
2882
- "EPIPE",
2883
- "EHOSTUNREACH",
2884
- "ENETUNREACH",
2885
- "EAI_FAIL"
2886
- ]);
2887
- var TIMEOUT_OS_ERROR_CODES = new Set(["ETIMEDOUT", "ESOCKETTIMEDOUT"]);
2888
- var TLS_ERROR_CODES2 = new Set([
2889
- "SELF_SIGNED_CERT_IN_CHAIN",
2890
- "DEPTH_ZERO_SELF_SIGNED_CERT",
2891
- "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
2892
- "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
2893
- "UNABLE_TO_GET_ISSUER_CERT",
2894
- "CERT_HAS_EXPIRED",
2895
- "CERT_UNTRUSTED",
2896
- "ERR_TLS_CERT_ALTNAME_INVALID"
2897
- ]);
2898
- var MISSING_DEPENDENCY_CODES = new Set([
2899
- "MODULE_NOT_FOUND",
2900
- "ERR_MODULE_NOT_FOUND"
2901
- ]);
2902
- var INTERNAL_ERROR_NAMES = new Set([
2903
- "TypeError",
2904
- "ReferenceError",
2905
- "SyntaxError",
2906
- "RangeError"
2907
- ]);
2908
- function isRecord(value) {
2909
- return value !== null && typeof value === "object";
2910
- }
2911
- function stringField(value, field) {
2912
- if (!isRecord(value)) {
2913
- return;
2914
- }
2915
- const raw = value[field];
2916
- return typeof raw === "string" ? raw : undefined;
2917
- }
2918
- function numberField(value, field) {
2919
- if (!isRecord(value)) {
2920
- return;
2921
- }
2922
- const raw = value[field];
2923
- return typeof raw === "number" ? raw : undefined;
2924
- }
2925
- function findStringInCauseChain(error, field) {
2926
- let current = error;
2927
- for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
2928
- const value = stringField(current, field);
2929
- if (value) {
2930
- return value;
2931
- }
2932
- current = current.cause;
2933
- }
2934
- return;
2935
- }
2936
- function findCodeInCauseChain(error) {
2937
- return findStringInCauseChain(error, "code");
2938
- }
2939
- function isSpawnEnoent(error) {
2940
- const code = findCodeInCauseChain(error);
2941
- if (code !== "ENOENT") {
2942
- return false;
2943
- }
2944
- const syscall = findStringInCauseChain(error, "syscall");
2945
- return syscall?.startsWith("spawn") === true;
2946
- }
2947
- function isCancellationError(error, exitCode, pollSignal) {
2948
- if (exitCode === 130) {
2949
- return true;
2950
- }
2951
- if (!isRecord(error)) {
2952
- return false;
2953
- }
2954
- if (numberField(error, "exitCode") === 130) {
2955
- return true;
2956
- }
2957
- const name = stringField(error, "name");
2958
- if (name === "ExitPromptError") {
2959
- return true;
2960
- }
2961
- if (name === "AbortError" && pollSignal?.aborted) {
2962
- return true;
2963
- }
2964
- const message = stringField(error, "message");
2965
- return message?.includes("SIGINT") === true;
2966
- }
2967
- function terminalSignalFor(input, outcome) {
2968
- if (input.recordedFailure?.terminalSignal) {
2969
- return input.recordedFailure.terminalSignal;
2970
- }
2971
- const explicit = findStringInCauseChain(input.error, "terminalSignal") ?? findStringInCauseChain(input.error, "signal");
2972
- if (explicit) {
2973
- return explicit;
2974
- }
2975
- return outcome === "cancelled" ? "SIGINT" : undefined;
2976
- }
2977
- function classifyHttpStatus(status) {
2978
- if (status === 401 || status === 403) {
2979
- return "auth";
2980
- }
2981
- if (status === 400 || status === 409 || status === 422) {
2982
- return "validation";
2983
- }
2984
- if (status === 408) {
2985
- return "timeout";
2986
- }
2987
- return "network_http";
2988
- }
2989
- function classifyFromResult(result) {
2990
- switch (result) {
2991
- case "AuthenticationError":
2992
- return "auth";
2993
- case "ValidationError":
2994
- return "validation";
2995
- case "TimeoutError":
2996
- return "timeout";
2997
- default:
2998
- return;
2999
- }
3000
- }
3001
- function classifyFromErrorCode(errorCode) {
3002
- if (!errorCode) {
3003
- return;
3036
+ }
3037
+ function classifyFromErrorCode(errorCode) {
3038
+ if (!errorCode) {
3039
+ return;
3004
3040
  }
3005
3041
  if (AUTH_ERROR_CODES.has(errorCode)) {
3006
3042
  return "auth";
@@ -3022,7 +3058,7 @@ function classifyFromError(error) {
3022
3058
  if (code.startsWith("commander.")) {
3023
3059
  return "validation";
3024
3060
  }
3025
- if (NETWORK_OS_ERROR_CODES.has(code) || TLS_ERROR_CODES2.has(code)) {
3061
+ if (NETWORK_OS_ERROR_CODES.has(code) || TLS_ERROR_CODES.has(code)) {
3026
3062
  return "network_http";
3027
3063
  }
3028
3064
  if (TIMEOUT_OS_ERROR_CODES.has(code)) {
@@ -3042,7 +3078,7 @@ function classifyFromError(error) {
3042
3078
  }
3043
3079
  return;
3044
3080
  }
3045
- function classifyError2(input) {
3081
+ function classifyError(input) {
3046
3082
  const recorded = input.recordedFailure;
3047
3083
  if (recorded?.errorClass) {
3048
3084
  return recorded.errorClass;
@@ -3067,7 +3103,7 @@ function takeRecordedCommandFailureTelemetry() {
3067
3103
  function buildCommandTerminalTelemetryProperties(input) {
3068
3104
  const cancelled = isCancellationError(input.error, input.exitCode, input.pollSignal);
3069
3105
  const outcome = input.recordedFailure?.terminalOutcome ?? (input.exitCode === 0 ? "success" : cancelled ? "cancelled" : "failure");
3070
- const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError2(input);
3106
+ const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError(input);
3071
3107
  const terminalSignal = terminalSignalFor(input, outcome);
3072
3108
  return {
3073
3109
  exit_code: input.exitCode,
@@ -3112,27 +3148,41 @@ class LoggerTelemetryProvider {
3112
3148
  ...this.analyticsUniqueId ? { analyticsUniqueId: this.analyticsUniqueId } : {}
3113
3149
  };
3114
3150
  }
3115
- async trackEvent(eventName, properties) {
3116
- logger.debug(formatMessage("Event", eventName, this.enrich(properties)));
3151
+ async trackEvent({ name, properties }) {
3152
+ logger.debug(formatMessage("Event", name, this.enrich(properties)));
3117
3153
  }
3118
- async trackException(error, properties) {
3154
+ async trackException({
3155
+ error,
3156
+ properties
3157
+ }) {
3119
3158
  logger.error(formatMessage("Exception", error.message, this.enrich({
3120
3159
  ...properties,
3121
3160
  stack: error.stack
3122
3161
  })));
3123
3162
  }
3124
- async trackRequest(name, duration, success, properties) {
3163
+ async trackRequest({
3164
+ name,
3165
+ durationMs,
3166
+ success,
3167
+ properties
3168
+ }) {
3125
3169
  logger.debug(formatMessage("Request", name, this.enrich({
3126
3170
  ...properties,
3127
- duration: `${duration}ms`,
3171
+ duration: `${durationMs}ms`,
3128
3172
  success
3129
3173
  })));
3130
3174
  }
3131
- async trackDependency(name, type, duration, success, properties) {
3175
+ async trackDependency({
3176
+ name,
3177
+ type,
3178
+ durationMs,
3179
+ success,
3180
+ properties
3181
+ }) {
3132
3182
  logger.debug(formatMessage("Dependency", name, this.enrich({
3133
3183
  ...properties,
3134
3184
  type,
3135
- duration: `${duration}ms`,
3185
+ duration: `${durationMs}ms`,
3136
3186
  success
3137
3187
  })));
3138
3188
  }
@@ -3388,144 +3438,16 @@ function getGlobalTelemetryProperties() {
3388
3438
  return telemetryPropsSlot.get();
3389
3439
  }
3390
3440
 
3391
- // ../common/src/telemetry/pii-redactor.ts
3392
- var REDACTED = "[REDACTED]";
3393
- var MAX_VALUE_LENGTH = 200;
3394
- var SENSITIVE_NAME_TOKENS = new Set([
3395
- "token",
3396
- "tokens",
3397
- "secret",
3398
- "secrets",
3399
- "password",
3400
- "passwords",
3401
- "pwd",
3402
- "credential",
3403
- "credentials",
3404
- "auth",
3405
- "authentication",
3406
- "authorization",
3407
- "authority",
3408
- "cert",
3409
- "certificate",
3410
- "certificates"
3411
- ]);
3412
- var SENSITIVE_KEY_PREFIXES = new Set([
3413
- "api",
3414
- "access",
3415
- "client",
3416
- "private",
3417
- "public",
3418
- "signing",
3419
- "encryption",
3420
- "session",
3421
- "master",
3422
- "shared",
3423
- "root",
3424
- "ssh",
3425
- "rsa",
3426
- "aes",
3427
- "hmac",
3428
- "oauth"
3429
- ]);
3430
- 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;
3431
- var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
3432
- var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
3433
- var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
3434
- var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
3435
- var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
3436
- var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
3437
- function shortHash(input) {
3438
- let hash = 2166136261;
3439
- for (let i = 0;i < input.length; i++) {
3440
- hash ^= input.charCodeAt(i);
3441
- hash = Math.imul(hash, 16777619);
3442
- }
3443
- return (hash >>> 0).toString(16).padStart(8, "0");
3444
- }
3445
- function redactUrl(raw) {
3446
- try {
3447
- const url = new URL(raw);
3448
- return `${url.protocol}//${url.host}`;
3449
- } catch {
3450
- return `url#${shortHash(raw)}`;
3451
- }
3452
- }
3453
- function redactValueDetectors(value) {
3454
- let out = value;
3455
- out = out.replace(JWT_PATTERN, () => REDACTED);
3456
- out = out.replace(URL_PATTERN, (match) => {
3457
- const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
3458
- const core = trailing ? match.slice(0, -trailing.length) : match;
3459
- return `${redactUrl(core)}${trailing}`;
3460
- });
3461
- out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
3462
- out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
3463
- out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
3464
- out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
3465
- if (out.length > MAX_VALUE_LENGTH) {
3466
- out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
3467
- }
3468
- return out;
3469
- }
3470
- function redactValue(value) {
3471
- return redactValueDetectors(value);
3472
- }
3473
- function redactError(error) {
3474
- const safe = new Error(redactValueDetectors(error.message ?? ""));
3475
- safe.name = error.name;
3476
- safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
3477
- return safe;
3478
- }
3479
- function nameTokens(name) {
3480
- 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);
3481
- }
3482
- function isSensitiveName(name) {
3483
- const tokens = nameTokens(name);
3484
- for (let i = 0;i < tokens.length; i++) {
3485
- const token = tokens[i];
3486
- if (SENSITIVE_NAME_TOKENS.has(token)) {
3487
- return true;
3488
- }
3489
- if (token === "key" || token === "keys") {
3490
- const prev = tokens[i - 1];
3491
- if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
3492
- return true;
3493
- }
3494
- }
3495
- }
3496
- return false;
3497
- }
3498
- function redactProperty(name, value) {
3499
- if (value === undefined || value === null) {
3500
- return;
3501
- }
3502
- if (isSensitiveName(name)) {
3503
- return REDACTED;
3504
- }
3505
- if (typeof value === "boolean" || typeof value === "number") {
3506
- return value;
3507
- }
3508
- if (typeof value !== "string") {
3509
- return "[OBJECT]";
3510
- }
3511
- return redactValueDetectors(value);
3512
- }
3513
- function redactProperties(properties) {
3514
- const out = {};
3515
- for (const [name, value] of Object.entries(properties)) {
3516
- const redacted = redactProperty(name, value);
3517
- if (redacted !== undefined) {
3518
- out[name] = redacted;
3519
- }
3520
- }
3521
- return out;
3441
+ // ../common/src/telemetry/span-clock.ts
3442
+ function startSpanClock() {
3443
+ const started = performance.now();
3444
+ return {
3445
+ startedAt: new Date(performance.timeOrigin + started),
3446
+ elapsedMs: () => performance.now() - started
3447
+ };
3522
3448
  }
3523
3449
 
3524
3450
  // ../common/src/telemetry/telemetry-service.ts
3525
- var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
3526
- var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
3527
- var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
3528
-
3529
3451
  class TelemetryService {
3530
3452
  telemetryProvider;
3531
3453
  contextStorage;
@@ -3545,36 +3467,39 @@ class TelemetryService {
3545
3467
  this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
3546
3468
  }
3547
3469
  trackEvent(name, properties) {
3548
- const context = this.getCurrentContext();
3549
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3550
- this.telemetryProvider.trackEvent(name, enrichedProperties);
3470
+ this.telemetryProvider.trackEvent({
3471
+ name: redactSpanName(name),
3472
+ properties: this.enrichProperties(properties),
3473
+ ...this.leafCorrelation()
3474
+ });
3551
3475
  }
3552
- trackException(error, properties) {
3553
- const context = this.getCurrentContext();
3554
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3555
- this.telemetryProvider.trackException(redactError(error), enrichedProperties);
3476
+ trackException(error, properties, context) {
3477
+ this.telemetryProvider.trackException({
3478
+ error: redactError(error),
3479
+ properties: this.enrichProperties(properties),
3480
+ ...this.leafCorrelation(context)
3481
+ });
3556
3482
  }
3557
3483
  async trackRequest(name, fn, properties) {
3558
- const parentContext = this.getCurrentContext();
3484
+ const parentContext = this.getActiveContext();
3559
3485
  const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
3560
3486
  const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
3487
+ const clock = startSpanClock();
3561
3488
  const context = {
3562
3489
  operationId,
3563
3490
  ...parentId !== undefined ? { parentId } : {},
3564
- id: this.generateId()
3491
+ id: this.generateId(),
3492
+ startedAt: clock.startedAt
3565
3493
  };
3566
- const startTime = performance.now();
3567
3494
  try {
3568
3495
  const result = await this.contextStorage.run(context, fn);
3569
- const durationMs = performance.now() - startTime;
3570
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3571
- await this.telemetryProvider.trackRequest(name, durationMs, true, enrichedProperties);
3496
+ const durationMs = clock.elapsedMs();
3497
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, true, properties, context));
3572
3498
  return result;
3573
3499
  } catch (error) {
3574
- const durationMs = performance.now() - startTime;
3500
+ const durationMs = clock.elapsedMs();
3575
3501
  const err = error instanceof Error ? error : new Error(String(error));
3576
- const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, context);
3577
- await this.telemetryProvider.trackRequest(name, durationMs, false, enrichedProperties);
3502
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, context));
3578
3503
  throw error;
3579
3504
  }
3580
3505
  }
@@ -3583,8 +3508,7 @@ class TelemetryService {
3583
3508
  operationId: this.operationId ?? getTelemetryOperationId(),
3584
3509
  id: this.generateId()
3585
3510
  };
3586
- const enrichedProperties = this.enrichPropertiesWithContext(properties, requestContext);
3587
- this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
3511
+ this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, success, properties, requestContext));
3588
3512
  }
3589
3513
  createRequestContext() {
3590
3514
  const operationId = this.operationId ?? getTelemetryOperationId();
@@ -3592,7 +3516,8 @@ class TelemetryService {
3592
3516
  return {
3593
3517
  operationId,
3594
3518
  ...parentId !== undefined ? { parentId } : {},
3595
- id: this.generateId()
3519
+ id: this.generateId(),
3520
+ startedAt: startSpanClock().startedAt
3596
3521
  };
3597
3522
  }
3598
3523
  inboundParentIdFor(operationId) {
@@ -3603,58 +3528,84 @@ class TelemetryService {
3603
3528
  return this.contextStorage.run(context, fn);
3604
3529
  }
3605
3530
  createDependencyContext() {
3606
- const parentContext = this.getCurrentContext();
3531
+ const parentContext = this.getActiveContext();
3607
3532
  if (!parentContext) {
3608
3533
  return;
3609
3534
  }
3610
3535
  return {
3611
3536
  operationId: parentContext.operationId,
3612
3537
  parentId: parentContext.id,
3613
- id: this.generateId()
3538
+ id: this.generateId(),
3539
+ startedAt: startSpanClock().startedAt
3614
3540
  };
3615
3541
  }
3616
3542
  trackDependencyResult(name, type, durationMs, success, properties, context, resultCode) {
3617
- const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
3618
- this.telemetryProvider.trackDependency(redactValue(name), type, durationMs, success, enrichedProperties, resultCode);
3543
+ this.telemetryProvider.trackDependency({
3544
+ ...this.spanFor(redactHttpDependencyName(name), durationMs, success, properties, context),
3545
+ type,
3546
+ ...resultCode !== undefined ? { resultCode } : {}
3547
+ });
3619
3548
  }
3620
3549
  async trackDependencyOperation(name, type, fn, properties) {
3621
- const parentContext = this.getCurrentContext();
3550
+ const clock = startSpanClock();
3551
+ const parentContext = this.getActiveContext();
3622
3552
  const childContext = parentContext !== undefined ? {
3623
3553
  operationId: parentContext.operationId,
3624
3554
  parentId: parentContext.id,
3625
- id: this.generateId()
3626
- } : this.createRequestContext();
3627
- const startTime = performance.now();
3555
+ id: this.generateId(),
3556
+ startedAt: clock.startedAt
3557
+ } : {
3558
+ ...this.createRequestContext(),
3559
+ startedAt: clock.startedAt
3560
+ };
3628
3561
  try {
3629
3562
  const result = await this.contextStorage.run(childContext, fn);
3630
- const durationMs = performance.now() - startTime;
3631
- const enrichedProperties = this.enrichPropertiesWithContext(properties, childContext);
3632
- await this.telemetryProvider.trackDependency(name, type, durationMs, true, enrichedProperties);
3563
+ const durationMs = clock.elapsedMs();
3564
+ await this.telemetryProvider.trackDependency({
3565
+ ...this.spanFor(name, durationMs, true, properties, childContext),
3566
+ type
3567
+ });
3633
3568
  return result;
3634
3569
  } catch (error) {
3635
- const durationMs = performance.now() - startTime;
3570
+ const durationMs = clock.elapsedMs();
3636
3571
  const err = error instanceof Error ? error : new Error(String(error));
3637
- const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, childContext);
3638
- await this.telemetryProvider.trackDependency(name, type, durationMs, false, enrichedProperties);
3572
+ await this.telemetryProvider.trackDependency({
3573
+ ...this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, childContext),
3574
+ type
3575
+ });
3639
3576
  throw error;
3640
3577
  }
3641
3578
  }
3642
- getCurrentContext() {
3579
+ getActiveContext() {
3643
3580
  return this.contextStorage.getContext();
3644
3581
  }
3645
- enrichPropertiesWithContext(properties, context) {
3582
+ leafCorrelation(explicit) {
3583
+ const context = explicit ?? this.getActiveContext();
3584
+ return {
3585
+ operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
3586
+ ...context !== undefined ? { parentId: context.id } : {}
3587
+ };
3588
+ }
3589
+ spanFor(name, durationMs, success, properties, context) {
3590
+ return {
3591
+ name: redactSpanName(name),
3592
+ durationMs,
3593
+ success,
3594
+ properties: this.enrichProperties(properties),
3595
+ operationId: context.operationId,
3596
+ ...context.parentId !== undefined ? { parentId: context.parentId } : {},
3597
+ id: context.id,
3598
+ ...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
3599
+ };
3600
+ }
3601
+ enrichProperties(properties) {
3646
3602
  const globalProperties = getGlobalTelemetryProperties();
3647
3603
  const enriched = {
3648
3604
  ...getExecutionContextTelemetryProperties(),
3649
3605
  ...globalProperties,
3650
3606
  ...this.defaultProperties,
3651
3607
  ...redactProperties(properties ?? {}),
3652
- [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
3653
- ...context ? {
3654
- [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
3655
- ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
3656
- [TELEMETRY_SPAN_ID_PROPERTY]: context.id
3657
- } : {}
3608
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
3658
3609
  };
3659
3610
  return enriched;
3660
3611
  }
@@ -3671,6 +3622,81 @@ class TelemetryService {
3671
3622
  return hex;
3672
3623
  }
3673
3624
  }
3625
+ // ../common/src/timings.ts
3626
+ var TIMINGS_ENV_VAR = "UIP_TIMINGS";
3627
+ function createStorage2() {
3628
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
3629
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
3630
+ return {
3631
+ getStore: () => {
3632
+ return;
3633
+ },
3634
+ run: (_store, fn) => fn()
3635
+ };
3636
+ }
3637
+ return new mod.AsyncLocalStorage;
3638
+ }
3639
+ var storageSlot = singleton("TimingStorage");
3640
+ var stateSlot = singleton("Timings");
3641
+ var rootStartedSlot = singleton("TimingsRootStarted");
3642
+ var longLivedHostSlot = singleton("TimingsLongLivedHost");
3643
+ var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
3644
+ function newState(baseline) {
3645
+ return { baseline, httpMs: 0, httpCalls: 0 };
3646
+ }
3647
+ function getState() {
3648
+ const scoped = storage.getStore();
3649
+ if (scoped) {
3650
+ return scoped;
3651
+ }
3652
+ const pinned = livePinnedState();
3653
+ if (pinned !== undefined) {
3654
+ return pinned;
3655
+ }
3656
+ return newState(processStartIsInvocationStart() ? 0 : performance.now());
3657
+ }
3658
+ function livePinnedState() {
3659
+ const pinned = stateSlot.get();
3660
+ return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
3661
+ }
3662
+ function processStartIsInvocationStart() {
3663
+ return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
3664
+ }
3665
+ function timingsEnabled() {
3666
+ if (typeof process === "undefined") {
3667
+ return false;
3668
+ }
3669
+ const value = process.env?.[TIMINGS_ENV_VAR];
3670
+ if (value === undefined) {
3671
+ return false;
3672
+ }
3673
+ const normalized = value.trim().toLowerCase();
3674
+ return normalized === "1" || normalized === "true";
3675
+ }
3676
+ function recordExitCode(exitCode) {
3677
+ if (!timingsEnabled()) {
3678
+ return;
3679
+ }
3680
+ getState().exitCode = exitCode;
3681
+ }
3682
+ function invocationStartedAt() {
3683
+ return new Date(performance.timeOrigin + getState().baseline);
3684
+ }
3685
+ function invocationElapsedMs() {
3686
+ return performance.now() - getState().baseline;
3687
+ }
3688
+ function markCommandStart() {
3689
+ if (!timingsEnabled()) {
3690
+ return;
3691
+ }
3692
+ getState().commandStart = performance.now();
3693
+ }
3694
+ function recordCommandDuration(durationMs) {
3695
+ if (!timingsEnabled()) {
3696
+ return;
3697
+ }
3698
+ getState().commandMs = durationMs;
3699
+ }
3674
3700
  // ../common/src/telemetry/proxy-http-agent.ts
3675
3701
  var slot = singleton("ProxyAuthHttpsAgent");
3676
3702
 
@@ -3691,6 +3717,9 @@ function getGlobalTelemetryInstance() {
3691
3717
  }
3692
3718
  return;
3693
3719
  }
3720
+ function setGlobalTelemetryInstance(instance) {
3721
+ telemetryInstanceSlot.set(instance);
3722
+ }
3694
3723
  var _localTelemetryInstance;
3695
3724
  function getTelemetryInstance() {
3696
3725
  const global = getGlobalTelemetryInstance();
@@ -3698,6 +3727,7 @@ function getTelemetryInstance() {
3698
3727
  return global;
3699
3728
  if (!_localTelemetryInstance) {
3700
3729
  _localTelemetryInstance = new TelemetryService(new LoggerTelemetryProvider, new NodeContextStorage);
3730
+ setGlobalTelemetryInstance(_localTelemetryInstance);
3701
3731
  }
3702
3732
  return _localTelemetryInstance;
3703
3733
  }
@@ -3710,6 +3740,14 @@ var telemetry = new Proxy({}, {
3710
3740
  });
3711
3741
 
3712
3742
  // ../common/src/formatter.ts
3743
+ var ANSI_STYLES = {
3744
+ red: "\x1B[31m",
3745
+ dim: "\x1B[2m"
3746
+ };
3747
+ var ANSI_RESET = "\x1B[0m";
3748
+ function styleLine(line, style) {
3749
+ return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
3750
+ }
3713
3751
  var CLI_ERROR_CODES = [
3714
3752
  "invalid_argument",
3715
3753
  "authentication_required",
@@ -3781,23 +3819,6 @@ function derivePaginationHasMore(returned, limit, offset, total, nextPage) {
3781
3819
  }
3782
3820
  return (offset ?? 0) + returned < total;
3783
3821
  }
3784
-
3785
- class SuccessOutput {
3786
- Result = RESULTS.Success;
3787
- Code;
3788
- Data;
3789
- Pagination;
3790
- Instructions;
3791
- Log;
3792
- constructor(code, data) {
3793
- this.Code = code;
3794
- this.Data = data;
3795
- const logPath = getLogFilePath();
3796
- if (logPath) {
3797
- this.Log = logPath;
3798
- }
3799
- }
3800
- }
3801
3822
  function escapeNonAscii(jsonText) {
3802
3823
  return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
3803
3824
  const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
@@ -3862,19 +3883,45 @@ function toPascalCaseKey(key) {
3862
3883
  const lowerCamelKey = toLowerCamelCaseKey(key);
3863
3884
  return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
3864
3885
  }
3865
- function toPascalCaseData(value) {
3886
+ function collectVerbatimRefs(value, into) {
3887
+ if (typeof value !== "object" || value === null)
3888
+ return;
3889
+ if (into.has(value))
3890
+ return;
3891
+ into.add(value);
3892
+ for (const nested of Array.isArray(value) ? value : Object.values(value)) {
3893
+ collectVerbatimRefs(nested, into);
3894
+ }
3895
+ }
3896
+ function toPascalCaseData(value, verbatimKeys, subtrees) {
3897
+ if (subtrees?.mode === "skip" && typeof value === "object" && value !== null && subtrees.refs.has(value)) {
3898
+ return value;
3899
+ }
3866
3900
  if (Array.isArray(value))
3867
- return value.map(toPascalCaseData);
3901
+ return value.map((entry) => toPascalCaseData(entry, verbatimKeys, subtrees));
3868
3902
  if (!isPlainRecord(value))
3869
3903
  return value;
3870
3904
  const result = {};
3871
3905
  for (const [key, nestedValue] of Object.entries(value)) {
3872
- result[toPascalCaseKey(key)] = toPascalCaseData(nestedValue);
3906
+ const pascalKey = toPascalCaseKey(key);
3907
+ if (verbatimKeys?.has(pascalKey)) {
3908
+ result[pascalKey] = nestedValue;
3909
+ if (subtrees?.mode === "collect") {
3910
+ collectVerbatimRefs(nestedValue, subtrees.refs);
3911
+ }
3912
+ continue;
3913
+ }
3914
+ result[pascalKey] = toPascalCaseData(nestedValue, verbatimKeys, subtrees);
3873
3915
  }
3874
3916
  return result;
3875
3917
  }
3876
- function normalizeDataKeys(data) {
3877
- return toPascalCaseData(data);
3918
+ function normalizeDataKeys(data, verbatimKeys, subtrees) {
3919
+ return toPascalCaseData(data, verbatimKeys, subtrees);
3920
+ }
3921
+ function toVerbatimKeySet(preserve) {
3922
+ if (!Array.isArray(preserve))
3923
+ return;
3924
+ return new Set(preserve.map(toPascalCaseKey));
3878
3925
  }
3879
3926
  function normalizeOutputKeys(data) {
3880
3927
  const result = {};
@@ -3884,7 +3931,7 @@ function normalizeOutputKeys(data) {
3884
3931
  }
3885
3932
  return result;
3886
3933
  }
3887
- function printOutput(data, format = "json", logFn, asciiSafe = false) {
3934
+ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowStyle) {
3888
3935
  if (!data) {
3889
3936
  logFn("Empty response object. No data to display.");
3890
3937
  return;
@@ -3919,7 +3966,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
3919
3966
  if (hasData && !(rows !== null && rows.length === 0)) {
3920
3967
  const logValue = data.Log;
3921
3968
  if (rows !== null) {
3922
- printResizableTable(rows, logFn, logValue);
3969
+ printResizableTable(rows, logFn, logValue, undefined, tableRowStyle);
3923
3970
  } else {
3924
3971
  printVerticalTable(data.Data, logFn, logValue);
3925
3972
  }
@@ -3930,10 +3977,11 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
3930
3977
  }
3931
3978
  }
3932
3979
  }
3933
- function logOutput(data, format = "json") {
3980
+ function logOutput(data, format = "json", tableRowStyle) {
3934
3981
  const sink = getOutputSink();
3982
+ const styleFn = sink.capabilities.isInteractive && sink.capabilities.supportsColor ? tableRowStyle : undefined;
3935
3983
  printOutput(data, format, (msg) => sink.writeOut(`${msg}
3936
- `), needsAsciiSafeJson(sink));
3984
+ `), needsAsciiSafeJson(sink), styleFn);
3937
3985
  }
3938
3986
  function cellToString(val) {
3939
3987
  return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
@@ -3947,7 +3995,7 @@ function wrapText(text, width) {
3947
3995
  }
3948
3996
  return lines;
3949
3997
  }
3950
- function printTable(data, logFn, externalLogValue) {
3998
+ function printTable(data, logFn, externalLogValue, tableRowStyle) {
3951
3999
  if (data.length === 0)
3952
4000
  return;
3953
4001
  const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
@@ -3957,7 +4005,7 @@ function printTable(data, logFn, externalLogValue) {
3957
4005
  logFn(keys.map((_, i) => "-".repeat(maxWidths[i])).join("-|-"));
3958
4006
  data.forEach((item) => {
3959
4007
  const row = keys.map((key, i) => cellToString(item[key]).padEnd(maxWidths[i])).join(" | ");
3960
- logFn(row);
4008
+ logFn(styleLine(row, tableRowStyle?.(item)));
3961
4009
  });
3962
4010
  if (externalLogValue) {
3963
4011
  logFn("");
@@ -4000,14 +4048,14 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
4000
4048
  logFn(`Log: ${externalLogValue}`);
4001
4049
  }
4002
4050
  }
4003
- function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth) {
4051
+ function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
4004
4052
  if (data.length === 0)
4005
4053
  return;
4006
4054
  const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
4007
4055
  if (keys.length === 0)
4008
4056
  return;
4009
4057
  if (!process.stdout.isTTY) {
4010
- printTable(data, logFn, externalLogValue);
4058
+ printTable(data, logFn, externalLogValue, tableRowStyle);
4011
4059
  return;
4012
4060
  }
4013
4061
  const naturalWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
@@ -4015,7 +4063,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
4015
4063
  const totalWidth = naturalWidths.reduce((a, b) => a + b, 0) + separatorTotal;
4016
4064
  const termWidth = availableWidth ?? (process.stdout.columns || 120);
4017
4065
  if (totalWidth <= termWidth) {
4018
- printTable(data, logFn, externalLogValue);
4066
+ printTable(data, logFn, externalLogValue, tableRowStyle);
4019
4067
  return;
4020
4068
  }
4021
4069
  const overflow = totalWidth - termWidth;
@@ -4040,120 +4088,484 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
4040
4088
  bestCol = i;
4041
4089
  }
4042
4090
  }
4043
- const finalWidths = [...naturalWidths];
4044
- if (bestCol !== -1) {
4045
- finalWidths[bestCol] = naturalWidths[bestCol] - overflow;
4046
- } else {
4047
- let remaining = overflow;
4048
- const colsByShrinkPotential = keys.map((_, i) => ({
4049
- index: i,
4050
- potential: naturalWidths[i] - minWidths[i]
4051
- })).filter((c) => c.potential > 0).sort((a, b) => b.potential - a.potential);
4052
- for (const col of colsByShrinkPotential) {
4053
- if (remaining <= 0)
4054
- break;
4055
- const shrink = Math.min(remaining, col.potential);
4056
- finalWidths[col.index] -= shrink;
4057
- remaining -= shrink;
4091
+ const finalWidths = [...naturalWidths];
4092
+ if (bestCol !== -1) {
4093
+ finalWidths[bestCol] = naturalWidths[bestCol] - overflow;
4094
+ } else {
4095
+ let remaining = overflow;
4096
+ const colsByShrinkPotential = keys.map((_, i) => ({
4097
+ index: i,
4098
+ potential: naturalWidths[i] - minWidths[i]
4099
+ })).filter((c) => c.potential > 0).sort((a, b) => b.potential - a.potential);
4100
+ for (const col of colsByShrinkPotential) {
4101
+ if (remaining <= 0)
4102
+ break;
4103
+ const shrink = Math.min(remaining, col.potential);
4104
+ finalWidths[col.index] -= shrink;
4105
+ remaining -= shrink;
4106
+ }
4107
+ }
4108
+ const header = keys.map((key, i) => key.padEnd(finalWidths[i])).join(" | ");
4109
+ logFn(header);
4110
+ logFn(keys.map((_, i) => "-".repeat(finalWidths[i])).join("-|-"));
4111
+ data.forEach((item) => {
4112
+ const style = tableRowStyle?.(item);
4113
+ const cellLines = keys.map((key, i) => wrapText(cellToString(item[key]), finalWidths[i]));
4114
+ const lineCount = Math.max(...cellLines.map((l) => l.length));
4115
+ for (let line = 0;line < lineCount; line++) {
4116
+ const row = keys.map((_, i) => {
4117
+ const val = line < cellLines[i].length ? cellLines[i][line] : "";
4118
+ return val.padEnd(finalWidths[i]);
4119
+ }).join(" | ");
4120
+ logFn(styleLine(row, style));
4121
+ }
4122
+ });
4123
+ if (externalLogValue) {
4124
+ logFn("");
4125
+ logFn(`Log: ${externalLogValue}`);
4126
+ }
4127
+ }
4128
+ function toYaml(data) {
4129
+ const codec = getYamlCodec();
4130
+ if (!codec) {
4131
+ throw new Error("YAML output requested before the YAML codec was loaded. " + "Call loadOutputCodecsAsync({ yaml: true }) first.");
4132
+ }
4133
+ return codec.dump(data);
4134
+ }
4135
+ function requireJmespath() {
4136
+ const codec = getJmespathCodec();
4137
+ if (!codec) {
4138
+ throw new Error("An --output-filter was applied before the JMESPath codec was loaded. " + "Call loadOutputCodecsAsync({ filter: true }) first.");
4139
+ }
4140
+ return codec;
4141
+ }
4142
+
4143
+ class FilterEvaluationError extends Error {
4144
+ __brand = "FilterEvaluationError";
4145
+ filter;
4146
+ errorCode = "invalid_argument";
4147
+ instructions;
4148
+ retry = "RetryWillNotFix";
4149
+ result = RESULTS.ValidationError;
4150
+ constructor(filter, cause) {
4151
+ const underlying = cause instanceof Error ? cause.message : String(cause);
4152
+ super(`Filter '${filter}' failed to evaluate: ${underlying}`);
4153
+ this.name = "FilterEvaluationError";
4154
+ this.filter = filter;
4155
+ this.instructions = `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
4156
+ }
4157
+ }
4158
+
4159
+ class FilterImplicitLimitError extends Error {
4160
+ __brand = "FilterImplicitLimitError";
4161
+ errorCode = "invalid_argument";
4162
+ instructions;
4163
+ retry = "RetryWillNotFix";
4164
+ result = RESULTS.ValidationError;
4165
+ constructor(defaultLimit) {
4166
+ super(`--output-filter requires an explicit --limit: this command defaults to --limit ${defaultLimit}, ` + `so the filter would silently apply to only the first ${defaultLimit} records.`);
4167
+ this.name = "FilterImplicitLimitError";
4168
+ this.instructions = "Pass --limit <n> to choose how many records the filter applies to. " + "To filter over all records, pass the command's maximum accepted --limit (see the option's description in --help).";
4169
+ }
4170
+ }
4171
+ function applyFilter(data, filter) {
4172
+ const codec = requireJmespath();
4173
+ let result;
4174
+ try {
4175
+ result = codec.search(data, filter);
4176
+ } catch (err) {
4177
+ throw new FilterEvaluationError(filter, err);
4178
+ }
4179
+ if (result == null)
4180
+ return [];
4181
+ if (Array.isArray(result)) {
4182
+ if (result.length > 0 && typeof result[0] !== "object") {
4183
+ const fieldMatch = filter.match(/\.(\w+)$/);
4184
+ const key = fieldMatch ? fieldMatch[1] : "Value";
4185
+ return result.map((v) => ({ [key]: v }));
4186
+ }
4187
+ return result;
4188
+ }
4189
+ if (typeof result === "object")
4190
+ return result;
4191
+ return { Value: result };
4192
+ }
4193
+ function defaultErrorCodeForResult(result) {
4194
+ switch (result) {
4195
+ case RESULTS.AuthenticationError:
4196
+ return "authentication_required";
4197
+ case RESULTS.ConfigError:
4198
+ return "configuration_error";
4199
+ case RESULTS.ValidationError:
4200
+ return "invalid_argument";
4201
+ case RESULTS.TimeoutError:
4202
+ return "timeout";
4203
+ default:
4204
+ return "unknown_error";
4205
+ }
4206
+ }
4207
+ function parseHttpStatusFromMessage(message) {
4208
+ const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
4209
+ if (!match)
4210
+ return;
4211
+ const status = Number(match[1]);
4212
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
4213
+ }
4214
+ function defaultErrorCodeForHttpStatus(status) {
4215
+ if (status === undefined)
4216
+ return;
4217
+ if (status === 400 || status === 409 || status === 422) {
4218
+ return "invalid_argument";
4219
+ }
4220
+ if (status === 401)
4221
+ return "authentication_required";
4222
+ if (status === 403)
4223
+ return "permission_denied";
4224
+ if (status === 404)
4225
+ return "not_found";
4226
+ if (status === 405)
4227
+ return "method_not_allowed";
4228
+ if (status === 408)
4229
+ return "timeout";
4230
+ if (status === 429)
4231
+ return "rate_limited";
4232
+ if (status >= 500 && status < 600)
4233
+ return "server_error";
4234
+ return;
4235
+ }
4236
+ var LOCAL_PERMISSION_TEXT_PATTERN = /(?:\b|\()(?:EACCES|EPERM|EROFS)(?::\s|\))/;
4237
+ function defaultErrorCodeForFailure(data) {
4238
+ if (data.Result === RESULTS.Failure) {
4239
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
4240
+ const errorCode = defaultErrorCodeForHttpStatus(status);
4241
+ if (errorCode)
4242
+ return errorCode;
4243
+ if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
4244
+ return "local_permission_denied";
4245
+ }
4246
+ }
4247
+ return defaultErrorCodeForResult(data.Result);
4248
+ }
4249
+ function defaultRetryForErrorCode(errorCode) {
4250
+ switch (errorCode) {
4251
+ case "network_error":
4252
+ case "rate_limited":
4253
+ case "server_error":
4254
+ case "timeout":
4255
+ return "RetryLater";
4256
+ default:
4257
+ return "RetryWillNotFix";
4258
+ }
4259
+ }
4260
+ var OutputFormatter;
4261
+ ((OutputFormatter) => {
4262
+ function success(data, options) {
4263
+ data.Log ??= getLogFilePath() || undefined;
4264
+ const normalize = options?.preserveDataKeys !== true;
4265
+ const verbatim = toVerbatimKeySet(options?.preserveDataKeys);
4266
+ const subtrees = verbatim && {
4267
+ refs: new Set,
4268
+ mode: "collect"
4269
+ };
4270
+ if (normalize) {
4271
+ data.Data = normalizeDataKeys(data.Data, verbatim, subtrees);
4272
+ }
4273
+ const filter = getOutputFilter();
4274
+ if (filter) {
4275
+ const filtered = applyFilter(data.Data, filter);
4276
+ data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
4277
+ }
4278
+ logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4279
+ }
4280
+ OutputFormatter.success = success;
4281
+ function error(data) {
4282
+ data.Log ??= getLogFilePath() || undefined;
4283
+ data.ErrorCode ??= defaultErrorCodeForFailure(data);
4284
+ data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
4285
+ const exitCode = EXIT_CODES[data.Result] ?? 1;
4286
+ setExitCode(exitCode);
4287
+ recordCommandFailureTelemetry({
4288
+ result: data.Result,
4289
+ errorCode: data.ErrorCode,
4290
+ retry: data.Retry,
4291
+ message: data.Message,
4292
+ context: data.Context,
4293
+ exitCode,
4294
+ errorClass: data.TelemetryErrorClass,
4295
+ terminalOutcome: data.TelemetryTerminalOutcome,
4296
+ terminalSignal: data.TelemetryTerminalSignal
4297
+ });
4298
+ const suppressTelemetry = data.SuppressTelemetry === true;
4299
+ const envelope = { ...data };
4300
+ delete envelope.SuppressTelemetry;
4301
+ delete envelope.TelemetryErrorClass;
4302
+ delete envelope.TelemetryTerminalOutcome;
4303
+ delete envelope.TelemetryTerminalSignal;
4304
+ if (!suppressTelemetry) {
4305
+ telemetry.trackEvent(CommonTelemetryEvents.Error, {
4306
+ result: data.Result,
4307
+ errorCode: data.ErrorCode,
4308
+ retry: data.Retry,
4309
+ message: data.Message
4310
+ });
4311
+ }
4312
+ logOutput(normalizeOutputKeys(envelope), getOutputFormat());
4313
+ }
4314
+ OutputFormatter.error = error;
4315
+ function emitList(code, items, opts) {
4316
+ const data = {
4317
+ Result: RESULTS.Success,
4318
+ Code: code,
4319
+ Data: items
4320
+ };
4321
+ if (items.length === 0 && opts?.emptyInstructions) {
4322
+ data.Instructions = opts.emptyInstructions;
4323
+ }
4324
+ if (opts?.warning) {
4325
+ data.Warning = opts.warning;
4326
+ }
4327
+ if (opts?.pagination) {
4328
+ data.Pagination = opts.pagination;
4329
+ }
4330
+ success(data);
4331
+ }
4332
+ OutputFormatter.emitList = emitList;
4333
+ function log(data) {
4334
+ const format = getOutputFormat();
4335
+ const sink = getOutputSink();
4336
+ const normalized = toPascalCaseData(data);
4337
+ if (format === "json") {
4338
+ const json = JSON.stringify(normalized);
4339
+ const safe = needsAsciiSafeJson(sink) ? escapeNonAscii(json) : json;
4340
+ sink.writeErr(`${safe}
4341
+ `);
4342
+ } else {
4343
+ for (const [key, value] of Object.entries(normalized)) {
4344
+ sink.writeErr(`${key}: ${value}
4345
+ `);
4346
+ }
4058
4347
  }
4059
4348
  }
4060
- const header = keys.map((key, i) => key.padEnd(finalWidths[i])).join(" | ");
4061
- logFn(header);
4062
- logFn(keys.map((_, i) => "-".repeat(finalWidths[i])).join("-|-"));
4063
- data.forEach((item) => {
4064
- const cellLines = keys.map((key, i) => wrapText(cellToString(item[key]), finalWidths[i]));
4065
- const lineCount = Math.max(...cellLines.map((l) => l.length));
4066
- for (let line = 0;line < lineCount; line++) {
4067
- const row = keys.map((_, i) => {
4068
- const val = line < cellLines[i].length ? cellLines[i][line] : "";
4069
- return val.padEnd(finalWidths[i]);
4070
- }).join(" | ");
4071
- logFn(row);
4349
+ OutputFormatter.log = log;
4350
+ function formatToString(data) {
4351
+ const filter = getOutputFilter();
4352
+ if ("Data" in data && data.Data != null) {
4353
+ data.Data = normalizeDataKeys(data.Data);
4354
+ if (filter) {
4355
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
4356
+ }
4072
4357
  }
4073
- });
4074
- if (externalLogValue) {
4075
- logFn("");
4076
- logFn(`Log: ${externalLogValue}`);
4358
+ const output = normalizeOutputKeys(data);
4359
+ const lines = [];
4360
+ const sink = getOutputSink();
4361
+ printOutput(output, getOutputFormat(), (msg) => {
4362
+ lines.push(msg);
4363
+ }, needsAsciiSafeJson(sink));
4364
+ return lines.join(`
4365
+ `);
4077
4366
  }
4367
+ OutputFormatter.formatToString = formatToString;
4368
+ })(OutputFormatter ||= {});
4369
+
4370
+ // ../../node_modules/commander/esm.mjs
4371
+ var import__ = __toESM(require_commander(), 1);
4372
+ var {
4373
+ program,
4374
+ createCommand,
4375
+ createArgument,
4376
+ createOption,
4377
+ CommanderError,
4378
+ InvalidArgumentError,
4379
+ InvalidOptionArgumentError,
4380
+ Command,
4381
+ Argument,
4382
+ Option,
4383
+ Help
4384
+ } = import__.default;
4385
+
4386
+ // ../common/src/preview.ts
4387
+ var previewSlot = singleton("PreviewBuild");
4388
+ function isPreviewBuild() {
4389
+ return previewSlot.get(false) ?? false;
4078
4390
  }
4079
- function toYaml(data) {
4080
- const codec = getYamlCodec();
4081
- if (!codec) {
4082
- throw new Error("YAML output requested before the YAML codec was loaded. " + "Call loadOutputCodecsAsync({ yaml: true }) first.");
4391
+ Command.prototype.previewCommand = function(nameAndArgs, opts) {
4392
+ if (isPreviewBuild()) {
4393
+ return this.command(nameAndArgs, opts);
4083
4394
  }
4084
- return codec.dump(data);
4395
+ return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
4396
+ };
4397
+
4398
+ // ../common/src/content-hash.ts
4399
+ function isBrowserRuntime() {
4400
+ const runtime = globalThis;
4401
+ return typeof runtime.window !== "undefined" && typeof runtime.document !== "undefined";
4085
4402
  }
4086
- function requireJmespath() {
4087
- const codec = getJmespathCodec();
4088
- if (!codec) {
4089
- throw new Error("An --output-filter was applied before the JMESPath codec was loaded. " + "Call loadOutputCodecsAsync({ filter: true }) first.");
4403
+ async function hashContent(content) {
4404
+ const encoder = new TextEncoder;
4405
+ const bytes = encoder.encode(content);
4406
+ if (globalThis.crypto?.subtle) {
4407
+ const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
4408
+ return Array.from(new Uint8Array(digest2), (byte) => byte.toString(16).padStart(2, "0")).join("");
4090
4409
  }
4091
- return codec;
4410
+ if (!isBrowserRuntime()) {
4411
+ const crypto2 = await import("node:crypto");
4412
+ return crypto2.createHash("sha256").update(content, "utf-8").digest("hex");
4413
+ }
4414
+ throw new Error("Unable to compute SHA-256 hash in this environment.");
4092
4415
  }
4093
4416
 
4094
- class FilterEvaluationError extends Error {
4095
- __brand = "FilterEvaluationError";
4096
- filter;
4097
- errorCode = "invalid_argument";
4098
- instructions;
4099
- retry = "RetryWillNotFix";
4100
- result = RESULTS.ValidationError;
4101
- constructor(filter, cause) {
4102
- const underlying = cause instanceof Error ? cause.message : String(cause);
4103
- super(`Filter '${filter}' failed to evaluate: ${underlying}`);
4104
- this.name = "FilterEvaluationError";
4105
- this.filter = filter;
4106
- this.instructions = `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
4417
+ // ../common/src/package-metadata-options.ts
4418
+ function registerPackageMetadataOptions(command) {
4419
+ return command.option("--author <author>", "Package author").option("--description <text>", "Package description").option("--repository-url <url>", "Source repository URL (recorded in the package for traceability)").option("--repository-commit <sha>", "Source repository commit hash (recorded in the package for traceability)").option("--repository-branch <branch>", "Source repository branch").option("--repository-type <type>", "Source repository type (defaults to 'git' when --repository-url is set)").option("--release-notes <text>", "Release notes for the package").option("--project-url <url>", "Automation Hub idea URL");
4420
+ }
4421
+ function mapPackageMetadataOptions(opts) {
4422
+ const fields = {};
4423
+ if (opts.author !== undefined)
4424
+ fields.author = opts.author;
4425
+ if (opts.description !== undefined)
4426
+ fields.description = opts.description;
4427
+ if (opts.releaseNotes !== undefined)
4428
+ fields.releaseNotes = opts.releaseNotes;
4429
+ if (opts.projectUrl !== undefined)
4430
+ fields.projectUrl = opts.projectUrl;
4431
+ if (opts.repositoryUrl !== undefined)
4432
+ fields.repositoryUrl = opts.repositoryUrl;
4433
+ if (opts.repositoryCommit !== undefined)
4434
+ fields.repositoryCommit = opts.repositoryCommit;
4435
+ if (opts.repositoryBranch !== undefined)
4436
+ fields.repositoryBranch = opts.repositoryBranch;
4437
+ if (opts.repositoryType !== undefined)
4438
+ fields.repositoryType = opts.repositoryType;
4439
+ if (fields.repositoryUrl !== undefined && fields.repositoryType === undefined) {
4440
+ fields.repositoryType = "git";
4107
4441
  }
4442
+ return fields;
4108
4443
  }
4109
4444
 
4110
- class FilterImplicitLimitError extends Error {
4111
- __brand = "FilterImplicitLimitError";
4112
- errorCode = "invalid_argument";
4113
- instructions;
4114
- retry = "RetryWillNotFix";
4115
- result = RESULTS.ValidationError;
4116
- constructor(defaultLimit) {
4117
- super(`--output-filter requires an explicit --limit: this command defaults to --limit ${defaultLimit}, ` + `so the filter would silently apply to only the first ${defaultLimit} records.`);
4118
- this.name = "FilterImplicitLimitError";
4119
- this.instructions = "Pass --limit <n> to choose how many records the filter applies to. " + "To filter over all records, pass the command's maximum accepted --limit (see the option's description in --help).";
4445
+ // ../common/src/stdin.ts
4446
+ async function readStdin() {
4447
+ if (process.stdin.isTTY) {
4448
+ return null;
4120
4449
  }
4450
+ return new Promise((resolve, reject) => {
4451
+ let data = "";
4452
+ process.stdin.setEncoding("utf8");
4453
+ process.stdin.on("data", (chunk) => {
4454
+ data += chunk;
4455
+ });
4456
+ process.stdin.on("end", () => resolve(data.trim() || null));
4457
+ process.stdin.on("error", reject);
4458
+ });
4121
4459
  }
4122
- function applyFilter(data, filter) {
4123
- const codec = requireJmespath();
4124
- let result;
4125
- try {
4126
- result = codec.search(data, filter);
4127
- } catch (err) {
4128
- throw new FilterEvaluationError(filter, err);
4460
+
4461
+ // ../common/src/error-handler.ts
4462
+ var DEFAULT_401 = "Unauthorized (401). Run `uip login` to authenticate.";
4463
+ var DEFAULT_403 = "Forbidden (403). Ensure the account has the required permissions.";
4464
+ var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
4465
+ var DEFAULT_413 = "Payload too large (413). The upload exceeded the server or CDN size limit. Reduce the package size — for example, exclude unused dependencies or remove large files from the project — and try again.";
4466
+ var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
4467
+ var NETWORK_ERROR_CODES = new Set([
4468
+ "ECONNREFUSED",
4469
+ "ECONNRESET",
4470
+ "ENOTFOUND",
4471
+ "EAI_AGAIN",
4472
+ "ETIMEDOUT",
4473
+ "EPIPE",
4474
+ "EHOSTUNREACH",
4475
+ "ENETUNREACH",
4476
+ "EAI_FAIL"
4477
+ ]);
4478
+ var TLS_ERROR_CODES2 = new Set([
4479
+ "SELF_SIGNED_CERT_IN_CHAIN",
4480
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
4481
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
4482
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
4483
+ "UNABLE_TO_GET_ISSUER_CERT",
4484
+ "CERT_HAS_EXPIRED",
4485
+ "CERT_UNTRUSTED",
4486
+ "ERR_TLS_CERT_ALTNAME_INVALID"
4487
+ ]);
4488
+ var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
4489
+ var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
4490
+ var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
4491
+ var LOCAL_PERMISSION_MESSAGE_PATTERN = /\b(EACCES|EPERM|EROFS)\b/;
4492
+ function localPermissionInstructions(code, path) {
4493
+ const target = path !== undefined ? `'${path}'` : "a local file or resource";
4494
+ if (code === "EROFS") {
4495
+ return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
4129
4496
  }
4130
- if (result == null)
4131
- return [];
4132
- if (Array.isArray(result)) {
4133
- if (result.length > 0 && typeof result[0] !== "object") {
4134
- const fieldMatch = filter.match(/\.(\w+)$/);
4135
- const key = fieldMatch ? fieldMatch[1] : "Value";
4136
- return result.map((v) => ({ [key]: v }));
4497
+ const remedy = process.platform === "win32" ? "Re-run from an elevated terminal, close any program holding " + "the file open, or grant your user access to the path." : "Grant this user (or the sandbox the command runs in) access " + "to the path, or run the command outside the sandbox.";
4498
+ return `The operating system denied access to ${target} (${code}). This is ` + "a local permission problem, not a UiPath service error — retrying " + `without a permission change will not help. ${remedy}`;
4499
+ }
4500
+ function describeConnectivityError(error) {
4501
+ for (const cur of walkErrorGraph(error)) {
4502
+ const code = typeof cur.code === "string" ? cur.code : undefined;
4503
+ const message = typeof cur.message === "string" ? cur.message : undefined;
4504
+ if (code && TLS_ERROR_CODES2.has(code)) {
4505
+ return {
4506
+ code,
4507
+ kind: "tls",
4508
+ message: message ?? code,
4509
+ instructions: TLS_INSTRUCTIONS
4510
+ };
4137
4511
  }
4138
- return result;
4512
+ if (code && NETWORK_ERROR_CODES.has(code)) {
4513
+ return {
4514
+ code,
4515
+ kind: "network",
4516
+ message: message ?? code,
4517
+ instructions: NETWORK_INSTRUCTIONS
4518
+ };
4519
+ }
4520
+ }
4521
+ return;
4522
+ }
4523
+ function describePermissionError(error) {
4524
+ for (const cur of walkErrorGraph(error)) {
4525
+ const message = typeof cur.message === "string" ? cur.message : undefined;
4526
+ const code = matchLocalPermissionCode(cur.code, message);
4527
+ if (!code)
4528
+ continue;
4529
+ const path = localPermissionPath(cur.path, message);
4530
+ return {
4531
+ code,
4532
+ message: message ?? code,
4533
+ ...path !== undefined ? { path } : {},
4534
+ instructions: localPermissionInstructions(code, path)
4535
+ };
4139
4536
  }
4140
- if (typeof result === "object")
4141
- return result;
4142
- return { Value: result };
4537
+ return;
4143
4538
  }
4144
- function defaultErrorCodeForResult(result) {
4145
- switch (result) {
4146
- case RESULTS.AuthenticationError:
4147
- return "authentication_required";
4148
- case RESULTS.ConfigError:
4149
- return "configuration_error";
4150
- case RESULTS.ValidationError:
4151
- return "invalid_argument";
4152
- case RESULTS.TimeoutError:
4153
- return "timeout";
4154
- default:
4155
- return "unknown_error";
4539
+ function matchLocalPermissionCode(code, message) {
4540
+ if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
4541
+ return code;
4542
+ }
4543
+ const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
4544
+ return match ? match[1] : undefined;
4545
+ }
4546
+ function localPermissionPath(path, message) {
4547
+ if (typeof path === "string")
4548
+ return path;
4549
+ return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
4550
+ }
4551
+ function* walkErrorGraph(error) {
4552
+ const queue = [error];
4553
+ const seen = new Set;
4554
+ for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
4555
+ const current = queue.shift();
4556
+ if (current === null || typeof current !== "object")
4557
+ continue;
4558
+ if (seen.has(current))
4559
+ continue;
4560
+ seen.add(current);
4561
+ const cur = current;
4562
+ yield cur;
4563
+ if (cur.cause !== undefined)
4564
+ queue.push(cur.cause);
4565
+ if (Array.isArray(cur.errors))
4566
+ queue.push(...cur.errors);
4156
4567
  }
4568
+ return;
4157
4569
  }
4158
4570
  function parseHttpStatusFromMessage2(message) {
4159
4571
  const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
@@ -4162,156 +4574,280 @@ function parseHttpStatusFromMessage2(message) {
4162
4574
  const status = Number(match[1]);
4163
4575
  return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
4164
4576
  }
4165
- function defaultErrorCodeForHttpStatus(status) {
4166
- if (status === undefined)
4167
- return;
4168
- if (status === 400 || status === 409 || status === 422) {
4169
- return "invalid_argument";
4577
+ function isHtmlDocument(body) {
4578
+ return /^\s*(<!doctype html|<html\b)/i.test(body);
4579
+ }
4580
+ function retryHintForRetryAfter(seconds) {
4581
+ if (seconds <= 1) {
4582
+ return "RetryAfter1Second";
4170
4583
  }
4171
- if (status === 401)
4172
- return "authentication_required";
4173
- if (status === 403)
4174
- return "permission_denied";
4175
- if (status === 404)
4176
- return "not_found";
4177
- if (status === 405)
4178
- return "method_not_allowed";
4179
- if (status === 408)
4180
- return "timeout";
4181
- if (status === 429)
4182
- return "rate_limited";
4183
- if (status >= 500 && status < 600)
4184
- return "server_error";
4185
- return;
4584
+ if (seconds <= 10) {
4585
+ return "RetryAfter10Seconds";
4586
+ }
4587
+ if (seconds <= 30) {
4588
+ return "RetryAfter30Seconds";
4589
+ }
4590
+ return "RetryAfter60Seconds";
4186
4591
  }
4187
- var LOCAL_PERMISSION_TEXT_PATTERN = /(?:\b|\()(?:EACCES|EPERM|EROFS)(?::\s|\))/;
4188
- function defaultErrorCodeForFailure(data) {
4189
- if (data.Result === RESULTS.Failure) {
4190
- const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
4191
- const errorCode = defaultErrorCodeForHttpStatus(status);
4192
- if (errorCode)
4193
- return errorCode;
4194
- if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
4195
- return "local_permission_denied";
4196
- }
4592
+ function classifyError2(status, error) {
4593
+ if (status === 400 || status === 409 || status === 422) {
4594
+ return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
4197
4595
  }
4198
- return defaultErrorCodeForResult(data.Result);
4596
+ if (status === 401) {
4597
+ return {
4598
+ errorCode: "authentication_required",
4599
+ retry: "RetryWillNotFix"
4600
+ };
4601
+ }
4602
+ if (status === 403) {
4603
+ return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
4604
+ }
4605
+ if (status === 404) {
4606
+ return { errorCode: "not_found", retry: "RetryWillNotFix" };
4607
+ }
4608
+ if (status === 405) {
4609
+ return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
4610
+ }
4611
+ if (status === 413) {
4612
+ return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
4613
+ }
4614
+ if (status === 408) {
4615
+ return { errorCode: "timeout", retry: "RetryLater" };
4616
+ }
4617
+ if (status === 429) {
4618
+ return { errorCode: "rate_limited", retry: "RetryLater" };
4619
+ }
4620
+ if (status !== undefined && status >= 500 && status < 600) {
4621
+ return { errorCode: "server_error", retry: "RetryLater" };
4622
+ }
4623
+ if (status === undefined && describePermissionError(error)) {
4624
+ return {
4625
+ errorCode: "local_permission_denied",
4626
+ retry: "RetryWillNotFix"
4627
+ };
4628
+ }
4629
+ const connectivity = describeConnectivityError(error);
4630
+ if (connectivity) {
4631
+ return {
4632
+ errorCode: "network_error",
4633
+ retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
4634
+ };
4635
+ }
4636
+ return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
4199
4637
  }
4200
- function defaultRetryForErrorCode(errorCode) {
4201
- switch (errorCode) {
4202
- case "network_error":
4203
- case "rate_limited":
4204
- case "server_error":
4205
- case "timeout":
4206
- return "RetryLater";
4207
- default:
4208
- return "RetryWillNotFix";
4638
+ function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
4639
+ if (extractedMessage) {
4640
+ return `HTTP ${status}: ${extractedMessage}`;
4209
4641
  }
4642
+ return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
4210
4643
  }
4211
- var OutputFormatter;
4212
- ((OutputFormatter) => {
4213
- function success(data, options) {
4214
- data.Log ??= getLogFilePath() || undefined;
4215
- const normalize = !options?.preserveDataKeys;
4216
- if (normalize) {
4217
- data.Data = normalizeDataKeys(data.Data);
4218
- }
4219
- const filter = getOutputFilter();
4220
- if (filter) {
4221
- const filtered = applyFilter(data.Data, filter);
4222
- data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
4644
+ async function extractErrorDetails(error, options) {
4645
+ const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
4646
+ const response = err.response;
4647
+ const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
4648
+ const explicitStatus = err.status ?? response?.status;
4649
+ const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage2(rawMessage) : undefined;
4650
+ const status = explicitStatus ?? inferredStatus;
4651
+ const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
4652
+ let rawBody;
4653
+ let extractedMessage;
4654
+ let parsedBody;
4655
+ const textFn = response?.text?.bind(response);
4656
+ if (textFn) {
4657
+ const [bodyError, body] = await catchError((async () => textFn())());
4658
+ if (!bodyError && body) {
4659
+ rawBody = body;
4660
+ const [parseError, parsed] = catchError(() => JSON.parse(body));
4661
+ if (!parseError && parsed && typeof parsed === "object") {
4662
+ parsedBody = parsed;
4663
+ if (parsedBody.errors && typeof parsedBody.errors === "object") {
4664
+ for (const field of Object.values(parsedBody.errors)) {
4665
+ if (Array.isArray(field) && field.length > 0) {
4666
+ const first = field[0];
4667
+ if (first && typeof first.message === "string") {
4668
+ extractedMessage = first.message;
4669
+ break;
4670
+ }
4671
+ }
4672
+ }
4673
+ }
4674
+ if (!extractedMessage) {
4675
+ extractedMessage = typeof parsedBody.message === "string" ? parsedBody.message : typeof parsedBody.errorMessage === "string" ? parsedBody.errorMessage : typeof parsedBody.title === "string" ? parsedBody.title : undefined;
4676
+ }
4677
+ if (!extractedMessage) {
4678
+ extractedMessage = body;
4679
+ }
4680
+ if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
4681
+ extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
4682
+ }
4683
+ } else {
4684
+ extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
4685
+ }
4223
4686
  }
4224
- logOutput(normalizeOutputKeys(data), getOutputFormat());
4225
4687
  }
4226
- OutputFormatter.success = success;
4227
- function error(data) {
4228
- data.Log ??= getLogFilePath() || undefined;
4229
- data.ErrorCode ??= defaultErrorCodeForFailure(data);
4230
- data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
4231
- process.exitCode = EXIT_CODES[data.Result] ?? 1;
4232
- recordCommandFailureTelemetry({
4233
- result: data.Result,
4234
- errorCode: data.ErrorCode,
4235
- retry: data.Retry,
4236
- message: data.Message,
4237
- context: data.Context,
4238
- exitCode: process.exitCode,
4239
- errorClass: data.TelemetryErrorClass,
4240
- terminalOutcome: data.TelemetryTerminalOutcome,
4241
- terminalSignal: data.TelemetryTerminalSignal
4242
- });
4243
- const suppressTelemetry = data.SuppressTelemetry === true;
4244
- const envelope = { ...data };
4245
- delete envelope.SuppressTelemetry;
4246
- delete envelope.TelemetryErrorClass;
4247
- delete envelope.TelemetryTerminalOutcome;
4248
- delete envelope.TelemetryTerminalSignal;
4249
- if (!suppressTelemetry) {
4250
- telemetry.trackEvent(CommonTelemetryEvents.Error, {
4251
- result: data.Result,
4252
- errorCode: data.ErrorCode,
4253
- retry: data.Retry,
4254
- message: data.Message
4255
- });
4688
+ let message;
4689
+ let result = "Failure";
4690
+ const classification = classifyError2(status, error);
4691
+ let retry = classification.retry;
4692
+ if (status === 401) {
4693
+ message = DEFAULT_401;
4694
+ result = "AuthenticationError";
4695
+ } else if (status === 403) {
4696
+ message = options?.forbiddenMessage ?? DEFAULT_403;
4697
+ result = "AuthenticationError";
4698
+ } else if (status === 405) {
4699
+ message = DEFAULT_405;
4700
+ } else if (status === 413) {
4701
+ message = DEFAULT_413;
4702
+ } else if (status === 400 || status === 422) {
4703
+ message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
4704
+ result = "ValidationError";
4705
+ } else if (status === 429) {
4706
+ message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
4707
+ } else if (extractedMessage) {
4708
+ if (isSuccessfulResponse && rawMessage !== "Unknown error") {
4709
+ message = rawMessage;
4710
+ } else {
4711
+ message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
4712
+ }
4713
+ } else if (status) {
4714
+ if (inferredStatus !== undefined) {
4715
+ message = rawMessage;
4716
+ } else if (rawMessage === "Unknown error" && response) {
4717
+ const statusText = response.statusText;
4718
+ message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
4719
+ } else {
4720
+ message = `HTTP ${status}: ${rawMessage}`;
4256
4721
  }
4257
- logOutput(normalizeOutputKeys(envelope), getOutputFormat());
4722
+ } else {
4723
+ message = rawMessage;
4258
4724
  }
4259
- OutputFormatter.error = error;
4260
- function emitList(code, items, opts) {
4261
- const data = {
4262
- Result: RESULTS.Success,
4263
- Code: code,
4264
- Data: items
4265
- };
4266
- if (items.length === 0 && opts?.emptyInstructions) {
4267
- data.Instructions = opts.emptyInstructions;
4725
+ if (status === undefined) {
4726
+ const connectivity = describeConnectivityError(error);
4727
+ if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
4728
+ message = `${message}: ${connectivity.message}`;
4268
4729
  }
4269
- if (opts?.warning) {
4270
- data.Warning = opts.warning;
4730
+ }
4731
+ const permission = status === undefined ? describePermissionError(error) : undefined;
4732
+ if (permission) {
4733
+ if (permission.message !== message && !message.includes(permission.message)) {
4734
+ message = `${message}: ${permission.message}`;
4271
4735
  }
4272
- if (opts?.pagination) {
4273
- data.Pagination = opts.pagination;
4736
+ if (!message.includes(permission.instructions)) {
4737
+ const punctuated = message.endsWith(".") ? message : `${message}.`;
4738
+ message = `${punctuated} ${permission.instructions}`;
4274
4739
  }
4275
- success(data);
4276
4740
  }
4277
- OutputFormatter.emitList = emitList;
4278
- function log(data) {
4279
- const format = getOutputFormat();
4280
- const sink = getOutputSink();
4281
- const normalized = toPascalCaseData(data);
4282
- if (format === "json") {
4283
- const json = JSON.stringify(normalized);
4284
- const safe = needsAsciiSafeJson(sink) ? escapeNonAscii(json) : json;
4285
- sink.writeErr(`${safe}
4286
- `);
4741
+ let details = rawMessage;
4742
+ if (rawBody) {
4743
+ if (parsedBody) {
4744
+ const extra = {};
4745
+ if (parsedBody.errorCode)
4746
+ extra.errorCode = parsedBody.errorCode;
4747
+ if (parsedBody.detail)
4748
+ extra.detail = parsedBody.detail;
4749
+ if (parsedBody.details)
4750
+ extra.details = parsedBody.details;
4751
+ if (parsedBody.errors != null)
4752
+ extra.errors = parsedBody.errors;
4753
+ if (parsedBody.data && typeof parsedBody.data === "object" && Object.keys(parsedBody.data).length > 0) {
4754
+ extra.data = parsedBody.data;
4755
+ }
4756
+ details = Object.keys(extra).length > 0 ? JSON.stringify(extra) : rawBody;
4287
4757
  } else {
4288
- for (const [key, value] of Object.entries(normalized)) {
4289
- sink.writeErr(`${key}: ${value}
4290
- `);
4758
+ details = rawBody;
4759
+ }
4760
+ } else if (typeof err.message === "string") {
4761
+ details = err.message;
4762
+ } else {
4763
+ details = describeThrownValue(error);
4764
+ }
4765
+ const context = {};
4766
+ if (status) {
4767
+ context.httpStatus = status;
4768
+ }
4769
+ if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
4770
+ context.errorCode = parsedBody.errorCode;
4771
+ } else if (parsedBody?.code && typeof parsedBody.code === "string") {
4772
+ context.errorCode = parsedBody.code;
4773
+ }
4774
+ if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
4775
+ context.requestId = parsedBody.requestId;
4776
+ }
4777
+ if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
4778
+ context.traceId = parsedBody.traceId;
4779
+ }
4780
+ if (permission?.path !== undefined) {
4781
+ context.path = permission.path;
4782
+ }
4783
+ if (status === 429) {
4784
+ const resp = response;
4785
+ const headersObj = resp?.headers;
4786
+ let retryAfterValue;
4787
+ if (headersObj && typeof headersObj === "object" && typeof headersObj.get === "function") {
4788
+ retryAfterValue = headersObj.get("retry-after") ?? undefined;
4789
+ }
4790
+ if (!retryAfterValue && headersObj && typeof headersObj === "object") {
4791
+ const headers = headersObj;
4792
+ retryAfterValue = headers["retry-after"] ?? headers["Retry-After"];
4793
+ }
4794
+ if (retryAfterValue) {
4795
+ const seconds = Number(retryAfterValue);
4796
+ if (!Number.isNaN(seconds)) {
4797
+ context.retryAfter = seconds;
4798
+ retry = retryHintForRetryAfter(seconds);
4291
4799
  }
4292
4800
  }
4293
4801
  }
4294
- OutputFormatter.log = log;
4295
- function formatToString(data) {
4296
- const filter = getOutputFilter();
4297
- if ("Data" in data && data.Data != null) {
4298
- data.Data = normalizeDataKeys(data.Data);
4299
- if (filter) {
4300
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
4802
+ const hasContext = Object.keys(context).length > 0;
4803
+ let parsedErrors;
4804
+ if (parsedBody?.errors && typeof parsedBody.errors === "object") {
4805
+ const errors = {};
4806
+ for (const [field, raw] of Object.entries(parsedBody.errors)) {
4807
+ if (Array.isArray(raw)) {
4808
+ const messages = raw.map((entry) => {
4809
+ if (typeof entry === "string")
4810
+ return entry;
4811
+ if (entry && typeof entry === "object" && typeof entry.message === "string") {
4812
+ return entry.message;
4813
+ }
4814
+ return String(entry);
4815
+ }).filter(Boolean);
4816
+ if (messages.length > 0)
4817
+ errors[field] = messages;
4818
+ } else if (typeof raw === "string") {
4819
+ errors[field] = [raw];
4301
4820
  }
4302
4821
  }
4303
- const output = normalizeOutputKeys(data);
4304
- const lines = [];
4305
- const sink = getOutputSink();
4306
- printOutput(output, getOutputFormat(), (msg) => {
4307
- lines.push(msg);
4308
- }, needsAsciiSafeJson(sink));
4309
- return lines.join(`
4310
- `);
4822
+ if (Object.keys(errors).length > 0)
4823
+ parsedErrors = errors;
4311
4824
  }
4312
- OutputFormatter.formatToString = formatToString;
4313
- })(OutputFormatter ||= {});
4314
-
4825
+ return {
4826
+ result,
4827
+ errorCode: classification.errorCode,
4828
+ message,
4829
+ retry,
4830
+ details,
4831
+ ...hasContext ? { context } : {},
4832
+ ...parsedErrors ? { parsedErrors } : {}
4833
+ };
4834
+ }
4835
+ async function extractErrorMessage(error, options) {
4836
+ const { message } = await extractErrorDetails(error, options);
4837
+ return message;
4838
+ }
4839
+ // ../common/src/classified-failure.ts
4840
+ var MAX_QUOTED_BODY_CHARS = 200;
4841
+ function summarizePlatformBody(body) {
4842
+ const trimmed = body.trim().replace(/\s+/g, " ");
4843
+ return trimmed.length > MAX_QUOTED_BODY_CHARS ? `${trimmed.slice(0, MAX_QUOTED_BODY_CHARS)}…` : trimmed;
4844
+ }
4845
+ // ../common/src/command-examples.ts
4846
+ var examplesByCommand = new WeakMap;
4847
+ Command.prototype.examples = function(examples) {
4848
+ examplesByCommand.set(this, examples);
4849
+ return this;
4850
+ };
4315
4851
  // ../common/src/telemetry/command-attribution.ts
4316
4852
  var LEGACY_SKILL_NAMESPACE = "uipath:";
4317
4853
  var MAX_SKILL_NAME_LENGTH = 80;
@@ -4465,6 +5001,57 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
4465
5001
  };
4466
5002
  }
4467
5003
 
5004
+ // ../common/src/telemetry/command-name.ts
5005
+ var TELEMETRY_COMMAND_ROOT = "uip";
5006
+ function commandTelemetryName(parts) {
5007
+ const tokens = [];
5008
+ for (const part of parts) {
5009
+ const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== TELEMETRY_COMMAND_ROOT);
5010
+ if (pieces.every(isCommandToken)) {
5011
+ tokens.push(...pieces);
5012
+ continue;
5013
+ }
5014
+ tokens.push(UNKNOWN_TOKEN);
5015
+ }
5016
+ return [TELEMETRY_COMMAND_ROOT, ...tokens].join(".");
5017
+ }
5018
+ var COMMAND_TOKEN_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
5019
+ var MAX_COMMAND_TOKEN_LENGTH = 32;
5020
+ var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
5021
+ function isCommandToken(token) {
5022
+ return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token) && !/^\d+$/.test(token);
5023
+ }
5024
+ var UNKNOWN_TOKEN = "<unknown>";
5025
+
5026
+ // ../common/src/telemetry/invocation-request.ts
5027
+ var requestContextSlot = singleton("TelemetryInvocationRequestContext");
5028
+ function activeContext() {
5029
+ return telemetry.getActiveContext?.();
5030
+ }
5031
+ function runWithInvocationRequest(fn) {
5032
+ const context = telemetry.createRequestContext();
5033
+ context.startedAt = invocationStartedAt();
5034
+ requestContextSlot.set(context);
5035
+ return telemetry.runWithContext(context, fn);
5036
+ }
5037
+ function ensureInvocationRequestScope(fn) {
5038
+ if (activeContext() !== undefined) {
5039
+ return fn();
5040
+ }
5041
+ const kept = requestContextSlot.get();
5042
+ return kept === undefined ? runWithInvocationRequest(fn) : telemetry.runWithContext(kept, fn);
5043
+ }
5044
+ function getInvocationRequestContext() {
5045
+ return activeContext() ?? requestContextSlot.get();
5046
+ }
5047
+ function emitInvocationRequest(name, success, properties) {
5048
+ const context = getInvocationRequestContext();
5049
+ telemetry.trackRequestResult(name, invocationElapsedMs(), success, properties, context);
5050
+ if (context !== undefined && requestContextSlot.get() === context) {
5051
+ requestContextSlot.clear();
5052
+ }
5053
+ }
5054
+
4468
5055
  // ../common/src/trackedAction.ts
4469
5056
  var pollSignalSlot = singleton("PollSignal");
4470
5057
  var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
@@ -4472,28 +5059,74 @@ var retryHintValues = new Set(RETRY_HINTS);
4472
5059
  var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
4473
5060
  var processContext = {
4474
5061
  exit: (code) => {
4475
- process.exitCode = code;
5062
+ recordExitCode(code);
5063
+ setExitCode(code);
4476
5064
  },
4477
5065
  get pollSignal() {
4478
5066
  return pollSignalSlot.get();
4479
5067
  }
4480
5068
  };
5069
+ var TELEMETRY_ARG_VALUE_WITHHELD = "<provided>";
5070
+ var TELEMETRY_ARG_VALUE_DEFAULTED = "<default>";
5071
+ function recordableArgValue(value, choices) {
5072
+ if (typeof value === "boolean" || typeof value === "number") {
5073
+ return value;
5074
+ }
5075
+ if (choices && choices.length > 0) {
5076
+ if (typeof value === "string" && choices.includes(value)) {
5077
+ return value;
5078
+ }
5079
+ if (Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string" && choices.includes(entry))) {
5080
+ return value.join(",");
5081
+ }
5082
+ }
5083
+ return TELEMETRY_ARG_VALUE_WITHHELD;
5084
+ }
4481
5085
  function extractCommandParams(cmd) {
4482
5086
  const params = {};
4483
- const add = (name, value) => {
4484
- if (name && value !== undefined) {
4485
- params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = value;
4486
- }
4487
- };
5087
+ forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
5088
+ const recordable = recordableArgValue(value, choices);
5089
+ params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
5090
+ });
5091
+ return params;
5092
+ }
5093
+ function isDefaultedOption(cmd, name) {
5094
+ const source = cmd.getOptionValueSource?.(name);
5095
+ return source === "default" || source === "implied";
5096
+ }
5097
+ function isDefaultedPositional(cmd, index) {
5098
+ return index >= (cmd.args?.length ?? 0);
5099
+ }
5100
+ function forEachSuppliedArgument(cmd, visit) {
4488
5101
  const registered = cmd.registeredArguments ?? [];
4489
5102
  const processed = cmd.processedArgs ?? [];
4490
5103
  for (let i = 0;i < registered.length; i++) {
4491
- add(registered[i].name(), processed[i]);
5104
+ const name = registered[i].name();
5105
+ if (name && processed[i] !== undefined) {
5106
+ visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
5107
+ }
5108
+ }
5109
+ const choicesByAttribute = new Map;
5110
+ for (const option of cmd.options) {
5111
+ choicesByAttribute.set(option.attributeName(), option.argChoices);
4492
5112
  }
4493
5113
  for (const [key, value] of Object.entries(cmd.opts())) {
4494
- add(key, value);
5114
+ if (key && value !== undefined) {
5115
+ visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
5116
+ }
4495
5117
  }
4496
- return params;
5118
+ }
5119
+ function withheldArgumentValues(cmd) {
5120
+ const values = [];
5121
+ forEachSuppliedArgument(cmd, (_name, value, choices, defaulted) => {
5122
+ if (defaulted) {
5123
+ return;
5124
+ }
5125
+ if (recordableArgValue(value, choices) === TELEMETRY_ARG_VALUE_WITHHELD) {
5126
+ values.push(value);
5127
+ }
5128
+ });
5129
+ return values;
4497
5130
  }
4498
5131
  function deriveCommandPath(cmd) {
4499
5132
  const parts = [];
@@ -4508,7 +5141,7 @@ function deriveCommandPath(cmd) {
4508
5141
  if (parts.length > 1) {
4509
5142
  parts.shift();
4510
5143
  }
4511
- return ["uip", ...parts.filter((p) => p !== "uip")].join(".");
5144
+ return commandTelemetryName(parts);
4512
5145
  }
4513
5146
  function isCliErrorCode(value) {
4514
5147
  return typeof value === "string" && cliErrorCodeValues.has(value);
@@ -4548,68 +5181,77 @@ Command.prototype.trackedAction = function(context, fn, properties) {
4548
5181
  });
4549
5182
  const telemetryName = deriveCommandPath(command);
4550
5183
  const props = typeof properties === "function" ? properties(...args) : properties;
4551
- const requestContext = telemetry.createRequestContext();
4552
- const startTime = performance.now();
4553
- let errorMessage;
4554
- let fallbackExitCode = EXIT_CODES.Success;
4555
- clearRecordedCommandFailureTelemetry();
4556
- const [error] = await catchError(telemetry.runWithContext(requestContext, () => {
4557
- const violation = implicitLimitViolation(command);
4558
- if (violation) {
4559
- return Promise.reject(violation);
4560
- }
4561
- return fn(...args);
4562
- }));
4563
- if (error) {
4564
- errorMessage = error instanceof Error ? error.message : String(error);
4565
- logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
4566
- const typed = error;
4567
- const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
4568
- const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
4569
- const finalResult = customResult ?? RESULTS.Failure;
4570
- const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
4571
- const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
4572
- const typedRetry = typed.retry ?? typed.Retry;
4573
- const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
4574
- const typedContext = typed.context ?? typed.Context;
4575
- const customContext = isErrorContext(typedContext) ? typedContext : undefined;
4576
- const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
4577
- fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
4578
- OutputFormatter.error({
4579
- Result: finalResult,
4580
- ...customErrorCode ? { ErrorCode: customErrorCode } : {},
4581
- Message: errorMessage,
4582
- Instructions: customInstructions ?? commandHelpHint(telemetryName),
4583
- ...customRetry ? { Retry: customRetry } : {},
4584
- ...customContext ? { Context: customContext } : {}
5184
+ markCommandStart();
5185
+ const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
5186
+ try {
5187
+ const startTime = performance.now();
5188
+ let errorMessage;
5189
+ let fallbackExitCode = EXIT_CODES.Success;
5190
+ clearRecordedCommandFailureTelemetry();
5191
+ const [error] = await catchError(ensureInvocationRequestScope(() => {
5192
+ const violation = implicitLimitViolation(command);
5193
+ if (violation) {
5194
+ return Promise.reject(violation);
5195
+ }
5196
+ return fn(...args);
5197
+ }));
5198
+ if (error) {
5199
+ errorMessage = error instanceof Error ? error.message : String(error);
5200
+ logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
5201
+ const typed = error;
5202
+ const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
5203
+ const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
5204
+ const finalResult = customResult ?? RESULTS.Failure;
5205
+ const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
5206
+ const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
5207
+ const typedRetry = typed.retry ?? typed.Retry;
5208
+ const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
5209
+ const typedContext = typed.context ?? typed.Context;
5210
+ const customContext = isErrorContext(typedContext) ? typedContext : undefined;
5211
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
5212
+ fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
5213
+ OutputFormatter.error({
5214
+ Result: finalResult,
5215
+ ...customErrorCode ? { ErrorCode: customErrorCode } : {},
5216
+ Message: errorMessage,
5217
+ Instructions: customInstructions ?? commandHelpHint(telemetryName),
5218
+ ...customRetry ? { Retry: customRetry } : {},
5219
+ ...customContext ? { Context: customContext } : {}
5220
+ });
5221
+ context.exit(fallbackExitCode);
5222
+ }
5223
+ const durationMs = performance.now() - startTime;
5224
+ recordCommandDuration(durationMs);
5225
+ const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
5226
+ const recordedFailure = takeRecordedCommandFailureTelemetry();
5227
+ const success = !error && exitCode === 0;
5228
+ const terminalTelemetry = buildCommandTerminalTelemetryProperties({
5229
+ error,
5230
+ exitCode,
5231
+ recordedFailure,
5232
+ pollSignal: context.pollSignal
4585
5233
  });
4586
- context.exit(fallbackExitCode);
4587
- }
4588
- const durationMs = performance.now() - startTime;
4589
- const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
4590
- const recordedFailure = takeRecordedCommandFailureTelemetry();
4591
- const success = !error && exitCode === 0;
4592
- const terminalTelemetry = buildCommandTerminalTelemetryProperties({
4593
- error,
4594
- exitCode,
4595
- recordedFailure,
4596
- pollSignal: context.pollSignal
4597
- });
4598
- const commandParams = extractCommandParams(command);
4599
- if (props) {
4600
- for (const key of Object.keys(props)) {
4601
- delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
4602
- }
4603
- }
4604
- const baseProperties = redactProperties({
4605
- ...commandParams,
4606
- ...props,
4607
- ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
4608
- command: "true",
4609
- ...terminalTelemetry,
4610
- ...errorMessage ? { errorMessage } : {}
4611
- });
4612
- telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
5234
+ if (terminalTelemetry.error_class === "internal" && error) {
5235
+ telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { command_name: telemetryName }, getInvocationRequestContext());
5236
+ }
5237
+ const commandParams = extractCommandParams(command);
5238
+ if (props) {
5239
+ for (const key of Object.keys(props)) {
5240
+ delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
5241
+ }
5242
+ }
5243
+ const baseProperties = redactProperties({
5244
+ ...commandParams,
5245
+ ...props,
5246
+ ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
5247
+ command: "true",
5248
+ ...terminalTelemetry,
5249
+ ...errorMessage ? { errorMessage } : {}
5250
+ });
5251
+ emitInvocationRequest(telemetryName, success, baseProperties);
5252
+ } finally {
5253
+ releaseSuppliedArgumentValues(supplied);
5254
+ }
4613
5255
  });
4614
5256
  };
4615
5257
  // ../common/src/completer.ts
@@ -4618,26 +5260,207 @@ var COMPLETER_SYMBOL = Symbol.for("@uipath/common/completer");
4618
5260
  var guardInstalledSlot = singleton("ConsoleGuardInstalled");
4619
5261
  var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
4620
5262
  // ../common/src/constants.ts
5263
+ var UIPATH_HOME_DIR = ".uipath";
4621
5264
  var DEFAULT_PAGE_SIZE = 50;
4622
5265
  var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
4623
- // ../common/src/content-hash.ts
4624
- function isBrowserRuntime() {
4625
- const runtime = globalThis;
4626
- return typeof runtime.window !== "undefined" && typeof runtime.document !== "undefined";
4627
- }
4628
- async function hashContent(content) {
4629
- const encoder = new TextEncoder;
4630
- const bytes = encoder.encode(content);
4631
- if (globalThis.crypto?.subtle) {
4632
- const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
4633
- return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
4634
- }
4635
- if (!isBrowserRuntime()) {
4636
- const crypto2 = await import("node:crypto");
4637
- return crypto2.createHash("sha256").update(content, "utf-8").digest("hex");
4638
- }
4639
- throw new Error("Unable to compute SHA-256 hash in this environment.");
4640
- }
5266
+ // ../common/src/entity-name-rules.ts
5267
+ var RESERVED_SQL_KEYWORDS_LOWER = new Set(["group", "order"]);
5268
+ var RESERVED_FIELD_NAMES_LOWER = new Set([
5269
+ "id",
5270
+ "createdby",
5271
+ "createtime",
5272
+ "updatedby",
5273
+ "updatetime",
5274
+ "recordowner",
5275
+ "version"
5276
+ ]);
5277
+ var RESERVED_KEYWORDS_LOWER = new Set([
5278
+ "abstract",
5279
+ "as",
5280
+ "base",
5281
+ "bool",
5282
+ "break",
5283
+ "byte",
5284
+ "case",
5285
+ "catch",
5286
+ "char",
5287
+ "checked",
5288
+ "class",
5289
+ "const",
5290
+ "continue",
5291
+ "decimal",
5292
+ "default",
5293
+ "delegate",
5294
+ "do",
5295
+ "double",
5296
+ "else",
5297
+ "enum",
5298
+ "event",
5299
+ "explicit",
5300
+ "extern",
5301
+ "false",
5302
+ "finally",
5303
+ "fixed",
5304
+ "float",
5305
+ "for",
5306
+ "foreach",
5307
+ "goto",
5308
+ "if",
5309
+ "implicit",
5310
+ "in",
5311
+ "int",
5312
+ "interface",
5313
+ "internal",
5314
+ "is",
5315
+ "lock",
5316
+ "long",
5317
+ "namespace",
5318
+ "new",
5319
+ "null",
5320
+ "object",
5321
+ "operator",
5322
+ "out",
5323
+ "override",
5324
+ "params",
5325
+ "private",
5326
+ "protected",
5327
+ "public",
5328
+ "readonly",
5329
+ "ref",
5330
+ "return",
5331
+ "sbyte",
5332
+ "sealed",
5333
+ "short",
5334
+ "sizeof",
5335
+ "stackalloc",
5336
+ "static",
5337
+ "string",
5338
+ "struct",
5339
+ "switch",
5340
+ "this",
5341
+ "throw",
5342
+ "true",
5343
+ "try",
5344
+ "typeof",
5345
+ "uint",
5346
+ "ulong",
5347
+ "unchecked",
5348
+ "unsafe",
5349
+ "ushort",
5350
+ "using",
5351
+ "virtual",
5352
+ "void",
5353
+ "volatile",
5354
+ "while",
5355
+ "addhandler",
5356
+ "addressof",
5357
+ "alias",
5358
+ "and",
5359
+ "andalso",
5360
+ "boolean",
5361
+ "byref",
5362
+ "byval",
5363
+ "call",
5364
+ "cbool",
5365
+ "cbyte",
5366
+ "cchar",
5367
+ "cdate",
5368
+ "cdbl",
5369
+ "cdec",
5370
+ "cint",
5371
+ "clng",
5372
+ "cobj",
5373
+ "csbyte",
5374
+ "cshort",
5375
+ "csng",
5376
+ "cstr",
5377
+ "ctype",
5378
+ "cuint",
5379
+ "culng",
5380
+ "cushort",
5381
+ "date",
5382
+ "declare",
5383
+ "dim",
5384
+ "directcast",
5385
+ "each",
5386
+ "elseif",
5387
+ "end",
5388
+ "endif",
5389
+ "erase",
5390
+ "error",
5391
+ "exit",
5392
+ "friend",
5393
+ "function",
5394
+ "get",
5395
+ "gettype",
5396
+ "getxmlnamespace",
5397
+ "global",
5398
+ "gosub",
5399
+ "goto",
5400
+ "handles",
5401
+ "implements",
5402
+ "imports",
5403
+ "inherits",
5404
+ "integer",
5405
+ "isnot",
5406
+ "let",
5407
+ "lib",
5408
+ "like",
5409
+ "loop",
5410
+ "me",
5411
+ "mod",
5412
+ "module",
5413
+ "mustinherit",
5414
+ "mustoverride",
5415
+ "mybase",
5416
+ "myclass",
5417
+ "narrowing",
5418
+ "next",
5419
+ "not",
5420
+ "nothing",
5421
+ "notinheritable",
5422
+ "notoverridable",
5423
+ "of",
5424
+ "on",
5425
+ "option",
5426
+ "optional",
5427
+ "or",
5428
+ "orelse",
5429
+ "overloads",
5430
+ "overridable",
5431
+ "overrides",
5432
+ "paramarray",
5433
+ "partial",
5434
+ "property",
5435
+ "raiseevent",
5436
+ "redim",
5437
+ "rem",
5438
+ "removehandler",
5439
+ "resume",
5440
+ "select",
5441
+ "set",
5442
+ "shadows",
5443
+ "shared",
5444
+ "single",
5445
+ "step",
5446
+ "stop",
5447
+ "structure",
5448
+ "sub",
5449
+ "synclock",
5450
+ "then",
5451
+ "to",
5452
+ "trycast",
5453
+ "uinteger",
5454
+ "ushort",
5455
+ "variant",
5456
+ "wend",
5457
+ "when",
5458
+ "widening",
5459
+ "with",
5460
+ "withevents",
5461
+ "writeonly",
5462
+ "xor"
5463
+ ]);
4641
5464
  // ../common/src/error-instructions.ts
4642
5465
  function extractHttpStatus(err) {
4643
5466
  if (!err || typeof err !== "object")
@@ -4646,7 +5469,7 @@ function extractHttpStatus(err) {
4646
5469
  const structured = e.response?.status ?? e.status ?? e.statusCode;
4647
5470
  if (structured !== undefined)
4648
5471
  return structured;
4649
- return typeof e.message === "string" ? parseHttpStatusFromMessage(e.message) : undefined;
5472
+ return typeof e.message === "string" ? parseHttpStatusFromMessage2(e.message) : undefined;
4650
5473
  }
4651
5474
  var GENERIC = "Check authentication and parameters";
4652
5475
  function instructionsFor(ctx, err) {
@@ -4669,16 +5492,31 @@ function instructionsFor(ctx, err) {
4669
5492
  return "Re-authenticate with 'uip login' — your session is invalid or expired";
4670
5493
  }
4671
5494
  if (status === 403) {
4672
- return "Confirm your user has access to the folder and the required permissions";
5495
+ return "Confirm your user has access to the resource, and the required permissions in this folder or tenant";
4673
5496
  }
4674
5497
  if (status === 404) {
4675
5498
  return "Verify the resource exists in the current folder/tenant";
4676
5499
  }
4677
- if (status === 400) {
5500
+ if (status === 400 || status === 422) {
4678
5501
  return "Request was rejected — check flag values and inputs";
4679
5502
  }
5503
+ if (status === 405) {
5504
+ return "Check the command name and the base URL in use — the endpoint may not exist";
5505
+ }
5506
+ if (status === 408) {
5507
+ return "The request timed out — retry; if it persists, narrow the request (e.g. --limit on list commands)";
5508
+ }
5509
+ if (status === 409) {
5510
+ return "The resource already exists, or changed since it was read — list it to see the current state";
5511
+ }
5512
+ if (status === 413) {
5513
+ return "The upload is over the size limit — exclude unused dependencies or drop large files, then retry";
5514
+ }
5515
+ if (status === 429) {
5516
+ return "Rate limit reached — wait and retry; when the service suggests a delay, Retry and Context.retryAfter carry it";
5517
+ }
4680
5518
  if (status !== undefined && status >= 500 && status < 600) {
4681
- return "Orchestrator returned a server error — retry; if it persists, check service status";
5519
+ return "The service returned a server error — retry; if it persists, check service status";
4682
5520
  }
4683
5521
  const permission = describePermissionError(err);
4684
5522
  if (permission) {
@@ -4878,25 +5716,10 @@ function unsupportedSolutionProjectType(projectType) {
4878
5716
  }
4879
5717
  return projectType.toLowerCase() === "library" ? LIBRARY_NOT_A_PROJECT : null;
4880
5718
  }
4881
- // ../common/src/stdin.ts
4882
- async function readStdin() {
4883
- if (process.stdin.isTTY) {
4884
- return null;
4885
- }
4886
- return new Promise((resolve, reject) => {
4887
- let data = "";
4888
- process.stdin.setEncoding("utf8");
4889
- process.stdin.on("data", (chunk) => {
4890
- data += chunk;
4891
- });
4892
- process.stdin.on("end", () => resolve(data.trim() || null));
4893
- process.stdin.on("error", reject);
4894
- });
4895
- }
4896
5719
  // ../common/src/telemetry/ship-succeeded.ts
4897
5720
  var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
4898
5721
  // ../common/src/tool-provider.ts
4899
5722
  var factorySlot = singleton("PackagerFactoryProvider");
4900
- export { catchError, extractErrorMessage, InvalidArgumentError, Command, Option, isPreviewBuild, logger, getOutputFormat, getOutputFormatExplicit, RESULTS, EXIT_CODES, Pagination, OutputFormatter, processContext, DEFAULT_PAGE_SIZE, hashContent, instructionsFor, isGuid, createHiddenDeprecatedTenantOption, parseLimit, parseOffset, parseBoundedInt, registerPackageMetadataOptions, mapPackageMetadataOptions, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, unsupportedSolutionProjectType, readStdin };
5723
+ export { catchError, extractErrorMessage, logger, getOutputFormat, getOutputFormatExplicit, RESULTS, EXIT_CODES, Pagination, OutputFormatter, summarizePlatformBody, InvalidArgumentError, Command, Option, isPreviewBuild, processContext, UIPATH_HOME_DIR, DEFAULT_PAGE_SIZE, hashContent, instructionsFor, isGuid, createHiddenDeprecatedTenantOption, parseLimit, parseOffset, parseBoundedInt, registerPackageMetadataOptions, mapPackageMetadataOptions, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, unsupportedSolutionProjectType, readStdin };
4901
5724
 
4902
- //# debugId=0588CC9DE89155C064756E2164756E21
5725
+ //# debugId=515DE86CC639634E64756E2164756E21