@uipath/codedagent-tool 1.201.0-preview.132 → 1.202.0-preview.134
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -34
- package/dist/{index-2fj08e7n.js → index-gpd94m28.js} +27 -27
- package/dist/{index-w03qc9m8.js → index-sby22td6.js} +4 -4
- package/dist/index.js +4 -7
- package/dist/init.js +3 -6
- package/dist/{js-yaml-4ypbq2tt.js → js-yaml-b2jq67kn.js} +16 -16
- package/dist/{tool-0v6na3yp.js → tool-1de529jm.js} +9 -7
- package/dist/{tool-bmz9w9hg.js → tool-bd0jh9dt.js} +45 -19
- package/dist/{tool-26zbdsea.js → tool-s19cqcj0.js} +1643 -554
- package/dist/tool.js +6 -9
- package/package.json +2 -2
- package/dist/browser-strategy-yccf8mtd.js +0 -99
- package/dist/node-strategy-12qfy0nv.js +0 -348
- package/dist/tool-5arsyj36.js +0 -11
- package/dist/tool-7eva0peq.js +0 -265
- package/dist/tool-9qecd4wb.js +0 -14
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isBrowser
|
|
3
|
-
} from "./tool-9qecd4wb.js";
|
|
4
|
-
import {
|
|
5
|
-
catchError,
|
|
6
|
-
getFileSystem
|
|
7
|
-
} from "./tool-7eva0peq.js";
|
|
8
|
-
import {
|
|
9
|
-
AUTH_FILENAME,
|
|
10
|
-
DEFAULT_BASE_URL,
|
|
11
|
-
UIPATH_HOME_DIR
|
|
12
|
-
} from "./tool-5arsyj36.js";
|
|
13
1
|
import {
|
|
14
2
|
__commonJS,
|
|
15
3
|
__require,
|
|
16
4
|
__toESM
|
|
17
|
-
} from "./tool-
|
|
5
|
+
} from "./tool-1de529jm.js";
|
|
18
6
|
|
|
19
7
|
// ../../node_modules/commander/lib/error.js
|
|
20
|
-
var require_error = __commonJS((exports)
|
|
8
|
+
var require_error = __commonJS(function(exports) {
|
|
21
9
|
class CommanderError extends Error {
|
|
22
10
|
constructor(exitCode, code, message) {
|
|
23
11
|
super(message);
|
|
@@ -41,7 +29,7 @@ var require_error = __commonJS((exports) => {
|
|
|
41
29
|
});
|
|
42
30
|
|
|
43
31
|
// ../../node_modules/commander/lib/argument.js
|
|
44
|
-
var require_argument = __commonJS((exports)
|
|
32
|
+
var require_argument = __commonJS(function(exports) {
|
|
45
33
|
var { InvalidArgumentError } = require_error();
|
|
46
34
|
|
|
47
35
|
class Argument {
|
|
@@ -121,7 +109,7 @@ var require_argument = __commonJS((exports) => {
|
|
|
121
109
|
});
|
|
122
110
|
|
|
123
111
|
// ../../node_modules/commander/lib/help.js
|
|
124
|
-
var require_help = __commonJS((exports)
|
|
112
|
+
var require_help = __commonJS(function(exports) {
|
|
125
113
|
var { humanReadableArgName } = require_argument();
|
|
126
114
|
|
|
127
115
|
class Help {
|
|
@@ -478,7 +466,7 @@ ${itemIndentStr}`);
|
|
|
478
466
|
});
|
|
479
467
|
|
|
480
468
|
// ../../node_modules/commander/lib/option.js
|
|
481
|
-
var require_option = __commonJS((exports)
|
|
469
|
+
var require_option = __commonJS(function(exports) {
|
|
482
470
|
var { InvalidArgumentError } = require_error();
|
|
483
471
|
|
|
484
472
|
class Option {
|
|
@@ -662,7 +650,7 @@ var require_option = __commonJS((exports) => {
|
|
|
662
650
|
});
|
|
663
651
|
|
|
664
652
|
// ../../node_modules/commander/lib/suggestSimilar.js
|
|
665
|
-
var require_suggestSimilar = __commonJS((exports)
|
|
653
|
+
var require_suggestSimilar = __commonJS(function(exports) {
|
|
666
654
|
var maxDistance = 3;
|
|
667
655
|
function editDistance(a, b) {
|
|
668
656
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
@@ -735,7 +723,7 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
735
723
|
});
|
|
736
724
|
|
|
737
725
|
// ../../node_modules/commander/lib/command.js
|
|
738
|
-
var require_command = __commonJS((exports)
|
|
726
|
+
var require_command = __commonJS(function(exports) {
|
|
739
727
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
740
728
|
var childProcess = __require("node:child_process");
|
|
741
729
|
var path = __require("node:path");
|
|
@@ -2090,7 +2078,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2090
2078
|
});
|
|
2091
2079
|
|
|
2092
2080
|
// ../../node_modules/commander/index.js
|
|
2093
|
-
var require_commander = __commonJS((exports)
|
|
2081
|
+
var require_commander = __commonJS(function(exports) {
|
|
2094
2082
|
var { Argument } = require_argument();
|
|
2095
2083
|
var { Command } = require_command();
|
|
2096
2084
|
var { CommanderError, InvalidArgumentError } = require_error();
|
|
@@ -2125,32 +2113,170 @@ var {
|
|
|
2125
2113
|
Help
|
|
2126
2114
|
} = import__.default;
|
|
2127
2115
|
|
|
2128
|
-
// ../common/src/
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2116
|
+
// ../common/src/telemetry/pseudonymize.ts
|
|
2117
|
+
var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
|
|
2118
|
+
var PSEUDONYM_HEX_LENGTH = 32;
|
|
2119
|
+
var SHA256_K = new Uint32Array([
|
|
2120
|
+
1116352408,
|
|
2121
|
+
1899447441,
|
|
2122
|
+
3049323471,
|
|
2123
|
+
3921009573,
|
|
2124
|
+
961987163,
|
|
2125
|
+
1508970993,
|
|
2126
|
+
2453635748,
|
|
2127
|
+
2870763221,
|
|
2128
|
+
3624381080,
|
|
2129
|
+
310598401,
|
|
2130
|
+
607225278,
|
|
2131
|
+
1426881987,
|
|
2132
|
+
1925078388,
|
|
2133
|
+
2162078206,
|
|
2134
|
+
2614888103,
|
|
2135
|
+
3248222580,
|
|
2136
|
+
3835390401,
|
|
2137
|
+
4022224774,
|
|
2138
|
+
264347078,
|
|
2139
|
+
604807628,
|
|
2140
|
+
770255983,
|
|
2141
|
+
1249150122,
|
|
2142
|
+
1555081692,
|
|
2143
|
+
1996064986,
|
|
2144
|
+
2554220882,
|
|
2145
|
+
2821834349,
|
|
2146
|
+
2952996808,
|
|
2147
|
+
3210313671,
|
|
2148
|
+
3336571891,
|
|
2149
|
+
3584528711,
|
|
2150
|
+
113926993,
|
|
2151
|
+
338241895,
|
|
2152
|
+
666307205,
|
|
2153
|
+
773529912,
|
|
2154
|
+
1294757372,
|
|
2155
|
+
1396182291,
|
|
2156
|
+
1695183700,
|
|
2157
|
+
1986661051,
|
|
2158
|
+
2177026350,
|
|
2159
|
+
2456956037,
|
|
2160
|
+
2730485921,
|
|
2161
|
+
2820302411,
|
|
2162
|
+
3259730800,
|
|
2163
|
+
3345764771,
|
|
2164
|
+
3516065817,
|
|
2165
|
+
3600352804,
|
|
2166
|
+
4094571909,
|
|
2167
|
+
275423344,
|
|
2168
|
+
430227734,
|
|
2169
|
+
506948616,
|
|
2170
|
+
659060556,
|
|
2171
|
+
883997877,
|
|
2172
|
+
958139571,
|
|
2173
|
+
1322822218,
|
|
2174
|
+
1537002063,
|
|
2175
|
+
1747873779,
|
|
2176
|
+
1955562222,
|
|
2177
|
+
2024104815,
|
|
2178
|
+
2227730452,
|
|
2179
|
+
2361852424,
|
|
2180
|
+
2428436474,
|
|
2181
|
+
2756734187,
|
|
2182
|
+
3204031479,
|
|
2183
|
+
3329325298
|
|
2184
|
+
]);
|
|
2185
|
+
var SHA256_INITIAL_STATE = new Uint32Array([
|
|
2186
|
+
1779033703,
|
|
2187
|
+
3144134277,
|
|
2188
|
+
1013904242,
|
|
2189
|
+
2773480762,
|
|
2190
|
+
1359893119,
|
|
2191
|
+
2600822924,
|
|
2192
|
+
528734635,
|
|
2193
|
+
1541459225
|
|
2194
|
+
]);
|
|
2195
|
+
function rotr(value, bits) {
|
|
2196
|
+
return (value >>> bits | value << 32 - bits) >>> 0;
|
|
2197
|
+
}
|
|
2198
|
+
function sha256Hex(input) {
|
|
2199
|
+
const bytes = new TextEncoder().encode(input);
|
|
2200
|
+
const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
|
|
2201
|
+
const buffer = new Uint8Array(paddedLength);
|
|
2202
|
+
buffer.set(bytes);
|
|
2203
|
+
buffer[bytes.length] = 128;
|
|
2204
|
+
const view = new DataView(buffer.buffer);
|
|
2205
|
+
const bitLength = bytes.length * 8;
|
|
2206
|
+
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
|
|
2207
|
+
view.setUint32(paddedLength - 4, bitLength >>> 0);
|
|
2208
|
+
const state = SHA256_INITIAL_STATE.slice();
|
|
2209
|
+
const schedule = new Uint32Array(64);
|
|
2210
|
+
for (let offset = 0;offset < paddedLength; offset += 64) {
|
|
2211
|
+
for (let i = 0;i < 16; i++) {
|
|
2212
|
+
schedule[i] = view.getUint32(offset + i * 4);
|
|
2213
|
+
}
|
|
2214
|
+
for (let i = 16;i < 64; i++) {
|
|
2215
|
+
const x = schedule[i - 15];
|
|
2216
|
+
const y = schedule[i - 2];
|
|
2217
|
+
const s0 = (rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3) >>> 0;
|
|
2218
|
+
const s1 = (rotr(y, 17) ^ rotr(y, 19) ^ y >>> 10) >>> 0;
|
|
2219
|
+
schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1 >>> 0;
|
|
2220
|
+
}
|
|
2221
|
+
let a = state[0];
|
|
2222
|
+
let b = state[1];
|
|
2223
|
+
let c = state[2];
|
|
2224
|
+
let d = state[3];
|
|
2225
|
+
let e = state[4];
|
|
2226
|
+
let f = state[5];
|
|
2227
|
+
let g = state[6];
|
|
2228
|
+
let h = state[7];
|
|
2229
|
+
for (let i = 0;i < 64; i++) {
|
|
2230
|
+
const s1 = (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) >>> 0;
|
|
2231
|
+
const ch = (e & f ^ ~e & g) >>> 0;
|
|
2232
|
+
const temp1 = h + s1 + ch + SHA256_K[i] + schedule[i] >>> 0;
|
|
2233
|
+
const s0 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) >>> 0;
|
|
2234
|
+
const maj = (a & b ^ a & c ^ b & c) >>> 0;
|
|
2235
|
+
const temp2 = s0 + maj >>> 0;
|
|
2236
|
+
h = g;
|
|
2237
|
+
g = f;
|
|
2238
|
+
f = e;
|
|
2239
|
+
e = d + temp1 >>> 0;
|
|
2240
|
+
d = c;
|
|
2241
|
+
c = b;
|
|
2242
|
+
b = a;
|
|
2243
|
+
a = temp1 + temp2 >>> 0;
|
|
2244
|
+
}
|
|
2245
|
+
state[0] = state[0] + a >>> 0;
|
|
2246
|
+
state[1] = state[1] + b >>> 0;
|
|
2247
|
+
state[2] = state[2] + c >>> 0;
|
|
2248
|
+
state[3] = state[3] + d >>> 0;
|
|
2249
|
+
state[4] = state[4] + e >>> 0;
|
|
2250
|
+
state[5] = state[5] + f >>> 0;
|
|
2251
|
+
state[6] = state[6] + g >>> 0;
|
|
2252
|
+
state[7] = state[7] + h >>> 0;
|
|
2253
|
+
}
|
|
2254
|
+
let hex = "";
|
|
2255
|
+
for (const word of state) {
|
|
2256
|
+
hex += word.toString(16).padStart(8, "0");
|
|
2135
2257
|
}
|
|
2258
|
+
return hex;
|
|
2259
|
+
}
|
|
2260
|
+
function resolveSha256Hex() {
|
|
2136
2261
|
try {
|
|
2137
|
-
const
|
|
2138
|
-
|
|
2139
|
-
|
|
2262
|
+
const nodeCrypto = __require("node:crypto");
|
|
2263
|
+
const createHash = nodeCrypto?.createHash;
|
|
2264
|
+
if (typeof createHash !== "function") {
|
|
2265
|
+
return sha256Hex;
|
|
2140
2266
|
}
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
undefined
|
|
2146
|
-
];
|
|
2267
|
+
const native = (input) => createHash("sha256").update(input, "utf8").digest("hex");
|
|
2268
|
+
return native("abc") === sha256Hex("abc") ? native : sha256Hex;
|
|
2269
|
+
} catch {
|
|
2270
|
+
return sha256Hex;
|
|
2147
2271
|
}
|
|
2148
2272
|
}
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2273
|
+
var cachedSha256Hex;
|
|
2274
|
+
function digest(input) {
|
|
2275
|
+
cachedSha256Hex ??= resolveSha256Hex();
|
|
2276
|
+
return cachedSha256Hex(input);
|
|
2277
|
+
}
|
|
2278
|
+
function pseudonymize(input) {
|
|
2279
|
+
return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
|
|
2154
2280
|
}
|
|
2155
2281
|
|
|
2156
2282
|
// ../common/src/singleton.ts
|
|
@@ -2183,9 +2309,582 @@ function singleton(ctorOrName) {
|
|
|
2183
2309
|
};
|
|
2184
2310
|
}
|
|
2185
2311
|
|
|
2312
|
+
// ../common/src/telemetry/supplied-values.ts
|
|
2313
|
+
var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
|
|
2314
|
+
function activeEntries() {
|
|
2315
|
+
const existing = suppliedValuesSlot.get();
|
|
2316
|
+
return Array.isArray(existing) ? existing : [];
|
|
2317
|
+
}
|
|
2318
|
+
var MIN_SCRUBBABLE_LENGTH = 4;
|
|
2319
|
+
function recordSuppliedArgumentValues(values) {
|
|
2320
|
+
const flat = [];
|
|
2321
|
+
const push = (value) => {
|
|
2322
|
+
if (Array.isArray(value)) {
|
|
2323
|
+
for (const item of value) {
|
|
2324
|
+
push(item);
|
|
2325
|
+
}
|
|
2326
|
+
return;
|
|
2327
|
+
}
|
|
2328
|
+
if (typeof value === "string" && value.length >= MIN_SCRUBBABLE_LENGTH) {
|
|
2329
|
+
flat.push(value);
|
|
2330
|
+
}
|
|
2331
|
+
};
|
|
2332
|
+
push(values);
|
|
2333
|
+
const entry = { values: flat };
|
|
2334
|
+
suppliedValuesSlot.set([...activeEntries(), entry]);
|
|
2335
|
+
return entry;
|
|
2336
|
+
}
|
|
2337
|
+
function releaseSuppliedArgumentValues(entry) {
|
|
2338
|
+
suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
|
|
2339
|
+
}
|
|
2340
|
+
function getSuppliedArgumentValues() {
|
|
2341
|
+
const all = new Set;
|
|
2342
|
+
for (const entry of activeEntries()) {
|
|
2343
|
+
for (const value of entry.values) {
|
|
2344
|
+
all.add(value);
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
return [...all].sort((a, b) => b.length - a.length);
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
// ../common/src/telemetry/pii-redactor.ts
|
|
2351
|
+
var REDACTED = "[REDACTED]";
|
|
2352
|
+
var MAX_VALUE_LENGTH = 280;
|
|
2353
|
+
var MAX_STACK_LENGTH = 4096;
|
|
2354
|
+
var MAX_SCAN_LENGTH = MAX_STACK_LENGTH;
|
|
2355
|
+
function truncate(value, maxLength) {
|
|
2356
|
+
return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;
|
|
2357
|
+
}
|
|
2358
|
+
var SENSITIVE_NAME_TOKENS = new Set([
|
|
2359
|
+
"token",
|
|
2360
|
+
"tokens",
|
|
2361
|
+
"secret",
|
|
2362
|
+
"secrets",
|
|
2363
|
+
"password",
|
|
2364
|
+
"passwords",
|
|
2365
|
+
"pwd",
|
|
2366
|
+
"credential",
|
|
2367
|
+
"credentials",
|
|
2368
|
+
"auth",
|
|
2369
|
+
"authentication",
|
|
2370
|
+
"authorization",
|
|
2371
|
+
"authority",
|
|
2372
|
+
"cert",
|
|
2373
|
+
"certificate",
|
|
2374
|
+
"certificates"
|
|
2375
|
+
]);
|
|
2376
|
+
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
2377
|
+
"api",
|
|
2378
|
+
"access",
|
|
2379
|
+
"client",
|
|
2380
|
+
"private",
|
|
2381
|
+
"public",
|
|
2382
|
+
"signing",
|
|
2383
|
+
"encryption",
|
|
2384
|
+
"session",
|
|
2385
|
+
"master",
|
|
2386
|
+
"shared",
|
|
2387
|
+
"root",
|
|
2388
|
+
"ssh",
|
|
2389
|
+
"rsa",
|
|
2390
|
+
"aes",
|
|
2391
|
+
"hmac",
|
|
2392
|
+
"oauth"
|
|
2393
|
+
]);
|
|
2394
|
+
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;
|
|
2395
|
+
var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
2396
|
+
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
2397
|
+
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
2398
|
+
var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
2399
|
+
var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
|
|
2400
|
+
var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
|
|
2401
|
+
var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
|
|
2402
|
+
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;
|
|
2403
|
+
var SOURCE_FILE_EXTENSIONS = new Set([
|
|
2404
|
+
"ts",
|
|
2405
|
+
"tsx",
|
|
2406
|
+
"js",
|
|
2407
|
+
"jsx",
|
|
2408
|
+
"mjs",
|
|
2409
|
+
"cjs",
|
|
2410
|
+
"cts",
|
|
2411
|
+
"mts",
|
|
2412
|
+
"py",
|
|
2413
|
+
"cs",
|
|
2414
|
+
"java",
|
|
2415
|
+
"go",
|
|
2416
|
+
"rs",
|
|
2417
|
+
"rb",
|
|
2418
|
+
"php",
|
|
2419
|
+
"sh",
|
|
2420
|
+
"ps1",
|
|
2421
|
+
"json",
|
|
2422
|
+
"jsonc",
|
|
2423
|
+
"yaml",
|
|
2424
|
+
"yml",
|
|
2425
|
+
"xml",
|
|
2426
|
+
"xaml",
|
|
2427
|
+
"md",
|
|
2428
|
+
"txt",
|
|
2429
|
+
"log",
|
|
2430
|
+
"css",
|
|
2431
|
+
"html",
|
|
2432
|
+
"htm",
|
|
2433
|
+
"csproj",
|
|
2434
|
+
"nuspec",
|
|
2435
|
+
"sql"
|
|
2436
|
+
]);
|
|
2437
|
+
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
2438
|
+
var QUOTED_LITERAL_MAX_SPAN = 200;
|
|
2439
|
+
var QUOTED_LITERAL_PATTERN = new RegExp([
|
|
2440
|
+
`(?<![A-Za-z0-9])'(?:[^\\
|
|
2441
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
|
|
2442
|
+
`(?<![A-Za-z0-9])"(?:[^\\
|
|
2443
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
|
|
2444
|
+
].join("|"), "g");
|
|
2445
|
+
var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
|
|
2446
|
+
var COLLAPSED_BODY = "{…}";
|
|
2447
|
+
var COLLAPSED_BODY_MARKER = "\x01body\x01";
|
|
2448
|
+
var MAX_BODY_NESTING = 8;
|
|
2449
|
+
function collapseJsonBodies(text) {
|
|
2450
|
+
let out = text;
|
|
2451
|
+
for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
|
|
2452
|
+
const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
|
|
2453
|
+
if (next === out) {
|
|
2454
|
+
break;
|
|
2455
|
+
}
|
|
2456
|
+
out = next;
|
|
2457
|
+
}
|
|
2458
|
+
return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
|
|
2459
|
+
}
|
|
2460
|
+
var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
|
|
2461
|
+
function peelTrailingPunctuation(match) {
|
|
2462
|
+
const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
|
|
2463
|
+
return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
|
|
2464
|
+
}
|
|
2465
|
+
function redactUrl(raw) {
|
|
2466
|
+
try {
|
|
2467
|
+
const url = new URL(raw);
|
|
2468
|
+
return `${url.protocol}//${url.host}`;
|
|
2469
|
+
} catch {
|
|
2470
|
+
return `url#${pseudonymize(raw)}`;
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
|
|
2474
|
+
let out = truncate(value, MAX_SCAN_LENGTH);
|
|
2475
|
+
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
2476
|
+
out = out.replace(URL_PATTERN, (match) => {
|
|
2477
|
+
const [core, trailing] = peelTrailingPunctuation(match);
|
|
2478
|
+
return `${redactUrl(core)}${trailing}`;
|
|
2479
|
+
});
|
|
2480
|
+
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
2481
|
+
out = out.replace(UNC_PATH_PATTERN, (_match, before, path) => {
|
|
2482
|
+
const [core, trailing] = peelTrailingPunctuation(path);
|
|
2483
|
+
return `${before}unc#${pseudonymize(core)}${trailing}`;
|
|
2484
|
+
});
|
|
2485
|
+
out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
|
|
2486
|
+
out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
|
|
2487
|
+
out = out.replace(HOST_PORT_PATTERN, (match) => {
|
|
2488
|
+
const split = match.lastIndexOf(":");
|
|
2489
|
+
const host = match.slice(0, split);
|
|
2490
|
+
const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
|
|
2491
|
+
if (SOURCE_FILE_EXTENSIONS.has(extension)) {
|
|
2492
|
+
return match;
|
|
2493
|
+
}
|
|
2494
|
+
return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
|
|
2495
|
+
});
|
|
2496
|
+
out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
|
|
2497
|
+
out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
|
|
2498
|
+
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
2499
|
+
return truncate(out, maxLength);
|
|
2500
|
+
}
|
|
2501
|
+
function redactSpanName(name) {
|
|
2502
|
+
return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
|
|
2503
|
+
}
|
|
2504
|
+
var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
|
|
2505
|
+
function redactHttpDependencyName(name) {
|
|
2506
|
+
const parts = HTTP_DEPENDENCY_NAME.exec(name);
|
|
2507
|
+
if (!parts) {
|
|
2508
|
+
return redactMessage(name);
|
|
2509
|
+
}
|
|
2510
|
+
return `${parts[1]} ${redactMessage(parts[2])}`;
|
|
2511
|
+
}
|
|
2512
|
+
function redactMessage(value) {
|
|
2513
|
+
let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
|
|
2514
|
+
for (const supplied of getSuppliedArgumentValues()) {
|
|
2515
|
+
out = out.split(supplied).join(REDACTED);
|
|
2516
|
+
}
|
|
2517
|
+
return redactValueDetectors(out);
|
|
2518
|
+
}
|
|
2519
|
+
var MESSAGE_NAMES = new Set([
|
|
2520
|
+
"message",
|
|
2521
|
+
"errormessage",
|
|
2522
|
+
"errmessage",
|
|
2523
|
+
"error_message",
|
|
2524
|
+
"msg",
|
|
2525
|
+
"detail",
|
|
2526
|
+
"details",
|
|
2527
|
+
"reason",
|
|
2528
|
+
"instructions",
|
|
2529
|
+
"warning"
|
|
2530
|
+
]);
|
|
2531
|
+
function isFreeFormValue(name, value) {
|
|
2532
|
+
return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
|
|
2533
|
+
}
|
|
2534
|
+
function redactError(error) {
|
|
2535
|
+
const safe = new Error(redactMessage(error.message ?? ""));
|
|
2536
|
+
safe.name = error.name;
|
|
2537
|
+
safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
|
|
2538
|
+
return safe;
|
|
2539
|
+
}
|
|
2540
|
+
function redactStack(stack) {
|
|
2541
|
+
const bounded = truncate(stack, MAX_STACK_LENGTH);
|
|
2542
|
+
const firstBreak = bounded.indexOf(`
|
|
2543
|
+
`);
|
|
2544
|
+
if (firstBreak === -1) {
|
|
2545
|
+
return redactMessage(bounded);
|
|
2546
|
+
}
|
|
2547
|
+
return `${redactMessage(bounded.slice(0, firstBreak))}
|
|
2548
|
+
${redactValueDetectors(bounded.slice(firstBreak + 1), MAX_STACK_LENGTH)}`;
|
|
2549
|
+
}
|
|
2550
|
+
function nameTokens(name) {
|
|
2551
|
+
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);
|
|
2552
|
+
}
|
|
2553
|
+
function isSensitiveName(name) {
|
|
2554
|
+
const tokens = nameTokens(name);
|
|
2555
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
2556
|
+
const token = tokens[i];
|
|
2557
|
+
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
2558
|
+
return true;
|
|
2559
|
+
}
|
|
2560
|
+
if (token === "key" || token === "keys") {
|
|
2561
|
+
const prev = tokens[i - 1];
|
|
2562
|
+
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
2563
|
+
return true;
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
return false;
|
|
2568
|
+
}
|
|
2569
|
+
function redactProperty(name, value) {
|
|
2570
|
+
if (value === undefined || value === null) {
|
|
2571
|
+
return;
|
|
2572
|
+
}
|
|
2573
|
+
if (isSensitiveName(name)) {
|
|
2574
|
+
return REDACTED;
|
|
2575
|
+
}
|
|
2576
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
2577
|
+
return value;
|
|
2578
|
+
}
|
|
2579
|
+
if (typeof value !== "string") {
|
|
2580
|
+
return "[OBJECT]";
|
|
2581
|
+
}
|
|
2582
|
+
return isFreeFormValue(name, value) ? redactMessage(value) : redactValueDetectors(value);
|
|
2583
|
+
}
|
|
2584
|
+
function redactProperties(properties) {
|
|
2585
|
+
const out = {};
|
|
2586
|
+
for (const [name, value] of Object.entries(properties)) {
|
|
2587
|
+
const redacted = redactProperty(name, value);
|
|
2588
|
+
if (redacted !== undefined) {
|
|
2589
|
+
out[name] = redacted;
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
return out;
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
// ../common/src/catch-error.ts
|
|
2596
|
+
var MAX_SERIALIZED_LENGTH = 500;
|
|
2597
|
+
var TRUNCATION_SUFFIX = "…(truncated)";
|
|
2598
|
+
var REDACTED2 = "[REDACTED]";
|
|
2599
|
+
function cap(text) {
|
|
2600
|
+
return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
|
|
2601
|
+
}
|
|
2602
|
+
function omitSensitive(key, value) {
|
|
2603
|
+
return key.length > 0 && isSensitiveName(key) ? REDACTED2 : value;
|
|
2604
|
+
}
|
|
2605
|
+
function describeThrownValue(value) {
|
|
2606
|
+
if (typeof value !== "object" || value === null) {
|
|
2607
|
+
return String(value);
|
|
2608
|
+
}
|
|
2609
|
+
let message;
|
|
2610
|
+
try {
|
|
2611
|
+
message = value.message;
|
|
2612
|
+
} catch {
|
|
2613
|
+
message = undefined;
|
|
2614
|
+
}
|
|
2615
|
+
if (typeof message === "string" && message.length > 0) {
|
|
2616
|
+
return cap(message);
|
|
2617
|
+
}
|
|
2618
|
+
try {
|
|
2619
|
+
const json = JSON.stringify(value, omitSensitive);
|
|
2620
|
+
if (json !== undefined) {
|
|
2621
|
+
return cap(json);
|
|
2622
|
+
}
|
|
2623
|
+
} catch {}
|
|
2624
|
+
return String(value);
|
|
2625
|
+
}
|
|
2626
|
+
function toError(error) {
|
|
2627
|
+
return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
|
|
2628
|
+
}
|
|
2629
|
+
function isPromiseLike(value) {
|
|
2630
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
2631
|
+
}
|
|
2632
|
+
function catchError(fnOrPromise) {
|
|
2633
|
+
if (isPromiseLike(fnOrPromise)) {
|
|
2634
|
+
return settlePromiseLike(fnOrPromise);
|
|
2635
|
+
}
|
|
2636
|
+
try {
|
|
2637
|
+
const result = fnOrPromise();
|
|
2638
|
+
if (isPromiseLike(result)) {
|
|
2639
|
+
return settlePromiseLike(result);
|
|
2640
|
+
}
|
|
2641
|
+
return [undefined, result];
|
|
2642
|
+
} catch (error) {
|
|
2643
|
+
return [toError(error), undefined];
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
function settlePromiseLike(thenable) {
|
|
2647
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
// ../common/src/exit-code.ts
|
|
2651
|
+
function setExitCode(code) {
|
|
2652
|
+
process.exitCode = code;
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
// ../filesystem/src/node.ts
|
|
2656
|
+
import { randomUUID } from "node:crypto";
|
|
2657
|
+
import { existsSync } from "node:fs";
|
|
2658
|
+
import * as fs from "node:fs/promises";
|
|
2659
|
+
import * as os from "node:os";
|
|
2660
|
+
import * as path from "node:path";
|
|
2661
|
+
var LOCK_HEARTBEAT_MS = 5000;
|
|
2662
|
+
var LOCK_STALE_MS = 15000;
|
|
2663
|
+
var LOCK_MAX_WAIT_MS = 20000;
|
|
2664
|
+
var LOCK_MAX_HOLD_MS = 60000;
|
|
2665
|
+
var LOCK_RETRY_MIN_MS = 100;
|
|
2666
|
+
var LOCK_RETRY_JITTER_MS = 200;
|
|
2667
|
+
|
|
2668
|
+
class NodeFileSystem {
|
|
2669
|
+
path = {
|
|
2670
|
+
join: path.join,
|
|
2671
|
+
resolve: path.resolve,
|
|
2672
|
+
relative: path.relative,
|
|
2673
|
+
dirname: path.dirname,
|
|
2674
|
+
isAbsolute: path.isAbsolute,
|
|
2675
|
+
basename: path.basename
|
|
2676
|
+
};
|
|
2677
|
+
env = {
|
|
2678
|
+
cwd: process.cwd,
|
|
2679
|
+
homedir: os.homedir,
|
|
2680
|
+
tmpdir: os.tmpdir,
|
|
2681
|
+
getenv: (key) => process.env[key]
|
|
2682
|
+
};
|
|
2683
|
+
utils = {
|
|
2684
|
+
open: async (url) => {
|
|
2685
|
+
const { default: open } = await import("./index-sby22td6.js");
|
|
2686
|
+
await open(url);
|
|
2687
|
+
}
|
|
2688
|
+
};
|
|
2689
|
+
async readFile(path2, options) {
|
|
2690
|
+
try {
|
|
2691
|
+
if (options) {
|
|
2692
|
+
return await fs.readFile(path2, "utf-8");
|
|
2693
|
+
}
|
|
2694
|
+
return await fs.readFile(path2);
|
|
2695
|
+
} catch (error) {
|
|
2696
|
+
if (this.isEnoent(error))
|
|
2697
|
+
return null;
|
|
2698
|
+
throw error;
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
async writeFile(filePath, data) {
|
|
2702
|
+
const dir = path.dirname(filePath);
|
|
2703
|
+
if (dir) {
|
|
2704
|
+
await fs.mkdir(dir, { recursive: true });
|
|
2705
|
+
}
|
|
2706
|
+
await fs.writeFile(filePath, data);
|
|
2707
|
+
}
|
|
2708
|
+
async appendFile(filePath, data) {
|
|
2709
|
+
const dir = path.dirname(filePath);
|
|
2710
|
+
if (dir) {
|
|
2711
|
+
await fs.mkdir(dir, { recursive: true });
|
|
2712
|
+
}
|
|
2713
|
+
await fs.appendFile(filePath, data);
|
|
2714
|
+
}
|
|
2715
|
+
async readdir(dirPath) {
|
|
2716
|
+
try {
|
|
2717
|
+
return await fs.readdir(dirPath);
|
|
2718
|
+
} catch (error) {
|
|
2719
|
+
if (this.isEnoent(error))
|
|
2720
|
+
return [];
|
|
2721
|
+
throw error;
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
async stat(filePath) {
|
|
2725
|
+
try {
|
|
2726
|
+
const stats = await fs.stat(filePath);
|
|
2727
|
+
return {
|
|
2728
|
+
isFile: () => stats.isFile(),
|
|
2729
|
+
isDirectory: () => stats.isDirectory(),
|
|
2730
|
+
size: stats.size,
|
|
2731
|
+
mtimeMs: stats.mtimeMs
|
|
2732
|
+
};
|
|
2733
|
+
} catch (error) {
|
|
2734
|
+
if (this.isEnoent(error))
|
|
2735
|
+
return null;
|
|
2736
|
+
throw error;
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
async exists(filePath) {
|
|
2740
|
+
return existsSync(filePath);
|
|
2741
|
+
}
|
|
2742
|
+
async mkdir(dirPath) {
|
|
2743
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
2744
|
+
}
|
|
2745
|
+
async acquireLock(lockPath) {
|
|
2746
|
+
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
2747
|
+
const lockFile = `${canonicalPath}.lock`;
|
|
2748
|
+
const ownerId = randomUUID();
|
|
2749
|
+
const start = Date.now();
|
|
2750
|
+
while (true) {
|
|
2751
|
+
try {
|
|
2752
|
+
await fs.writeFile(lockFile, ownerId, { flag: "wx" });
|
|
2753
|
+
return this.createLockRelease(lockFile, ownerId);
|
|
2754
|
+
} catch (error) {
|
|
2755
|
+
if (!this.hasErrnoCode(error, "EEXIST")) {
|
|
2756
|
+
throw error;
|
|
2757
|
+
}
|
|
2758
|
+
const stats = await fs.stat(lockFile).catch(() => null);
|
|
2759
|
+
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
|
|
2760
|
+
const reclaimed = await fs.rm(lockFile, { force: true }).then(() => true).catch(() => false);
|
|
2761
|
+
if (reclaimed)
|
|
2762
|
+
continue;
|
|
2763
|
+
}
|
|
2764
|
+
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
2765
|
+
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
2766
|
+
}
|
|
2767
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
async canonicalizeLockTarget(lockPath) {
|
|
2772
|
+
const absolute = path.resolve(lockPath);
|
|
2773
|
+
const fullReal = await fs.realpath(absolute).catch(() => null);
|
|
2774
|
+
if (fullReal)
|
|
2775
|
+
return fullReal;
|
|
2776
|
+
const parent = path.dirname(absolute);
|
|
2777
|
+
const base = path.basename(absolute);
|
|
2778
|
+
const canonicalParent = await fs.realpath(parent).catch(() => parent);
|
|
2779
|
+
return path.join(canonicalParent, base);
|
|
2780
|
+
}
|
|
2781
|
+
createLockRelease(lockFile, ownerId) {
|
|
2782
|
+
const heartbeatStart = Date.now();
|
|
2783
|
+
let heartbeatTimer;
|
|
2784
|
+
let stopped = false;
|
|
2785
|
+
const stopHeartbeat = () => {
|
|
2786
|
+
stopped = true;
|
|
2787
|
+
if (heartbeatTimer)
|
|
2788
|
+
clearTimeout(heartbeatTimer);
|
|
2789
|
+
};
|
|
2790
|
+
const scheduleNextHeartbeat = () => {
|
|
2791
|
+
if (stopped)
|
|
2792
|
+
return;
|
|
2793
|
+
if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
|
|
2794
|
+
stopped = true;
|
|
2795
|
+
return;
|
|
2796
|
+
}
|
|
2797
|
+
heartbeatTimer = setTimeout(() => {
|
|
2798
|
+
runHeartbeat();
|
|
2799
|
+
}, LOCK_HEARTBEAT_MS);
|
|
2800
|
+
heartbeatTimer.unref?.();
|
|
2801
|
+
};
|
|
2802
|
+
const runHeartbeat = async () => {
|
|
2803
|
+
if (stopped)
|
|
2804
|
+
return;
|
|
2805
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
2806
|
+
if (stopped)
|
|
2807
|
+
return;
|
|
2808
|
+
if (current !== ownerId) {
|
|
2809
|
+
stopped = true;
|
|
2810
|
+
return;
|
|
2811
|
+
}
|
|
2812
|
+
const now = Date.now() / 1000;
|
|
2813
|
+
await fs.utimes(lockFile, now, now).catch(() => {});
|
|
2814
|
+
scheduleNextHeartbeat();
|
|
2815
|
+
};
|
|
2816
|
+
scheduleNextHeartbeat();
|
|
2817
|
+
let released = false;
|
|
2818
|
+
return async () => {
|
|
2819
|
+
if (released)
|
|
2820
|
+
return;
|
|
2821
|
+
released = true;
|
|
2822
|
+
stopHeartbeat();
|
|
2823
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
2824
|
+
if (current === ownerId) {
|
|
2825
|
+
await fs.rm(lockFile, { force: true });
|
|
2826
|
+
}
|
|
2827
|
+
};
|
|
2828
|
+
}
|
|
2829
|
+
async rm(filePath) {
|
|
2830
|
+
await fs.rm(filePath, { recursive: true, force: true });
|
|
2831
|
+
}
|
|
2832
|
+
async rename(oldPath, newPath) {
|
|
2833
|
+
await fs.rename(oldPath, newPath);
|
|
2834
|
+
}
|
|
2835
|
+
async realpath(filePath) {
|
|
2836
|
+
try {
|
|
2837
|
+
return await fs.realpath(filePath);
|
|
2838
|
+
} catch (error) {
|
|
2839
|
+
if (this.isEnoent(error))
|
|
2840
|
+
return filePath;
|
|
2841
|
+
throw error;
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
async getTempDir() {
|
|
2845
|
+
return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
|
|
2846
|
+
}
|
|
2847
|
+
async copyDirectory(sourcePath, destPath) {
|
|
2848
|
+
const sourceStats = await this.stat(sourcePath);
|
|
2849
|
+
if (!sourceStats) {
|
|
2850
|
+
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
2851
|
+
}
|
|
2852
|
+
if (!sourceStats.isDirectory()) {
|
|
2853
|
+
throw new Error(`Source path is not a directory: ${sourcePath}`);
|
|
2854
|
+
}
|
|
2855
|
+
await this.mkdir(destPath);
|
|
2856
|
+
const entries = await this.readdir(sourcePath);
|
|
2857
|
+
for (const entry of entries) {
|
|
2858
|
+
const srcEntry = path.join(sourcePath, entry);
|
|
2859
|
+
const destEntry = path.join(destPath, entry);
|
|
2860
|
+
const entryStats = await this.stat(srcEntry);
|
|
2861
|
+
if (!entryStats)
|
|
2862
|
+
continue;
|
|
2863
|
+
if (entryStats.isDirectory()) {
|
|
2864
|
+
await this.copyDirectory(srcEntry, destEntry);
|
|
2865
|
+
} else if (entryStats.isFile()) {
|
|
2866
|
+
const content = await this.readFile(srcEntry);
|
|
2867
|
+
if (content !== null) {
|
|
2868
|
+
await this.writeFile(destEntry, content);
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
isEnoent(error) {
|
|
2874
|
+
return this.hasErrnoCode(error, "ENOENT");
|
|
2875
|
+
}
|
|
2876
|
+
hasErrnoCode(error, code) {
|
|
2877
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
// ../filesystem/src/index.ts
|
|
2882
|
+
var fsInstance = new NodeFileSystem;
|
|
2883
|
+
var getFileSystem = () => fsInstance;
|
|
2884
|
+
|
|
2186
2885
|
// ../common/src/output-context.ts
|
|
2187
2886
|
function createStorage() {
|
|
2188
|
-
const [error, mod] =
|
|
2887
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
2189
2888
|
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
2190
2889
|
return {
|
|
2191
2890
|
getStore: () => {
|
|
@@ -2216,8 +2915,8 @@ function getOutputSink() {
|
|
|
2216
2915
|
|
|
2217
2916
|
// ../common/src/logger.ts
|
|
2218
2917
|
var logFilePathSlot = singleton("logFilePath");
|
|
2219
|
-
function setGlobalLogFilePath(
|
|
2220
|
-
logFilePathSlot.set(
|
|
2918
|
+
function setGlobalLogFilePath(path2) {
|
|
2919
|
+
logFilePathSlot.set(path2);
|
|
2221
2920
|
}
|
|
2222
2921
|
function getGlobalLogFilePath() {
|
|
2223
2922
|
return logFilePathSlot.get("");
|
|
@@ -2254,7 +2953,7 @@ class SimpleLogger {
|
|
|
2254
2953
|
}
|
|
2255
2954
|
return DEFAULT_LOG_LEVEL;
|
|
2256
2955
|
}
|
|
2257
|
-
const [localStorageError, hasDebug] =
|
|
2956
|
+
const [localStorageError, hasDebug] = catchError(() => typeof localStorage !== "undefined" && !!localStorage.getItem("debug"));
|
|
2258
2957
|
if (!localStorageError && hasDebug) {
|
|
2259
2958
|
return 0 /* DEBUG */;
|
|
2260
2959
|
}
|
|
@@ -2285,54 +2984,49 @@ class SimpleLogger {
|
|
|
2285
2984
|
return this.fileLoggingEnabled || !!getGlobalLogFilePath();
|
|
2286
2985
|
}
|
|
2287
2986
|
writeToFile(formatted) {
|
|
2288
|
-
const
|
|
2289
|
-
if (!
|
|
2987
|
+
const path2 = this.logFilePath || getGlobalLogFilePath();
|
|
2988
|
+
if (!path2)
|
|
2290
2989
|
return;
|
|
2291
2990
|
const timestamp = new Date().toISOString();
|
|
2292
2991
|
this.pendingWrites = Promise.all([
|
|
2293
2992
|
this.pendingWrites,
|
|
2294
2993
|
this.pendingInit
|
|
2295
|
-
]).then(() => getFileSystem().appendFile(
|
|
2994
|
+
]).then(() => getFileSystem().appendFile(path2, `${timestamp} ${formatted}`).catch(() => {}));
|
|
2296
2995
|
}
|
|
2297
|
-
|
|
2298
|
-
if (this.level > 0 /* DEBUG */)
|
|
2299
|
-
return;
|
|
2300
|
-
const formatted = this.format(`[DEBUG] ${message}`, args);
|
|
2996
|
+
write(formatted) {
|
|
2301
2997
|
if (this.isFileLoggingActive()) {
|
|
2302
2998
|
this.writeToFile(formatted);
|
|
2303
2999
|
} else {
|
|
2304
3000
|
getOutputSink().writeErr(formatted);
|
|
2305
3001
|
}
|
|
2306
3002
|
}
|
|
3003
|
+
debug(message, ...args) {
|
|
3004
|
+
if (this.level > 0 /* DEBUG */)
|
|
3005
|
+
return;
|
|
3006
|
+
const formatted = this.format(`[DEBUG] ${message}`, args);
|
|
3007
|
+
this.write(formatted);
|
|
3008
|
+
}
|
|
2307
3009
|
info(message, ...args) {
|
|
2308
3010
|
if (this.level > 1 /* INFO */)
|
|
2309
3011
|
return;
|
|
2310
3012
|
const formatted = this.format(message, args);
|
|
2311
|
-
|
|
2312
|
-
this.writeToFile(formatted);
|
|
2313
|
-
} else {
|
|
2314
|
-
getOutputSink().writeErr(formatted);
|
|
2315
|
-
}
|
|
3013
|
+
this.write(formatted);
|
|
2316
3014
|
}
|
|
2317
3015
|
warn(message, ...args) {
|
|
2318
3016
|
if (this.level > 2 /* WARN */)
|
|
2319
3017
|
return;
|
|
2320
3018
|
const formatted = this.format(`[WARN] ${message}`, args);
|
|
2321
|
-
|
|
2322
|
-
this.writeToFile(formatted);
|
|
2323
|
-
} else {
|
|
2324
|
-
getOutputSink().writeErr(formatted);
|
|
2325
|
-
}
|
|
3019
|
+
this.write(formatted);
|
|
2326
3020
|
}
|
|
2327
3021
|
error(message, ...args) {
|
|
2328
3022
|
if (this.level > 3 /* ERROR */)
|
|
2329
3023
|
return;
|
|
2330
3024
|
const formatted = this.format(`[ERROR] ${message}`, args);
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
3025
|
+
this.write(formatted);
|
|
3026
|
+
}
|
|
3027
|
+
report(message) {
|
|
3028
|
+
const formatted = this.format(message, []);
|
|
3029
|
+
this.write(formatted);
|
|
2336
3030
|
}
|
|
2337
3031
|
getLevel() {
|
|
2338
3032
|
return this.level;
|
|
@@ -2347,17 +3041,17 @@ class SimpleLogger {
|
|
|
2347
3041
|
setGlobalLogFilePath("");
|
|
2348
3042
|
}
|
|
2349
3043
|
}
|
|
2350
|
-
setLogFile(
|
|
2351
|
-
this.logFilePath =
|
|
2352
|
-
setGlobalLogFilePath(
|
|
2353
|
-
if (!
|
|
3044
|
+
setLogFile(path2) {
|
|
3045
|
+
this.logFilePath = path2;
|
|
3046
|
+
setGlobalLogFilePath(path2);
|
|
3047
|
+
if (!path2)
|
|
2354
3048
|
return;
|
|
2355
3049
|
this.fileLoggingEnabled = true;
|
|
2356
|
-
const
|
|
3050
|
+
const fs2 = getFileSystem();
|
|
2357
3051
|
this.pendingInit = (async () => {
|
|
2358
|
-
const [error] = await
|
|
2359
|
-
await
|
|
2360
|
-
await
|
|
3052
|
+
const [error] = await catchError((async () => {
|
|
3053
|
+
await fs2.mkdir(fs2.path.dirname(path2));
|
|
3054
|
+
await fs2.writeFile(path2, "");
|
|
2361
3055
|
})());
|
|
2362
3056
|
if (error)
|
|
2363
3057
|
this.fileLoggingEnabled = false;
|
|
@@ -2411,12 +3105,12 @@ var jmespathSlot = singleton("JmespathCodec");
|
|
|
2411
3105
|
async function loadOutputCodecsAsync(needed) {
|
|
2412
3106
|
const loads = [];
|
|
2413
3107
|
if (needed.yaml && yamlSlot.get() === undefined) {
|
|
2414
|
-
loads.push(import("./js-yaml-
|
|
3108
|
+
loads.push(import("./js-yaml-b2jq67kn.js").then((mod) => {
|
|
2415
3109
|
yamlSlot.set(mod);
|
|
2416
3110
|
}));
|
|
2417
3111
|
}
|
|
2418
3112
|
if (needed.filter && jmespathSlot.get() === undefined) {
|
|
2419
|
-
loads.push(import("./index-
|
|
3113
|
+
loads.push(import("./index-gpd94m28.js").then((mod) => {
|
|
2420
3114
|
jmespathSlot.set(mod);
|
|
2421
3115
|
}));
|
|
2422
3116
|
}
|
|
@@ -2674,7 +3368,7 @@ function readRegistryValue(keyPath, valueName) {
|
|
|
2674
3368
|
if (process.platform !== "win32") {
|
|
2675
3369
|
return "";
|
|
2676
3370
|
}
|
|
2677
|
-
const [error, output] =
|
|
3371
|
+
const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
|
|
2678
3372
|
encoding: "utf-8",
|
|
2679
3373
|
stdio: ["pipe", "pipe", "pipe"]
|
|
2680
3374
|
}));
|
|
@@ -2697,27 +3391,41 @@ class LoggerTelemetryProvider {
|
|
|
2697
3391
|
...this.analyticsUniqueId ? { analyticsUniqueId: this.analyticsUniqueId } : {}
|
|
2698
3392
|
};
|
|
2699
3393
|
}
|
|
2700
|
-
async trackEvent(
|
|
2701
|
-
logger.debug(formatMessage("Event",
|
|
3394
|
+
async trackEvent({ name, properties }) {
|
|
3395
|
+
logger.debug(formatMessage("Event", name, this.enrich(properties)));
|
|
2702
3396
|
}
|
|
2703
|
-
async trackException(
|
|
3397
|
+
async trackException({
|
|
3398
|
+
error,
|
|
3399
|
+
properties
|
|
3400
|
+
}) {
|
|
2704
3401
|
logger.error(formatMessage("Exception", error.message, this.enrich({
|
|
2705
3402
|
...properties,
|
|
2706
3403
|
stack: error.stack
|
|
2707
3404
|
})));
|
|
2708
3405
|
}
|
|
2709
|
-
async trackRequest(
|
|
3406
|
+
async trackRequest({
|
|
3407
|
+
name,
|
|
3408
|
+
durationMs,
|
|
3409
|
+
success,
|
|
3410
|
+
properties
|
|
3411
|
+
}) {
|
|
2710
3412
|
logger.debug(formatMessage("Request", name, this.enrich({
|
|
2711
3413
|
...properties,
|
|
2712
|
-
duration: `${
|
|
3414
|
+
duration: `${durationMs}ms`,
|
|
2713
3415
|
success
|
|
2714
3416
|
})));
|
|
2715
3417
|
}
|
|
2716
|
-
async trackDependency(
|
|
3418
|
+
async trackDependency({
|
|
3419
|
+
name,
|
|
3420
|
+
type,
|
|
3421
|
+
durationMs,
|
|
3422
|
+
success,
|
|
3423
|
+
properties
|
|
3424
|
+
}) {
|
|
2717
3425
|
logger.debug(formatMessage("Dependency", name, this.enrich({
|
|
2718
3426
|
...properties,
|
|
2719
3427
|
type,
|
|
2720
|
-
duration: `${
|
|
3428
|
+
duration: `${durationMs}ms`,
|
|
2721
3429
|
success
|
|
2722
3430
|
})));
|
|
2723
3431
|
}
|
|
@@ -2916,201 +3624,73 @@ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
|
|
|
2916
3624
|
function getProcessEnv2() {
|
|
2917
3625
|
return globalThis.process?.env;
|
|
2918
3626
|
}
|
|
2919
|
-
function normalizeSessionId(value) {
|
|
2920
|
-
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
2921
|
-
return;
|
|
2922
|
-
}
|
|
2923
|
-
const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
|
|
2924
|
-
return cleaned || undefined;
|
|
2925
|
-
}
|
|
2926
|
-
function getConfiguredTelemetrySessionId() {
|
|
2927
|
-
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
2928
|
-
}
|
|
2929
|
-
function getInheritedSession(env) {
|
|
2930
|
-
for (const candidate of INHERITED_SESSION_SOURCES) {
|
|
2931
|
-
const handle = normalizeSessionId(env[candidate.envVar]);
|
|
2932
|
-
if (handle) {
|
|
2933
|
-
return { id: handle, source: candidate.source };
|
|
2934
|
-
}
|
|
2935
|
-
}
|
|
2936
|
-
return;
|
|
2937
|
-
}
|
|
2938
|
-
function generateRandomSession() {
|
|
2939
|
-
const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
|
|
2940
|
-
crypto.getRandomValues(bytes);
|
|
2941
|
-
let hex = "";
|
|
2942
|
-
for (const byte of bytes) {
|
|
2943
|
-
hex += byte.toString(16).padStart(2, "0");
|
|
2944
|
-
}
|
|
2945
|
-
return { id: hex, source: "random" };
|
|
2946
|
-
}
|
|
2947
|
-
function resolveTelemetrySession() {
|
|
2948
|
-
const existing = telemetrySessionSlot.get();
|
|
2949
|
-
if (existing) {
|
|
2950
|
-
return existing;
|
|
2951
|
-
}
|
|
2952
|
-
const declaredHandle = getConfiguredTelemetrySessionId();
|
|
2953
|
-
const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
|
|
2954
|
-
telemetrySessionSlot.set(resolved);
|
|
2955
|
-
return resolved;
|
|
2956
|
-
}
|
|
2957
|
-
function getTelemetrySessionSource() {
|
|
2958
|
-
return resolveTelemetrySession().source;
|
|
2959
|
-
}
|
|
2960
|
-
function getTelemetryOperationId() {
|
|
2961
|
-
const existing = telemetryOperationIdSlot.get();
|
|
2962
|
-
if (existing) {
|
|
2963
|
-
return existing;
|
|
2964
|
-
}
|
|
2965
|
-
const inboundTraceId = getInboundTraceContext()?.traceId;
|
|
2966
|
-
const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
|
|
2967
|
-
telemetryOperationIdSlot.set(generated);
|
|
2968
|
-
return generated;
|
|
2969
|
-
}
|
|
2970
|
-
// ../common/src/telemetry/global-telemetry-properties.ts
|
|
2971
|
-
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
2972
|
-
function getGlobalTelemetryProperties() {
|
|
2973
|
-
return telemetryPropsSlot.get();
|
|
2974
|
-
}
|
|
2975
|
-
|
|
2976
|
-
// ../common/src/telemetry/pii-redactor.ts
|
|
2977
|
-
var REDACTED = "[REDACTED]";
|
|
2978
|
-
var MAX_VALUE_LENGTH = 200;
|
|
2979
|
-
var SENSITIVE_NAME_TOKENS = new Set([
|
|
2980
|
-
"token",
|
|
2981
|
-
"tokens",
|
|
2982
|
-
"secret",
|
|
2983
|
-
"secrets",
|
|
2984
|
-
"password",
|
|
2985
|
-
"passwords",
|
|
2986
|
-
"pwd",
|
|
2987
|
-
"credential",
|
|
2988
|
-
"credentials",
|
|
2989
|
-
"auth",
|
|
2990
|
-
"authentication",
|
|
2991
|
-
"authorization",
|
|
2992
|
-
"authority",
|
|
2993
|
-
"cert",
|
|
2994
|
-
"certificate",
|
|
2995
|
-
"certificates"
|
|
2996
|
-
]);
|
|
2997
|
-
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
2998
|
-
"api",
|
|
2999
|
-
"access",
|
|
3000
|
-
"client",
|
|
3001
|
-
"private",
|
|
3002
|
-
"public",
|
|
3003
|
-
"signing",
|
|
3004
|
-
"encryption",
|
|
3005
|
-
"session",
|
|
3006
|
-
"master",
|
|
3007
|
-
"shared",
|
|
3008
|
-
"root",
|
|
3009
|
-
"ssh",
|
|
3010
|
-
"rsa",
|
|
3011
|
-
"aes",
|
|
3012
|
-
"hmac",
|
|
3013
|
-
"oauth"
|
|
3014
|
-
]);
|
|
3015
|
-
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;
|
|
3016
|
-
var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
3017
|
-
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
3018
|
-
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
3019
|
-
var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
|
|
3020
|
-
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
3021
|
-
var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
|
|
3022
|
-
function shortHash(input) {
|
|
3023
|
-
let hash = 2166136261;
|
|
3024
|
-
for (let i = 0;i < input.length; i++) {
|
|
3025
|
-
hash ^= input.charCodeAt(i);
|
|
3026
|
-
hash = Math.imul(hash, 16777619);
|
|
3027
|
-
}
|
|
3028
|
-
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
3029
|
-
}
|
|
3030
|
-
function redactUrl(raw) {
|
|
3031
|
-
try {
|
|
3032
|
-
const url = new URL(raw);
|
|
3033
|
-
return `${url.protocol}//${url.host}`;
|
|
3034
|
-
} catch {
|
|
3035
|
-
return `url#${shortHash(raw)}`;
|
|
3036
|
-
}
|
|
3037
|
-
}
|
|
3038
|
-
function redactValueDetectors(value) {
|
|
3039
|
-
let out = value;
|
|
3040
|
-
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
3041
|
-
out = out.replace(URL_PATTERN, (match) => {
|
|
3042
|
-
const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
|
|
3043
|
-
const core = trailing ? match.slice(0, -trailing.length) : match;
|
|
3044
|
-
return `${redactUrl(core)}${trailing}`;
|
|
3045
|
-
});
|
|
3046
|
-
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
3047
|
-
out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
|
|
3048
|
-
out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
|
|
3049
|
-
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
3050
|
-
if (out.length > MAX_VALUE_LENGTH) {
|
|
3051
|
-
out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
|
|
3052
|
-
}
|
|
3053
|
-
return out;
|
|
3054
|
-
}
|
|
3055
|
-
function redactValue(value) {
|
|
3056
|
-
return redactValueDetectors(value);
|
|
3057
|
-
}
|
|
3058
|
-
function redactError(error) {
|
|
3059
|
-
const safe = new Error(redactValueDetectors(error.message ?? ""));
|
|
3060
|
-
safe.name = error.name;
|
|
3061
|
-
safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
|
|
3062
|
-
return safe;
|
|
3063
|
-
}
|
|
3064
|
-
function nameTokens(name) {
|
|
3065
|
-
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);
|
|
3066
|
-
}
|
|
3067
|
-
function isSensitiveName(name) {
|
|
3068
|
-
const tokens = nameTokens(name);
|
|
3069
|
-
for (let i = 0;i < tokens.length; i++) {
|
|
3070
|
-
const token = tokens[i];
|
|
3071
|
-
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
3072
|
-
return true;
|
|
3073
|
-
}
|
|
3074
|
-
if (token === "key" || token === "keys") {
|
|
3075
|
-
const prev = tokens[i - 1];
|
|
3076
|
-
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
3077
|
-
return true;
|
|
3078
|
-
}
|
|
3079
|
-
}
|
|
3080
|
-
}
|
|
3081
|
-
return false;
|
|
3082
|
-
}
|
|
3083
|
-
function redactProperty(name, value) {
|
|
3084
|
-
if (value === undefined || value === null) {
|
|
3627
|
+
function normalizeSessionId(value) {
|
|
3628
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
3085
3629
|
return;
|
|
3086
3630
|
}
|
|
3087
|
-
|
|
3088
|
-
|
|
3631
|
+
const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
|
|
3632
|
+
return cleaned || undefined;
|
|
3633
|
+
}
|
|
3634
|
+
function getConfiguredTelemetrySessionId() {
|
|
3635
|
+
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
3636
|
+
}
|
|
3637
|
+
function getInheritedSession(env) {
|
|
3638
|
+
for (const candidate of INHERITED_SESSION_SOURCES) {
|
|
3639
|
+
const handle = normalizeSessionId(env[candidate.envVar]);
|
|
3640
|
+
if (handle) {
|
|
3641
|
+
return { id: handle, source: candidate.source };
|
|
3642
|
+
}
|
|
3089
3643
|
}
|
|
3090
|
-
|
|
3091
|
-
|
|
3644
|
+
return;
|
|
3645
|
+
}
|
|
3646
|
+
function generateRandomSession() {
|
|
3647
|
+
const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
|
|
3648
|
+
crypto.getRandomValues(bytes);
|
|
3649
|
+
let hex = "";
|
|
3650
|
+
for (const byte of bytes) {
|
|
3651
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
3092
3652
|
}
|
|
3093
|
-
|
|
3094
|
-
|
|
3653
|
+
return { id: hex, source: "random" };
|
|
3654
|
+
}
|
|
3655
|
+
function resolveTelemetrySession() {
|
|
3656
|
+
const existing = telemetrySessionSlot.get();
|
|
3657
|
+
if (existing) {
|
|
3658
|
+
return existing;
|
|
3095
3659
|
}
|
|
3096
|
-
|
|
3660
|
+
const declaredHandle = getConfiguredTelemetrySessionId();
|
|
3661
|
+
const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
|
|
3662
|
+
telemetrySessionSlot.set(resolved);
|
|
3663
|
+
return resolved;
|
|
3097
3664
|
}
|
|
3098
|
-
function
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3665
|
+
function getTelemetrySessionSource() {
|
|
3666
|
+
return resolveTelemetrySession().source;
|
|
3667
|
+
}
|
|
3668
|
+
function getTelemetryOperationId() {
|
|
3669
|
+
const existing = telemetryOperationIdSlot.get();
|
|
3670
|
+
if (existing) {
|
|
3671
|
+
return existing;
|
|
3105
3672
|
}
|
|
3106
|
-
|
|
3673
|
+
const inboundTraceId = getInboundTraceContext()?.traceId;
|
|
3674
|
+
const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
|
|
3675
|
+
telemetryOperationIdSlot.set(generated);
|
|
3676
|
+
return generated;
|
|
3677
|
+
}
|
|
3678
|
+
// ../common/src/telemetry/global-telemetry-properties.ts
|
|
3679
|
+
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
3680
|
+
function getGlobalTelemetryProperties() {
|
|
3681
|
+
return telemetryPropsSlot.get();
|
|
3107
3682
|
}
|
|
3108
3683
|
|
|
3109
|
-
// ../common/src/telemetry/
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3684
|
+
// ../common/src/telemetry/span-clock.ts
|
|
3685
|
+
function startSpanClock() {
|
|
3686
|
+
const started = performance.now();
|
|
3687
|
+
return {
|
|
3688
|
+
startedAt: new Date(performance.timeOrigin + started),
|
|
3689
|
+
elapsedMs: () => performance.now() - started
|
|
3690
|
+
};
|
|
3691
|
+
}
|
|
3113
3692
|
|
|
3693
|
+
// ../common/src/telemetry/telemetry-service.ts
|
|
3114
3694
|
class TelemetryService {
|
|
3115
3695
|
telemetryProvider;
|
|
3116
3696
|
contextStorage;
|
|
@@ -3130,36 +3710,39 @@ class TelemetryService {
|
|
|
3130
3710
|
this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
|
|
3131
3711
|
}
|
|
3132
3712
|
trackEvent(name, properties) {
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3713
|
+
this.telemetryProvider.trackEvent({
|
|
3714
|
+
name: redactSpanName(name),
|
|
3715
|
+
properties: this.enrichProperties(properties),
|
|
3716
|
+
...this.leafCorrelation()
|
|
3717
|
+
});
|
|
3136
3718
|
}
|
|
3137
|
-
trackException(error, properties) {
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3719
|
+
trackException(error, properties, context) {
|
|
3720
|
+
this.telemetryProvider.trackException({
|
|
3721
|
+
error: redactError(error),
|
|
3722
|
+
properties: this.enrichProperties(properties),
|
|
3723
|
+
...this.leafCorrelation(context)
|
|
3724
|
+
});
|
|
3141
3725
|
}
|
|
3142
3726
|
async trackRequest(name, fn, properties) {
|
|
3143
|
-
const parentContext = this.
|
|
3727
|
+
const parentContext = this.getActiveContext();
|
|
3144
3728
|
const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
|
|
3145
3729
|
const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
|
|
3730
|
+
const clock = startSpanClock();
|
|
3146
3731
|
const context = {
|
|
3147
3732
|
operationId,
|
|
3148
3733
|
...parentId !== undefined ? { parentId } : {},
|
|
3149
|
-
id: this.generateId()
|
|
3734
|
+
id: this.generateId(),
|
|
3735
|
+
startedAt: clock.startedAt
|
|
3150
3736
|
};
|
|
3151
|
-
const startTime = performance.now();
|
|
3152
3737
|
try {
|
|
3153
3738
|
const result = await this.contextStorage.run(context, fn);
|
|
3154
|
-
const durationMs =
|
|
3155
|
-
|
|
3156
|
-
await this.telemetryProvider.trackRequest(name, durationMs, true, enrichedProperties);
|
|
3739
|
+
const durationMs = clock.elapsedMs();
|
|
3740
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, true, properties, context));
|
|
3157
3741
|
return result;
|
|
3158
3742
|
} catch (error) {
|
|
3159
|
-
const durationMs =
|
|
3743
|
+
const durationMs = clock.elapsedMs();
|
|
3160
3744
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
3161
|
-
|
|
3162
|
-
await this.telemetryProvider.trackRequest(name, durationMs, false, enrichedProperties);
|
|
3745
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, context));
|
|
3163
3746
|
throw error;
|
|
3164
3747
|
}
|
|
3165
3748
|
}
|
|
@@ -3168,8 +3751,7 @@ class TelemetryService {
|
|
|
3168
3751
|
operationId: this.operationId ?? getTelemetryOperationId(),
|
|
3169
3752
|
id: this.generateId()
|
|
3170
3753
|
};
|
|
3171
|
-
|
|
3172
|
-
this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
|
|
3754
|
+
this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, success, properties, requestContext));
|
|
3173
3755
|
}
|
|
3174
3756
|
createRequestContext() {
|
|
3175
3757
|
const operationId = this.operationId ?? getTelemetryOperationId();
|
|
@@ -3177,7 +3759,8 @@ class TelemetryService {
|
|
|
3177
3759
|
return {
|
|
3178
3760
|
operationId,
|
|
3179
3761
|
...parentId !== undefined ? { parentId } : {},
|
|
3180
|
-
id: this.generateId()
|
|
3762
|
+
id: this.generateId(),
|
|
3763
|
+
startedAt: startSpanClock().startedAt
|
|
3181
3764
|
};
|
|
3182
3765
|
}
|
|
3183
3766
|
inboundParentIdFor(operationId) {
|
|
@@ -3188,58 +3771,84 @@ class TelemetryService {
|
|
|
3188
3771
|
return this.contextStorage.run(context, fn);
|
|
3189
3772
|
}
|
|
3190
3773
|
createDependencyContext() {
|
|
3191
|
-
const parentContext = this.
|
|
3774
|
+
const parentContext = this.getActiveContext();
|
|
3192
3775
|
if (!parentContext) {
|
|
3193
3776
|
return;
|
|
3194
3777
|
}
|
|
3195
3778
|
return {
|
|
3196
3779
|
operationId: parentContext.operationId,
|
|
3197
3780
|
parentId: parentContext.id,
|
|
3198
|
-
id: this.generateId()
|
|
3781
|
+
id: this.generateId(),
|
|
3782
|
+
startedAt: startSpanClock().startedAt
|
|
3199
3783
|
};
|
|
3200
3784
|
}
|
|
3201
3785
|
trackDependencyResult(name, type, durationMs, success, properties, context, resultCode) {
|
|
3202
|
-
|
|
3203
|
-
|
|
3786
|
+
this.telemetryProvider.trackDependency({
|
|
3787
|
+
...this.spanFor(redactHttpDependencyName(name), durationMs, success, properties, context),
|
|
3788
|
+
type,
|
|
3789
|
+
...resultCode !== undefined ? { resultCode } : {}
|
|
3790
|
+
});
|
|
3204
3791
|
}
|
|
3205
3792
|
async trackDependencyOperation(name, type, fn, properties) {
|
|
3206
|
-
const
|
|
3793
|
+
const clock = startSpanClock();
|
|
3794
|
+
const parentContext = this.getActiveContext();
|
|
3207
3795
|
const childContext = parentContext !== undefined ? {
|
|
3208
3796
|
operationId: parentContext.operationId,
|
|
3209
3797
|
parentId: parentContext.id,
|
|
3210
|
-
id: this.generateId()
|
|
3211
|
-
|
|
3212
|
-
|
|
3798
|
+
id: this.generateId(),
|
|
3799
|
+
startedAt: clock.startedAt
|
|
3800
|
+
} : {
|
|
3801
|
+
...this.createRequestContext(),
|
|
3802
|
+
startedAt: clock.startedAt
|
|
3803
|
+
};
|
|
3213
3804
|
try {
|
|
3214
3805
|
const result = await this.contextStorage.run(childContext, fn);
|
|
3215
|
-
const durationMs =
|
|
3216
|
-
|
|
3217
|
-
|
|
3806
|
+
const durationMs = clock.elapsedMs();
|
|
3807
|
+
await this.telemetryProvider.trackDependency({
|
|
3808
|
+
...this.spanFor(name, durationMs, true, properties, childContext),
|
|
3809
|
+
type
|
|
3810
|
+
});
|
|
3218
3811
|
return result;
|
|
3219
3812
|
} catch (error) {
|
|
3220
|
-
const durationMs =
|
|
3813
|
+
const durationMs = clock.elapsedMs();
|
|
3221
3814
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
3222
|
-
|
|
3223
|
-
|
|
3815
|
+
await this.telemetryProvider.trackDependency({
|
|
3816
|
+
...this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, childContext),
|
|
3817
|
+
type
|
|
3818
|
+
});
|
|
3224
3819
|
throw error;
|
|
3225
3820
|
}
|
|
3226
3821
|
}
|
|
3227
|
-
|
|
3822
|
+
getActiveContext() {
|
|
3228
3823
|
return this.contextStorage.getContext();
|
|
3229
3824
|
}
|
|
3230
|
-
|
|
3825
|
+
leafCorrelation(explicit) {
|
|
3826
|
+
const context = explicit ?? this.getActiveContext();
|
|
3827
|
+
return {
|
|
3828
|
+
operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
|
|
3829
|
+
...context !== undefined ? { parentId: context.id } : {}
|
|
3830
|
+
};
|
|
3831
|
+
}
|
|
3832
|
+
spanFor(name, durationMs, success, properties, context) {
|
|
3833
|
+
return {
|
|
3834
|
+
name: redactSpanName(name),
|
|
3835
|
+
durationMs,
|
|
3836
|
+
success,
|
|
3837
|
+
properties: this.enrichProperties(properties),
|
|
3838
|
+
operationId: context.operationId,
|
|
3839
|
+
...context.parentId !== undefined ? { parentId: context.parentId } : {},
|
|
3840
|
+
id: context.id,
|
|
3841
|
+
...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
enrichProperties(properties) {
|
|
3231
3845
|
const globalProperties = getGlobalTelemetryProperties();
|
|
3232
3846
|
const enriched = {
|
|
3233
3847
|
...getExecutionContextTelemetryProperties(),
|
|
3234
3848
|
...globalProperties,
|
|
3235
3849
|
...this.defaultProperties,
|
|
3236
3850
|
...redactProperties(properties ?? {}),
|
|
3237
|
-
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
|
|
3238
|
-
...context ? {
|
|
3239
|
-
[TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
|
|
3240
|
-
...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
|
|
3241
|
-
[TELEMETRY_SPAN_ID_PROPERTY]: context.id
|
|
3242
|
-
} : {}
|
|
3851
|
+
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
|
|
3243
3852
|
};
|
|
3244
3853
|
return enriched;
|
|
3245
3854
|
}
|
|
@@ -3256,6 +3865,81 @@ class TelemetryService {
|
|
|
3256
3865
|
return hex;
|
|
3257
3866
|
}
|
|
3258
3867
|
}
|
|
3868
|
+
// ../common/src/timings.ts
|
|
3869
|
+
var TIMINGS_ENV_VAR = "UIP_TIMINGS";
|
|
3870
|
+
function createStorage2() {
|
|
3871
|
+
const [error, mod] = catchError(() => __require("node:async_hooks"));
|
|
3872
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
3873
|
+
return {
|
|
3874
|
+
getStore: () => {
|
|
3875
|
+
return;
|
|
3876
|
+
},
|
|
3877
|
+
run: (_store, fn) => fn()
|
|
3878
|
+
};
|
|
3879
|
+
}
|
|
3880
|
+
return new mod.AsyncLocalStorage;
|
|
3881
|
+
}
|
|
3882
|
+
var storageSlot = singleton("TimingStorage");
|
|
3883
|
+
var stateSlot = singleton("Timings");
|
|
3884
|
+
var rootStartedSlot = singleton("TimingsRootStarted");
|
|
3885
|
+
var longLivedHostSlot = singleton("TimingsLongLivedHost");
|
|
3886
|
+
var storage = storageSlot.getOrInit(createStorage2, (value) => ("getStore" in value));
|
|
3887
|
+
function newState(baseline) {
|
|
3888
|
+
return { baseline, httpMs: 0, httpCalls: 0 };
|
|
3889
|
+
}
|
|
3890
|
+
function getState() {
|
|
3891
|
+
const scoped = storage.getStore();
|
|
3892
|
+
if (scoped) {
|
|
3893
|
+
return scoped;
|
|
3894
|
+
}
|
|
3895
|
+
const pinned = livePinnedState();
|
|
3896
|
+
if (pinned !== undefined) {
|
|
3897
|
+
return pinned;
|
|
3898
|
+
}
|
|
3899
|
+
return newState(processStartIsInvocationStart() ? 0 : performance.now());
|
|
3900
|
+
}
|
|
3901
|
+
function livePinnedState() {
|
|
3902
|
+
const pinned = stateSlot.get();
|
|
3903
|
+
return pinned !== undefined && "httpCalls" in pinned && !pinned.finished ? pinned : undefined;
|
|
3904
|
+
}
|
|
3905
|
+
function processStartIsInvocationStart() {
|
|
3906
|
+
return !rootStartedSlot.get(false) && !longLivedHostSlot.get(false);
|
|
3907
|
+
}
|
|
3908
|
+
function timingsEnabled() {
|
|
3909
|
+
if (typeof process === "undefined") {
|
|
3910
|
+
return false;
|
|
3911
|
+
}
|
|
3912
|
+
const value = process.env?.[TIMINGS_ENV_VAR];
|
|
3913
|
+
if (value === undefined) {
|
|
3914
|
+
return false;
|
|
3915
|
+
}
|
|
3916
|
+
const normalized = value.trim().toLowerCase();
|
|
3917
|
+
return normalized === "1" || normalized === "true";
|
|
3918
|
+
}
|
|
3919
|
+
function recordExitCode(exitCode) {
|
|
3920
|
+
if (!timingsEnabled()) {
|
|
3921
|
+
return;
|
|
3922
|
+
}
|
|
3923
|
+
getState().exitCode = exitCode;
|
|
3924
|
+
}
|
|
3925
|
+
function invocationStartedAt() {
|
|
3926
|
+
return new Date(performance.timeOrigin + getState().baseline);
|
|
3927
|
+
}
|
|
3928
|
+
function invocationElapsedMs() {
|
|
3929
|
+
return performance.now() - getState().baseline;
|
|
3930
|
+
}
|
|
3931
|
+
function markCommandStart() {
|
|
3932
|
+
if (!timingsEnabled()) {
|
|
3933
|
+
return;
|
|
3934
|
+
}
|
|
3935
|
+
getState().commandStart = performance.now();
|
|
3936
|
+
}
|
|
3937
|
+
function recordCommandDuration(durationMs) {
|
|
3938
|
+
if (!timingsEnabled()) {
|
|
3939
|
+
return;
|
|
3940
|
+
}
|
|
3941
|
+
getState().commandMs = durationMs;
|
|
3942
|
+
}
|
|
3259
3943
|
// ../common/src/telemetry/proxy-http-agent.ts
|
|
3260
3944
|
var slot = singleton("ProxyAuthHttpsAgent");
|
|
3261
3945
|
|
|
@@ -3276,6 +3960,9 @@ function getGlobalTelemetryInstance() {
|
|
|
3276
3960
|
}
|
|
3277
3961
|
return;
|
|
3278
3962
|
}
|
|
3963
|
+
function setGlobalTelemetryInstance(instance) {
|
|
3964
|
+
telemetryInstanceSlot.set(instance);
|
|
3965
|
+
}
|
|
3279
3966
|
var _localTelemetryInstance;
|
|
3280
3967
|
function getTelemetryInstance() {
|
|
3281
3968
|
const global = getGlobalTelemetryInstance();
|
|
@@ -3283,6 +3970,7 @@ function getTelemetryInstance() {
|
|
|
3283
3970
|
return global;
|
|
3284
3971
|
if (!_localTelemetryInstance) {
|
|
3285
3972
|
_localTelemetryInstance = new TelemetryService(new LoggerTelemetryProvider, new NodeContextStorage);
|
|
3973
|
+
setGlobalTelemetryInstance(_localTelemetryInstance);
|
|
3286
3974
|
}
|
|
3287
3975
|
return _localTelemetryInstance;
|
|
3288
3976
|
}
|
|
@@ -3295,6 +3983,14 @@ var telemetry = new Proxy({}, {
|
|
|
3295
3983
|
});
|
|
3296
3984
|
|
|
3297
3985
|
// ../common/src/formatter.ts
|
|
3986
|
+
var ANSI_STYLES = {
|
|
3987
|
+
red: "\x1B[31m",
|
|
3988
|
+
dim: "\x1B[2m"
|
|
3989
|
+
};
|
|
3990
|
+
var ANSI_RESET = "\x1B[0m";
|
|
3991
|
+
function styleLine(line, style) {
|
|
3992
|
+
return style ? `${ANSI_STYLES[style]}${line}${ANSI_RESET}` : line;
|
|
3993
|
+
}
|
|
3298
3994
|
var CLI_ERROR_CODES = [
|
|
3299
3995
|
"invalid_argument",
|
|
3300
3996
|
"authentication_required",
|
|
@@ -3333,22 +4029,6 @@ var EXIT_CODES = {
|
|
|
3333
4029
|
ValidationError: 3,
|
|
3334
4030
|
TimeoutError: 4
|
|
3335
4031
|
};
|
|
3336
|
-
class SuccessOutput {
|
|
3337
|
-
Result = RESULTS.Success;
|
|
3338
|
-
Code;
|
|
3339
|
-
Data;
|
|
3340
|
-
Pagination;
|
|
3341
|
-
Instructions;
|
|
3342
|
-
Log;
|
|
3343
|
-
constructor(code, data) {
|
|
3344
|
-
this.Code = code;
|
|
3345
|
-
this.Data = data;
|
|
3346
|
-
const logPath = getLogFilePath();
|
|
3347
|
-
if (logPath) {
|
|
3348
|
-
this.Log = logPath;
|
|
3349
|
-
}
|
|
3350
|
-
}
|
|
3351
|
-
}
|
|
3352
4032
|
function escapeNonAscii(jsonText) {
|
|
3353
4033
|
return jsonText.replace(/[\u0080-\uffff]/g, (c) => {
|
|
3354
4034
|
const hex = c.charCodeAt(0).toString(16).padStart(4, "0");
|
|
@@ -3413,19 +4093,45 @@ function toPascalCaseKey(key) {
|
|
|
3413
4093
|
const lowerCamelKey = toLowerCamelCaseKey(key);
|
|
3414
4094
|
return lowerCamelKey ? lowerCamelKey.charAt(0).toUpperCase() + lowerCamelKey.slice(1) : lowerCamelKey;
|
|
3415
4095
|
}
|
|
3416
|
-
function
|
|
4096
|
+
function collectVerbatimRefs(value, into) {
|
|
4097
|
+
if (typeof value !== "object" || value === null)
|
|
4098
|
+
return;
|
|
4099
|
+
if (into.has(value))
|
|
4100
|
+
return;
|
|
4101
|
+
into.add(value);
|
|
4102
|
+
for (const nested of Array.isArray(value) ? value : Object.values(value)) {
|
|
4103
|
+
collectVerbatimRefs(nested, into);
|
|
4104
|
+
}
|
|
4105
|
+
}
|
|
4106
|
+
function toPascalCaseData(value, verbatimKeys, subtrees) {
|
|
4107
|
+
if (subtrees?.mode === "skip" && typeof value === "object" && value !== null && subtrees.refs.has(value)) {
|
|
4108
|
+
return value;
|
|
4109
|
+
}
|
|
3417
4110
|
if (Array.isArray(value))
|
|
3418
|
-
return value.map(toPascalCaseData);
|
|
4111
|
+
return value.map((entry) => toPascalCaseData(entry, verbatimKeys, subtrees));
|
|
3419
4112
|
if (!isPlainRecord(value))
|
|
3420
4113
|
return value;
|
|
3421
4114
|
const result = {};
|
|
3422
4115
|
for (const [key, nestedValue] of Object.entries(value)) {
|
|
3423
|
-
|
|
4116
|
+
const pascalKey = toPascalCaseKey(key);
|
|
4117
|
+
if (verbatimKeys?.has(pascalKey)) {
|
|
4118
|
+
result[pascalKey] = nestedValue;
|
|
4119
|
+
if (subtrees?.mode === "collect") {
|
|
4120
|
+
collectVerbatimRefs(nestedValue, subtrees.refs);
|
|
4121
|
+
}
|
|
4122
|
+
continue;
|
|
4123
|
+
}
|
|
4124
|
+
result[pascalKey] = toPascalCaseData(nestedValue, verbatimKeys, subtrees);
|
|
3424
4125
|
}
|
|
3425
4126
|
return result;
|
|
3426
4127
|
}
|
|
3427
|
-
function normalizeDataKeys(data) {
|
|
3428
|
-
return toPascalCaseData(data);
|
|
4128
|
+
function normalizeDataKeys(data, verbatimKeys, subtrees) {
|
|
4129
|
+
return toPascalCaseData(data, verbatimKeys, subtrees);
|
|
4130
|
+
}
|
|
4131
|
+
function toVerbatimKeySet(preserve) {
|
|
4132
|
+
if (!Array.isArray(preserve))
|
|
4133
|
+
return;
|
|
4134
|
+
return new Set(preserve.map(toPascalCaseKey));
|
|
3429
4135
|
}
|
|
3430
4136
|
function normalizeOutputKeys(data) {
|
|
3431
4137
|
const result = {};
|
|
@@ -3435,7 +4141,7 @@ function normalizeOutputKeys(data) {
|
|
|
3435
4141
|
}
|
|
3436
4142
|
return result;
|
|
3437
4143
|
}
|
|
3438
|
-
function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
4144
|
+
function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowStyle) {
|
|
3439
4145
|
if (!data) {
|
|
3440
4146
|
logFn("Empty response object. No data to display.");
|
|
3441
4147
|
return;
|
|
@@ -3470,7 +4176,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
3470
4176
|
if (hasData && !(rows !== null && rows.length === 0)) {
|
|
3471
4177
|
const logValue = data.Log;
|
|
3472
4178
|
if (rows !== null) {
|
|
3473
|
-
printResizableTable(rows, logFn, logValue);
|
|
4179
|
+
printResizableTable(rows, logFn, logValue, undefined, tableRowStyle);
|
|
3474
4180
|
} else {
|
|
3475
4181
|
printVerticalTable(data.Data, logFn, logValue);
|
|
3476
4182
|
}
|
|
@@ -3481,10 +4187,11 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
3481
4187
|
}
|
|
3482
4188
|
}
|
|
3483
4189
|
}
|
|
3484
|
-
function logOutput(data, format = "json") {
|
|
4190
|
+
function logOutput(data, format = "json", tableRowStyle) {
|
|
3485
4191
|
const sink = getOutputSink();
|
|
4192
|
+
const styleFn = sink.capabilities.isInteractive && sink.capabilities.supportsColor ? tableRowStyle : undefined;
|
|
3486
4193
|
printOutput(data, format, (msg) => sink.writeOut(`${msg}
|
|
3487
|
-
`), needsAsciiSafeJson(sink));
|
|
4194
|
+
`), needsAsciiSafeJson(sink), styleFn);
|
|
3488
4195
|
}
|
|
3489
4196
|
function cellToString(val) {
|
|
3490
4197
|
return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
|
|
@@ -3498,7 +4205,7 @@ function wrapText(text, width) {
|
|
|
3498
4205
|
}
|
|
3499
4206
|
return lines;
|
|
3500
4207
|
}
|
|
3501
|
-
function printTable(data, logFn, externalLogValue) {
|
|
4208
|
+
function printTable(data, logFn, externalLogValue, tableRowStyle) {
|
|
3502
4209
|
if (data.length === 0)
|
|
3503
4210
|
return;
|
|
3504
4211
|
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
@@ -3508,7 +4215,7 @@ function printTable(data, logFn, externalLogValue) {
|
|
|
3508
4215
|
logFn(keys.map((_, i) => "-".repeat(maxWidths[i])).join("-|-"));
|
|
3509
4216
|
data.forEach((item) => {
|
|
3510
4217
|
const row = keys.map((key, i) => cellToString(item[key]).padEnd(maxWidths[i])).join(" | ");
|
|
3511
|
-
logFn(row);
|
|
4218
|
+
logFn(styleLine(row, tableRowStyle?.(item)));
|
|
3512
4219
|
});
|
|
3513
4220
|
if (externalLogValue) {
|
|
3514
4221
|
logFn("");
|
|
@@ -3551,14 +4258,14 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
|
3551
4258
|
logFn(`Log: ${externalLogValue}`);
|
|
3552
4259
|
}
|
|
3553
4260
|
}
|
|
3554
|
-
function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth) {
|
|
4261
|
+
function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
|
|
3555
4262
|
if (data.length === 0)
|
|
3556
4263
|
return;
|
|
3557
4264
|
const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
|
|
3558
4265
|
if (keys.length === 0)
|
|
3559
4266
|
return;
|
|
3560
4267
|
if (!process.stdout.isTTY) {
|
|
3561
|
-
printTable(data, logFn, externalLogValue);
|
|
4268
|
+
printTable(data, logFn, externalLogValue, tableRowStyle);
|
|
3562
4269
|
return;
|
|
3563
4270
|
}
|
|
3564
4271
|
const naturalWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
|
|
@@ -3566,7 +4273,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
3566
4273
|
const totalWidth = naturalWidths.reduce((a, b) => a + b, 0) + separatorTotal;
|
|
3567
4274
|
const termWidth = availableWidth ?? (process.stdout.columns || 120);
|
|
3568
4275
|
if (totalWidth <= termWidth) {
|
|
3569
|
-
printTable(data, logFn, externalLogValue);
|
|
4276
|
+
printTable(data, logFn, externalLogValue, tableRowStyle);
|
|
3570
4277
|
return;
|
|
3571
4278
|
}
|
|
3572
4279
|
const overflow = totalWidth - termWidth;
|
|
@@ -3612,6 +4319,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
3612
4319
|
logFn(header);
|
|
3613
4320
|
logFn(keys.map((_, i) => "-".repeat(finalWidths[i])).join("-|-"));
|
|
3614
4321
|
data.forEach((item) => {
|
|
4322
|
+
const style = tableRowStyle?.(item);
|
|
3615
4323
|
const cellLines = keys.map((key, i) => wrapText(cellToString(item[key]), finalWidths[i]));
|
|
3616
4324
|
const lineCount = Math.max(...cellLines.map((l) => l.length));
|
|
3617
4325
|
for (let line = 0;line < lineCount; line++) {
|
|
@@ -3619,7 +4327,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
3619
4327
|
const val = line < cellLines[i].length ? cellLines[i][line] : "";
|
|
3620
4328
|
return val.padEnd(finalWidths[i]);
|
|
3621
4329
|
}).join(" | ");
|
|
3622
|
-
logFn(row);
|
|
4330
|
+
logFn(styleLine(row, style));
|
|
3623
4331
|
}
|
|
3624
4332
|
});
|
|
3625
4333
|
if (externalLogValue) {
|
|
@@ -3763,30 +4471,36 @@ var OutputFormatter;
|
|
|
3763
4471
|
((OutputFormatter) => {
|
|
3764
4472
|
function success(data, options) {
|
|
3765
4473
|
data.Log ??= getLogFilePath() || undefined;
|
|
3766
|
-
const normalize =
|
|
4474
|
+
const normalize = options?.preserveDataKeys !== true;
|
|
4475
|
+
const verbatim = toVerbatimKeySet(options?.preserveDataKeys);
|
|
4476
|
+
const subtrees = verbatim && {
|
|
4477
|
+
refs: new Set,
|
|
4478
|
+
mode: "collect"
|
|
4479
|
+
};
|
|
3767
4480
|
if (normalize) {
|
|
3768
|
-
data.Data = normalizeDataKeys(data.Data);
|
|
4481
|
+
data.Data = normalizeDataKeys(data.Data, verbatim, subtrees);
|
|
3769
4482
|
}
|
|
3770
4483
|
const filter = getOutputFilter();
|
|
3771
4484
|
if (filter) {
|
|
3772
4485
|
const filtered = applyFilter(data.Data, filter);
|
|
3773
|
-
data.Data = normalize ? normalizeDataKeys(filtered) : filtered;
|
|
4486
|
+
data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
|
|
3774
4487
|
}
|
|
3775
|
-
logOutput(normalizeOutputKeys(data), getOutputFormat());
|
|
4488
|
+
logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
|
|
3776
4489
|
}
|
|
3777
4490
|
OutputFormatter.success = success;
|
|
3778
4491
|
function error(data) {
|
|
3779
4492
|
data.Log ??= getLogFilePath() || undefined;
|
|
3780
4493
|
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
3781
4494
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
3782
|
-
|
|
4495
|
+
const exitCode = EXIT_CODES[data.Result] ?? 1;
|
|
4496
|
+
setExitCode(exitCode);
|
|
3783
4497
|
recordCommandFailureTelemetry({
|
|
3784
4498
|
result: data.Result,
|
|
3785
4499
|
errorCode: data.ErrorCode,
|
|
3786
4500
|
retry: data.Retry,
|
|
3787
4501
|
message: data.Message,
|
|
3788
4502
|
context: data.Context,
|
|
3789
|
-
exitCode
|
|
4503
|
+
exitCode,
|
|
3790
4504
|
errorClass: data.TelemetryErrorClass,
|
|
3791
4505
|
terminalOutcome: data.TelemetryTerminalOutcome,
|
|
3792
4506
|
terminalSignal: data.TelemetryTerminalSignal
|
|
@@ -4016,6 +4730,57 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
|
|
|
4016
4730
|
};
|
|
4017
4731
|
}
|
|
4018
4732
|
|
|
4733
|
+
// ../common/src/telemetry/command-name.ts
|
|
4734
|
+
var TELEMETRY_COMMAND_ROOT = "uip";
|
|
4735
|
+
function commandTelemetryName(parts) {
|
|
4736
|
+
const tokens = [];
|
|
4737
|
+
for (const part of parts) {
|
|
4738
|
+
const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== TELEMETRY_COMMAND_ROOT);
|
|
4739
|
+
if (pieces.every(isCommandToken)) {
|
|
4740
|
+
tokens.push(...pieces);
|
|
4741
|
+
continue;
|
|
4742
|
+
}
|
|
4743
|
+
tokens.push(UNKNOWN_TOKEN);
|
|
4744
|
+
}
|
|
4745
|
+
return [TELEMETRY_COMMAND_ROOT, ...tokens].join(".");
|
|
4746
|
+
}
|
|
4747
|
+
var COMMAND_TOKEN_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
4748
|
+
var MAX_COMMAND_TOKEN_LENGTH = 32;
|
|
4749
|
+
var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
4750
|
+
function isCommandToken(token) {
|
|
4751
|
+
return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token) && !/^\d+$/.test(token);
|
|
4752
|
+
}
|
|
4753
|
+
var UNKNOWN_TOKEN = "<unknown>";
|
|
4754
|
+
|
|
4755
|
+
// ../common/src/telemetry/invocation-request.ts
|
|
4756
|
+
var requestContextSlot = singleton("TelemetryInvocationRequestContext");
|
|
4757
|
+
function activeContext() {
|
|
4758
|
+
return telemetry.getActiveContext?.();
|
|
4759
|
+
}
|
|
4760
|
+
function runWithInvocationRequest(fn) {
|
|
4761
|
+
const context = telemetry.createRequestContext();
|
|
4762
|
+
context.startedAt = invocationStartedAt();
|
|
4763
|
+
requestContextSlot.set(context);
|
|
4764
|
+
return telemetry.runWithContext(context, fn);
|
|
4765
|
+
}
|
|
4766
|
+
function ensureInvocationRequestScope(fn) {
|
|
4767
|
+
if (activeContext() !== undefined) {
|
|
4768
|
+
return fn();
|
|
4769
|
+
}
|
|
4770
|
+
const kept = requestContextSlot.get();
|
|
4771
|
+
return kept === undefined ? runWithInvocationRequest(fn) : telemetry.runWithContext(kept, fn);
|
|
4772
|
+
}
|
|
4773
|
+
function getInvocationRequestContext() {
|
|
4774
|
+
return activeContext() ?? requestContextSlot.get();
|
|
4775
|
+
}
|
|
4776
|
+
function emitInvocationRequest(name, success, properties) {
|
|
4777
|
+
const context = getInvocationRequestContext();
|
|
4778
|
+
telemetry.trackRequestResult(name, invocationElapsedMs(), success, properties, context);
|
|
4779
|
+
if (context !== undefined && requestContextSlot.get() === context) {
|
|
4780
|
+
requestContextSlot.clear();
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4783
|
+
|
|
4019
4784
|
// ../common/src/trackedAction.ts
|
|
4020
4785
|
var pollSignalSlot = singleton("PollSignal");
|
|
4021
4786
|
var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
|
|
@@ -4023,28 +4788,74 @@ var retryHintValues = new Set(RETRY_HINTS);
|
|
|
4023
4788
|
var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
|
|
4024
4789
|
var processContext = {
|
|
4025
4790
|
exit: (code) => {
|
|
4026
|
-
|
|
4791
|
+
recordExitCode(code);
|
|
4792
|
+
setExitCode(code);
|
|
4027
4793
|
},
|
|
4028
4794
|
get pollSignal() {
|
|
4029
4795
|
return pollSignalSlot.get();
|
|
4030
4796
|
}
|
|
4031
4797
|
};
|
|
4798
|
+
var TELEMETRY_ARG_VALUE_WITHHELD = "<provided>";
|
|
4799
|
+
var TELEMETRY_ARG_VALUE_DEFAULTED = "<default>";
|
|
4800
|
+
function recordableArgValue(value, choices) {
|
|
4801
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
4802
|
+
return value;
|
|
4803
|
+
}
|
|
4804
|
+
if (choices && choices.length > 0) {
|
|
4805
|
+
if (typeof value === "string" && choices.includes(value)) {
|
|
4806
|
+
return value;
|
|
4807
|
+
}
|
|
4808
|
+
if (Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string" && choices.includes(entry))) {
|
|
4809
|
+
return value.join(",");
|
|
4810
|
+
}
|
|
4811
|
+
}
|
|
4812
|
+
return TELEMETRY_ARG_VALUE_WITHHELD;
|
|
4813
|
+
}
|
|
4032
4814
|
function extractCommandParams(cmd) {
|
|
4033
4815
|
const params = {};
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4816
|
+
forEachSuppliedArgument(cmd, (name, value, choices, defaulted) => {
|
|
4817
|
+
const recordable = recordableArgValue(value, choices);
|
|
4818
|
+
params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = recordable === TELEMETRY_ARG_VALUE_WITHHELD && defaulted ? TELEMETRY_ARG_VALUE_DEFAULTED : recordable;
|
|
4819
|
+
});
|
|
4820
|
+
return params;
|
|
4821
|
+
}
|
|
4822
|
+
function isDefaultedOption(cmd, name) {
|
|
4823
|
+
const source = cmd.getOptionValueSource?.(name);
|
|
4824
|
+
return source === "default" || source === "implied";
|
|
4825
|
+
}
|
|
4826
|
+
function isDefaultedPositional(cmd, index) {
|
|
4827
|
+
return index >= (cmd.args?.length ?? 0);
|
|
4828
|
+
}
|
|
4829
|
+
function forEachSuppliedArgument(cmd, visit) {
|
|
4039
4830
|
const registered = cmd.registeredArguments ?? [];
|
|
4040
4831
|
const processed = cmd.processedArgs ?? [];
|
|
4041
4832
|
for (let i = 0;i < registered.length; i++) {
|
|
4042
|
-
|
|
4833
|
+
const name = registered[i].name();
|
|
4834
|
+
if (name && processed[i] !== undefined) {
|
|
4835
|
+
visit(name, processed[i], registered[i].argChoices, isDefaultedPositional(cmd, i));
|
|
4836
|
+
}
|
|
4837
|
+
}
|
|
4838
|
+
const choicesByAttribute = new Map;
|
|
4839
|
+
for (const option of cmd.options) {
|
|
4840
|
+
choicesByAttribute.set(option.attributeName(), option.argChoices);
|
|
4043
4841
|
}
|
|
4044
4842
|
for (const [key, value] of Object.entries(cmd.opts())) {
|
|
4045
|
-
|
|
4843
|
+
if (key && value !== undefined) {
|
|
4844
|
+
visit(key, value, choicesByAttribute.get(key), isDefaultedOption(cmd, key));
|
|
4845
|
+
}
|
|
4046
4846
|
}
|
|
4047
|
-
|
|
4847
|
+
}
|
|
4848
|
+
function withheldArgumentValues(cmd) {
|
|
4849
|
+
const values = [];
|
|
4850
|
+
forEachSuppliedArgument(cmd, (_name, value, choices, defaulted) => {
|
|
4851
|
+
if (defaulted) {
|
|
4852
|
+
return;
|
|
4853
|
+
}
|
|
4854
|
+
if (recordableArgValue(value, choices) === TELEMETRY_ARG_VALUE_WITHHELD) {
|
|
4855
|
+
values.push(value);
|
|
4856
|
+
}
|
|
4857
|
+
});
|
|
4858
|
+
return values;
|
|
4048
4859
|
}
|
|
4049
4860
|
function deriveCommandPath(cmd) {
|
|
4050
4861
|
const parts = [];
|
|
@@ -4059,7 +4870,7 @@ function deriveCommandPath(cmd) {
|
|
|
4059
4870
|
if (parts.length > 1) {
|
|
4060
4871
|
parts.shift();
|
|
4061
4872
|
}
|
|
4062
|
-
return
|
|
4873
|
+
return commandTelemetryName(parts);
|
|
4063
4874
|
}
|
|
4064
4875
|
function isCliErrorCode(value) {
|
|
4065
4876
|
return typeof value === "string" && cliErrorCodeValues.has(value);
|
|
@@ -4099,68 +4910,77 @@ Command.prototype.trackedAction = function(context, fn, properties) {
|
|
|
4099
4910
|
});
|
|
4100
4911
|
const telemetryName = deriveCommandPath(command);
|
|
4101
4912
|
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
4102
|
-
|
|
4103
|
-
const
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4913
|
+
markCommandStart();
|
|
4914
|
+
const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
|
|
4915
|
+
try {
|
|
4916
|
+
const startTime = performance.now();
|
|
4917
|
+
let errorMessage;
|
|
4918
|
+
let fallbackExitCode = EXIT_CODES.Success;
|
|
4919
|
+
clearRecordedCommandFailureTelemetry();
|
|
4920
|
+
const [error] = await catchError(ensureInvocationRequestScope(() => {
|
|
4921
|
+
const violation = implicitLimitViolation(command);
|
|
4922
|
+
if (violation) {
|
|
4923
|
+
return Promise.reject(violation);
|
|
4924
|
+
}
|
|
4925
|
+
return fn(...args);
|
|
4926
|
+
}));
|
|
4927
|
+
if (error) {
|
|
4928
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
4929
|
+
logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
|
|
4930
|
+
const typed = error;
|
|
4931
|
+
const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
|
|
4932
|
+
const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
|
|
4933
|
+
const finalResult = customResult ?? RESULTS.Failure;
|
|
4934
|
+
const typedErrorCode = typed.errorCode ?? typed.ErrorCode;
|
|
4935
|
+
const customErrorCode = isCliErrorCode(typedErrorCode) ? typedErrorCode : undefined;
|
|
4936
|
+
const typedRetry = typed.retry ?? typed.Retry;
|
|
4937
|
+
const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
|
|
4938
|
+
const typedContext = typed.context ?? typed.Context;
|
|
4939
|
+
const customContext = isErrorContext(typedContext) ? typedContext : undefined;
|
|
4940
|
+
const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
|
|
4941
|
+
fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
|
|
4942
|
+
OutputFormatter.error({
|
|
4943
|
+
Result: finalResult,
|
|
4944
|
+
...customErrorCode ? { ErrorCode: customErrorCode } : {},
|
|
4945
|
+
Message: errorMessage,
|
|
4946
|
+
Instructions: customInstructions ?? commandHelpHint(telemetryName),
|
|
4947
|
+
...customRetry ? { Retry: customRetry } : {},
|
|
4948
|
+
...customContext ? { Context: customContext } : {}
|
|
4949
|
+
});
|
|
4950
|
+
context.exit(fallbackExitCode);
|
|
4951
|
+
}
|
|
4952
|
+
const durationMs = performance.now() - startTime;
|
|
4953
|
+
recordCommandDuration(durationMs);
|
|
4954
|
+
const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
|
|
4955
|
+
const recordedFailure = takeRecordedCommandFailureTelemetry();
|
|
4956
|
+
const success = !error && exitCode === 0;
|
|
4957
|
+
const terminalTelemetry = buildCommandTerminalTelemetryProperties({
|
|
4958
|
+
error,
|
|
4959
|
+
exitCode,
|
|
4960
|
+
recordedFailure,
|
|
4961
|
+
pollSignal: context.pollSignal
|
|
4136
4962
|
});
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
}
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
|
|
4159
|
-
command: "true",
|
|
4160
|
-
...terminalTelemetry,
|
|
4161
|
-
...errorMessage ? { errorMessage } : {}
|
|
4162
|
-
});
|
|
4163
|
-
telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
|
|
4963
|
+
if (terminalTelemetry.error_class === "internal" && error) {
|
|
4964
|
+
telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { command_name: telemetryName }, getInvocationRequestContext());
|
|
4965
|
+
}
|
|
4966
|
+
const commandParams = extractCommandParams(command);
|
|
4967
|
+
if (props) {
|
|
4968
|
+
for (const key of Object.keys(props)) {
|
|
4969
|
+
delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
|
|
4970
|
+
}
|
|
4971
|
+
}
|
|
4972
|
+
const baseProperties = redactProperties({
|
|
4973
|
+
...commandParams,
|
|
4974
|
+
...props,
|
|
4975
|
+
...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
|
|
4976
|
+
command: "true",
|
|
4977
|
+
...terminalTelemetry,
|
|
4978
|
+
...errorMessage ? { errorMessage } : {}
|
|
4979
|
+
});
|
|
4980
|
+
emitInvocationRequest(telemetryName, success, baseProperties);
|
|
4981
|
+
} finally {
|
|
4982
|
+
releaseSuppliedArgumentValues(supplied);
|
|
4983
|
+
}
|
|
4164
4984
|
});
|
|
4165
4985
|
};
|
|
4166
4986
|
|
|
@@ -4184,6 +5004,17 @@ function dedupeKey(payload) {
|
|
|
4184
5004
|
payload.artifact_correlation_key ?? payload.package_version_key ?? payload.deployment_key ?? payload.solution_id ?? payload.package_name ?? ""
|
|
4185
5005
|
].join("|");
|
|
4186
5006
|
}
|
|
5007
|
+
function withPseudonymizedIdentifiers(payload) {
|
|
5008
|
+
return {
|
|
5009
|
+
...payload,
|
|
5010
|
+
...payload.package_name === undefined ? {} : {
|
|
5011
|
+
package_name: `package#${pseudonymize(payload.package_name)}`
|
|
5012
|
+
},
|
|
5013
|
+
...payload.artifact_correlation_key === undefined ? {} : {
|
|
5014
|
+
artifact_correlation_key: `artifact#${pseudonymize(payload.artifact_correlation_key)}`
|
|
5015
|
+
}
|
|
5016
|
+
};
|
|
5017
|
+
}
|
|
4187
5018
|
function trackShipSucceeded(payload) {
|
|
4188
5019
|
const keys = getShippedKeys();
|
|
4189
5020
|
const key = dedupeKey(payload);
|
|
@@ -4191,7 +5022,7 @@ function trackShipSucceeded(payload) {
|
|
|
4191
5022
|
return false;
|
|
4192
5023
|
}
|
|
4193
5024
|
keys.add(key);
|
|
4194
|
-
telemetry.trackEvent(CommonTelemetryEvents.ShipSucceeded, redactProperties(
|
|
5025
|
+
telemetry.trackEvent(CommonTelemetryEvents.ShipSucceeded, redactProperties(withPseudonymizedIdentifiers(payload)));
|
|
4195
5026
|
return true;
|
|
4196
5027
|
}
|
|
4197
5028
|
|
|
@@ -4233,7 +5064,7 @@ function extractErrorMessageSync(error) {
|
|
|
4233
5064
|
return error.message;
|
|
4234
5065
|
}
|
|
4235
5066
|
}
|
|
4236
|
-
return
|
|
5067
|
+
return describeThrownValue(error);
|
|
4237
5068
|
}
|
|
4238
5069
|
// ../common/src/command-examples.ts
|
|
4239
5070
|
var examplesByCommand = new WeakMap;
|
|
@@ -4258,8 +5089,206 @@ var COMPLETER_SYMBOL = Symbol.for("@uipath/common/completer");
|
|
|
4258
5089
|
var guardInstalledSlot = singleton("ConsoleGuardInstalled");
|
|
4259
5090
|
var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
|
|
4260
5091
|
// ../common/src/constants.ts
|
|
4261
|
-
var
|
|
5092
|
+
var UIPATH_HOME_DIR = ".uipath";
|
|
4262
5093
|
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
5094
|
+
// ../common/src/entity-name-rules.ts
|
|
5095
|
+
var RESERVED_SQL_KEYWORDS_LOWER = new Set(["group", "order"]);
|
|
5096
|
+
var RESERVED_FIELD_NAMES_LOWER = new Set([
|
|
5097
|
+
"id",
|
|
5098
|
+
"createdby",
|
|
5099
|
+
"createtime",
|
|
5100
|
+
"updatedby",
|
|
5101
|
+
"updatetime",
|
|
5102
|
+
"recordowner",
|
|
5103
|
+
"version"
|
|
5104
|
+
]);
|
|
5105
|
+
var RESERVED_KEYWORDS_LOWER = new Set([
|
|
5106
|
+
"abstract",
|
|
5107
|
+
"as",
|
|
5108
|
+
"base",
|
|
5109
|
+
"bool",
|
|
5110
|
+
"break",
|
|
5111
|
+
"byte",
|
|
5112
|
+
"case",
|
|
5113
|
+
"catch",
|
|
5114
|
+
"char",
|
|
5115
|
+
"checked",
|
|
5116
|
+
"class",
|
|
5117
|
+
"const",
|
|
5118
|
+
"continue",
|
|
5119
|
+
"decimal",
|
|
5120
|
+
"default",
|
|
5121
|
+
"delegate",
|
|
5122
|
+
"do",
|
|
5123
|
+
"double",
|
|
5124
|
+
"else",
|
|
5125
|
+
"enum",
|
|
5126
|
+
"event",
|
|
5127
|
+
"explicit",
|
|
5128
|
+
"extern",
|
|
5129
|
+
"false",
|
|
5130
|
+
"finally",
|
|
5131
|
+
"fixed",
|
|
5132
|
+
"float",
|
|
5133
|
+
"for",
|
|
5134
|
+
"foreach",
|
|
5135
|
+
"goto",
|
|
5136
|
+
"if",
|
|
5137
|
+
"implicit",
|
|
5138
|
+
"in",
|
|
5139
|
+
"int",
|
|
5140
|
+
"interface",
|
|
5141
|
+
"internal",
|
|
5142
|
+
"is",
|
|
5143
|
+
"lock",
|
|
5144
|
+
"long",
|
|
5145
|
+
"namespace",
|
|
5146
|
+
"new",
|
|
5147
|
+
"null",
|
|
5148
|
+
"object",
|
|
5149
|
+
"operator",
|
|
5150
|
+
"out",
|
|
5151
|
+
"override",
|
|
5152
|
+
"params",
|
|
5153
|
+
"private",
|
|
5154
|
+
"protected",
|
|
5155
|
+
"public",
|
|
5156
|
+
"readonly",
|
|
5157
|
+
"ref",
|
|
5158
|
+
"return",
|
|
5159
|
+
"sbyte",
|
|
5160
|
+
"sealed",
|
|
5161
|
+
"short",
|
|
5162
|
+
"sizeof",
|
|
5163
|
+
"stackalloc",
|
|
5164
|
+
"static",
|
|
5165
|
+
"string",
|
|
5166
|
+
"struct",
|
|
5167
|
+
"switch",
|
|
5168
|
+
"this",
|
|
5169
|
+
"throw",
|
|
5170
|
+
"true",
|
|
5171
|
+
"try",
|
|
5172
|
+
"typeof",
|
|
5173
|
+
"uint",
|
|
5174
|
+
"ulong",
|
|
5175
|
+
"unchecked",
|
|
5176
|
+
"unsafe",
|
|
5177
|
+
"ushort",
|
|
5178
|
+
"using",
|
|
5179
|
+
"virtual",
|
|
5180
|
+
"void",
|
|
5181
|
+
"volatile",
|
|
5182
|
+
"while",
|
|
5183
|
+
"addhandler",
|
|
5184
|
+
"addressof",
|
|
5185
|
+
"alias",
|
|
5186
|
+
"and",
|
|
5187
|
+
"andalso",
|
|
5188
|
+
"boolean",
|
|
5189
|
+
"byref",
|
|
5190
|
+
"byval",
|
|
5191
|
+
"call",
|
|
5192
|
+
"cbool",
|
|
5193
|
+
"cbyte",
|
|
5194
|
+
"cchar",
|
|
5195
|
+
"cdate",
|
|
5196
|
+
"cdbl",
|
|
5197
|
+
"cdec",
|
|
5198
|
+
"cint",
|
|
5199
|
+
"clng",
|
|
5200
|
+
"cobj",
|
|
5201
|
+
"csbyte",
|
|
5202
|
+
"cshort",
|
|
5203
|
+
"csng",
|
|
5204
|
+
"cstr",
|
|
5205
|
+
"ctype",
|
|
5206
|
+
"cuint",
|
|
5207
|
+
"culng",
|
|
5208
|
+
"cushort",
|
|
5209
|
+
"date",
|
|
5210
|
+
"declare",
|
|
5211
|
+
"dim",
|
|
5212
|
+
"directcast",
|
|
5213
|
+
"each",
|
|
5214
|
+
"elseif",
|
|
5215
|
+
"end",
|
|
5216
|
+
"endif",
|
|
5217
|
+
"erase",
|
|
5218
|
+
"error",
|
|
5219
|
+
"exit",
|
|
5220
|
+
"friend",
|
|
5221
|
+
"function",
|
|
5222
|
+
"get",
|
|
5223
|
+
"gettype",
|
|
5224
|
+
"getxmlnamespace",
|
|
5225
|
+
"global",
|
|
5226
|
+
"gosub",
|
|
5227
|
+
"goto",
|
|
5228
|
+
"handles",
|
|
5229
|
+
"implements",
|
|
5230
|
+
"imports",
|
|
5231
|
+
"inherits",
|
|
5232
|
+
"integer",
|
|
5233
|
+
"isnot",
|
|
5234
|
+
"let",
|
|
5235
|
+
"lib",
|
|
5236
|
+
"like",
|
|
5237
|
+
"loop",
|
|
5238
|
+
"me",
|
|
5239
|
+
"mod",
|
|
5240
|
+
"module",
|
|
5241
|
+
"mustinherit",
|
|
5242
|
+
"mustoverride",
|
|
5243
|
+
"mybase",
|
|
5244
|
+
"myclass",
|
|
5245
|
+
"narrowing",
|
|
5246
|
+
"next",
|
|
5247
|
+
"not",
|
|
5248
|
+
"nothing",
|
|
5249
|
+
"notinheritable",
|
|
5250
|
+
"notoverridable",
|
|
5251
|
+
"of",
|
|
5252
|
+
"on",
|
|
5253
|
+
"option",
|
|
5254
|
+
"optional",
|
|
5255
|
+
"or",
|
|
5256
|
+
"orelse",
|
|
5257
|
+
"overloads",
|
|
5258
|
+
"overridable",
|
|
5259
|
+
"overrides",
|
|
5260
|
+
"paramarray",
|
|
5261
|
+
"partial",
|
|
5262
|
+
"property",
|
|
5263
|
+
"raiseevent",
|
|
5264
|
+
"redim",
|
|
5265
|
+
"rem",
|
|
5266
|
+
"removehandler",
|
|
5267
|
+
"resume",
|
|
5268
|
+
"select",
|
|
5269
|
+
"set",
|
|
5270
|
+
"shadows",
|
|
5271
|
+
"shared",
|
|
5272
|
+
"single",
|
|
5273
|
+
"step",
|
|
5274
|
+
"stop",
|
|
5275
|
+
"structure",
|
|
5276
|
+
"sub",
|
|
5277
|
+
"synclock",
|
|
5278
|
+
"then",
|
|
5279
|
+
"to",
|
|
5280
|
+
"trycast",
|
|
5281
|
+
"uinteger",
|
|
5282
|
+
"ushort",
|
|
5283
|
+
"variant",
|
|
5284
|
+
"wend",
|
|
5285
|
+
"when",
|
|
5286
|
+
"widening",
|
|
5287
|
+
"with",
|
|
5288
|
+
"withevents",
|
|
5289
|
+
"writeonly",
|
|
5290
|
+
"xor"
|
|
5291
|
+
]);
|
|
4263
5292
|
// ../common/src/host-global-options.ts
|
|
4264
5293
|
var HOST_GLOBAL_OPTIONS_WITH_VALUE = [
|
|
4265
5294
|
"--output",
|
|
@@ -4328,6 +5357,40 @@ var factorySlot = singleton("PackagerFactoryProvider");
|
|
|
4328
5357
|
// ../uipath-python-bridge/src/execute.ts
|
|
4329
5358
|
import { spawn } from "node:child_process";
|
|
4330
5359
|
|
|
5360
|
+
// ../auth/src/catch-error.ts
|
|
5361
|
+
function isPromiseLike2(value) {
|
|
5362
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
5363
|
+
}
|
|
5364
|
+
function catchError2(fnOrPromise) {
|
|
5365
|
+
if (isPromiseLike2(fnOrPromise)) {
|
|
5366
|
+
return settlePromiseLike2(fnOrPromise);
|
|
5367
|
+
}
|
|
5368
|
+
try {
|
|
5369
|
+
const result = fnOrPromise();
|
|
5370
|
+
if (isPromiseLike2(result)) {
|
|
5371
|
+
return settlePromiseLike2(result);
|
|
5372
|
+
}
|
|
5373
|
+
return [undefined, result];
|
|
5374
|
+
} catch (error) {
|
|
5375
|
+
return [
|
|
5376
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
5377
|
+
undefined
|
|
5378
|
+
];
|
|
5379
|
+
}
|
|
5380
|
+
}
|
|
5381
|
+
function settlePromiseLike2(thenable) {
|
|
5382
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
|
|
5383
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
5384
|
+
undefined
|
|
5385
|
+
]);
|
|
5386
|
+
}
|
|
5387
|
+
|
|
5388
|
+
// ../auth/src/constants.ts
|
|
5389
|
+
var UIPATH_HOME_DIR2 = ".uipath";
|
|
5390
|
+
var AUTH_FILENAME = ".auth";
|
|
5391
|
+
var DEFAULT_BASE_URL = "https://cloud.uipath.com";
|
|
5392
|
+
var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
|
|
5393
|
+
|
|
4331
5394
|
// ../auth/src/config.ts
|
|
4332
5395
|
var DEFAULT_CLIENT_ID = "36dea5b8-e8bb-423d-8e7b-c808df8f1c00";
|
|
4333
5396
|
var AUTH_FILE_CONFIG_KEY = Symbol.for("@uipath/auth/AuthFileConfig");
|
|
@@ -4341,7 +5404,7 @@ class InvalidBaseUrlError extends Error {
|
|
|
4341
5404
|
super(`Invalid base URL: "${url}"
|
|
4342
5405
|
` + `Reason: ${reason}
|
|
4343
5406
|
|
|
4344
|
-
` + `Expected format: an https:// URL, e.g. https://cloud.uipath.com (commercial), https://govcloud.uipath.us (Public Sector), or your Automation Suite host (https://<your-host>).
|
|
5407
|
+
` + `Expected format: an https:// URL (or bare host — https:// is assumed), e.g. https://cloud.uipath.com (commercial), https://govcloud.uipath.us (Public Sector), or your Automation Suite host (https://<your-host>).
|
|
4345
5408
|
` + `You can specify the URL via:
|
|
4346
5409
|
` + ` • --authority flag
|
|
4347
5410
|
` + ` • UIPATH_URL environment variable
|
|
@@ -4362,10 +5425,16 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
|
4362
5425
|
while (baseUrl.endsWith("/")) {
|
|
4363
5426
|
baseUrl = baseUrl.slice(0, -1);
|
|
4364
5427
|
}
|
|
5428
|
+
const hasScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(baseUrl);
|
|
5429
|
+
const [hostCandidate] = baseUrl.split(/[/?#]/, 1);
|
|
5430
|
+
if (!hasScheme && hostCandidate.includes(".")) {
|
|
5431
|
+
baseUrl = `https://${baseUrl}`;
|
|
5432
|
+
}
|
|
4365
5433
|
const resolvedBaseUrl = baseUrl;
|
|
4366
|
-
const [urlError, url] =
|
|
5434
|
+
const [urlError, url] = catchError2(() => new URL(resolvedBaseUrl));
|
|
4367
5435
|
if (urlError) {
|
|
4368
|
-
|
|
5436
|
+
const shapeHint = !hasScheme && !hostCandidate.includes(".") ? ` "${rawUrl.trim()}" is not a URL or a host name. Pass the full authority URL — https://<host>, or just <host> (https:// is assumed).` : ` ${urlError instanceof Error ? urlError.message : "Unknown error"}`;
|
|
5437
|
+
throw new InvalidBaseUrlError(baseUrl, `Malformed URL.${shapeHint}`);
|
|
4369
5438
|
}
|
|
4370
5439
|
if (url.protocol !== "https:") {
|
|
4371
5440
|
throw new InvalidBaseUrlError(baseUrl, `Authority must use https:// scheme, got ${url.protocol}//. OIDC token exchange requires TLS end-to-end.`);
|
|
@@ -4420,6 +5489,11 @@ var resolveConfigAsync = async ({
|
|
|
4420
5489
|
};
|
|
4421
5490
|
};
|
|
4422
5491
|
|
|
5492
|
+
// ../auth/src/utils/platform.ts
|
|
5493
|
+
function isBrowser() {
|
|
5494
|
+
return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis;
|
|
5495
|
+
}
|
|
5496
|
+
|
|
4423
5497
|
// ../auth/src/authProfile.ts
|
|
4424
5498
|
var DEFAULT_AUTH_PROFILE = "default";
|
|
4425
5499
|
var PROFILE_DIR = "profiles";
|
|
@@ -4431,7 +5505,7 @@ function isAuthProfileStorage(value) {
|
|
|
4431
5505
|
return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
|
|
4432
5506
|
}
|
|
4433
5507
|
function createProfileStorage() {
|
|
4434
|
-
const [error, mod] =
|
|
5508
|
+
const [error, mod] = catchError2(() => __require("node:async_hooks"));
|
|
4435
5509
|
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
4436
5510
|
return {
|
|
4437
5511
|
getStore: () => {
|
|
@@ -4447,9 +5521,9 @@ function getProfileStorage() {
|
|
|
4447
5521
|
if (isAuthProfileStorage(existing)) {
|
|
4448
5522
|
return existing;
|
|
4449
5523
|
}
|
|
4450
|
-
const
|
|
4451
|
-
globalSlot2[AUTH_PROFILE_STORAGE_KEY] =
|
|
4452
|
-
return
|
|
5524
|
+
const storage2 = createProfileStorage();
|
|
5525
|
+
globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage2;
|
|
5526
|
+
return storage2;
|
|
4453
5527
|
}
|
|
4454
5528
|
var profileStorage = getProfileStorage();
|
|
4455
5529
|
|
|
@@ -4480,8 +5554,8 @@ function resolveAuthProfileFilePath(profile) {
|
|
|
4480
5554
|
if (normalized === undefined) {
|
|
4481
5555
|
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
4482
5556
|
}
|
|
4483
|
-
const
|
|
4484
|
-
return
|
|
5557
|
+
const fs2 = getFileSystem();
|
|
5558
|
+
return fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR2, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
4485
5559
|
}
|
|
4486
5560
|
function getActiveAuthProfileFilePath() {
|
|
4487
5561
|
const profile = getActiveAuthProfile();
|
|
@@ -4562,7 +5636,7 @@ var getTokenExpiration = (accessToken) => {
|
|
|
4562
5636
|
// ../auth/src/sessionIdentity.ts
|
|
4563
5637
|
var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
|
|
4564
5638
|
var decodeClaims = (accessToken) => {
|
|
4565
|
-
const [error, claims] =
|
|
5639
|
+
const [error, claims] = catchError2(() => parseJWT(accessToken));
|
|
4566
5640
|
return error ? undefined : claims;
|
|
4567
5641
|
};
|
|
4568
5642
|
var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
|
|
@@ -4646,27 +5720,48 @@ var requireEnv = (name) => {
|
|
|
4646
5720
|
}
|
|
4647
5721
|
return value;
|
|
4648
5722
|
};
|
|
5723
|
+
var OPAQUE_TOKEN_BASE_URL_VAR = "UIPATH_URL";
|
|
5724
|
+
var resolveBaseUrl = (rawUrl, failureContext) => {
|
|
5725
|
+
const [baseUrlError, baseUrl] = catchError2(() => normalizeAndValidateBaseUrl(rawUrl));
|
|
5726
|
+
if (baseUrlError) {
|
|
5727
|
+
if (baseUrlError instanceof InvalidBaseUrlError) {
|
|
5728
|
+
throw baseUrlError;
|
|
5729
|
+
}
|
|
5730
|
+
throw new EnvAuthConfigError(`${failureContext}: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
|
|
5731
|
+
}
|
|
5732
|
+
return baseUrl;
|
|
5733
|
+
};
|
|
4649
5734
|
var readAuthFromEnv = () => {
|
|
4650
5735
|
const accessToken = requireEnv(ENV_AUTH_VARS.token);
|
|
4651
5736
|
const organizationName = requireEnv(ENV_AUTH_VARS.organizationName);
|
|
4652
5737
|
const organizationId = requireEnv(ENV_AUTH_VARS.organizationId);
|
|
4653
5738
|
const tenantName = requireEnv(ENV_AUTH_VARS.tenantName);
|
|
4654
5739
|
const tenantId = requireEnv(ENV_AUTH_VARS.tenantId);
|
|
4655
|
-
const [parseError, payload] =
|
|
5740
|
+
const [parseError, payload] = catchError2(() => parseJWT(accessToken));
|
|
4656
5741
|
if (parseError) {
|
|
4657
|
-
|
|
5742
|
+
const parseErrorMessage = parseError instanceof Error ? parseError.message : String(parseError);
|
|
5743
|
+
const rawUrl = process.env[OPAQUE_TOKEN_BASE_URL_VAR];
|
|
5744
|
+
if (!rawUrl) {
|
|
5745
|
+
throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} is not a JWT (treating it as an opaque token, ` + `e.g. a Personal Access Token). Set ${OPAQUE_TOKEN_BASE_URL_VAR} to the ` + `UiPath base URL if this is a PAT, or fix the token if it was meant to ` + `be a JWT (parse error: ${parseErrorMessage}).`);
|
|
5746
|
+
}
|
|
5747
|
+
const baseUrl2 = resolveBaseUrl(rawUrl, `Failed to validate ${OPAQUE_TOKEN_BASE_URL_VAR}`);
|
|
5748
|
+
return {
|
|
5749
|
+
loginStatus: "Logged in",
|
|
5750
|
+
accessToken,
|
|
5751
|
+
baseUrl: baseUrl2,
|
|
5752
|
+
organizationName,
|
|
5753
|
+
organizationId,
|
|
5754
|
+
tenantName,
|
|
5755
|
+
tenantId,
|
|
5756
|
+
source: "env-vars" /* EnvironmentVariables */,
|
|
5757
|
+
hint: "Token is opaque (not a JWT) - expiration and identity cannot be " + "determined locally. Commands will fail with 401 once it is revoked or " + `expired. If this was meant to be a JWT instead of a PAT, note: ${parseErrorMessage}`
|
|
5758
|
+
};
|
|
4658
5759
|
}
|
|
4659
5760
|
const iss = payload.iss;
|
|
4660
5761
|
if (typeof iss !== "string" || iss.length === 0) {
|
|
4661
5762
|
throw new EnvAuthConfigError(`${ENV_AUTH_VARS.token} has no 'iss' claim; cannot determine ` + `the UiPath server. Ensure the token was issued by a UiPath identity server.`);
|
|
4662
5763
|
}
|
|
4663
|
-
const
|
|
4664
|
-
if (baseUrlError) {
|
|
4665
|
-
if (baseUrlError instanceof InvalidBaseUrlError) {
|
|
4666
|
-
throw baseUrlError;
|
|
4667
|
-
}
|
|
4668
|
-
throw new EnvAuthConfigError(`Failed to derive server URL from token 'iss' claim: ` + `${baseUrlError instanceof Error ? baseUrlError.message : String(baseUrlError)}`);
|
|
4669
|
-
}
|
|
5764
|
+
const baseUrl = resolveBaseUrl(iss, "Failed to derive server URL from token 'iss' claim");
|
|
4670
5765
|
const expiration = getTokenExpiration(accessToken);
|
|
4671
5766
|
const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
|
|
4672
5767
|
const identity = resolveSessionIdentity(accessToken);
|
|
@@ -4692,8 +5787,8 @@ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
|
4692
5787
|
async function refreshTokenFingerprint(refreshToken) {
|
|
4693
5788
|
const bytes = new TextEncoder().encode(refreshToken);
|
|
4694
5789
|
if (globalThis.crypto?.subtle) {
|
|
4695
|
-
const
|
|
4696
|
-
return Array.from(new Uint8Array(
|
|
5790
|
+
const digest2 = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
5791
|
+
return Array.from(new Uint8Array(digest2), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
4697
5792
|
}
|
|
4698
5793
|
const { createHash } = await import("node:crypto");
|
|
4699
5794
|
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
@@ -4702,9 +5797,9 @@ function breakerPathFor(authPath) {
|
|
|
4702
5797
|
return `${authPath}${BREAKER_SUFFIX}`;
|
|
4703
5798
|
}
|
|
4704
5799
|
async function loadRefreshBreaker(authPath) {
|
|
4705
|
-
const
|
|
5800
|
+
const fs2 = getFileSystem();
|
|
4706
5801
|
try {
|
|
4707
|
-
const content = await
|
|
5802
|
+
const content = await fs2.readFile(breakerPathFor(authPath), "utf-8");
|
|
4708
5803
|
if (!content)
|
|
4709
5804
|
return {};
|
|
4710
5805
|
const parsed = JSON.parse(content);
|
|
@@ -4715,20 +5810,20 @@ async function loadRefreshBreaker(authPath) {
|
|
|
4715
5810
|
}
|
|
4716
5811
|
async function saveRefreshBreaker(authPath, state) {
|
|
4717
5812
|
try {
|
|
4718
|
-
const
|
|
4719
|
-
const
|
|
4720
|
-
await
|
|
4721
|
-
const tempPath = `${
|
|
4722
|
-
await
|
|
4723
|
-
await
|
|
5813
|
+
const fs2 = getFileSystem();
|
|
5814
|
+
const path2 = breakerPathFor(authPath);
|
|
5815
|
+
await fs2.mkdir(fs2.path.dirname(path2));
|
|
5816
|
+
const tempPath = `${path2}.tmp`;
|
|
5817
|
+
await fs2.writeFile(tempPath, JSON.stringify(state));
|
|
5818
|
+
await fs2.rename(tempPath, path2);
|
|
4724
5819
|
} catch {}
|
|
4725
5820
|
}
|
|
4726
5821
|
async function clearRefreshBreaker(authPath) {
|
|
4727
|
-
const
|
|
4728
|
-
const
|
|
5822
|
+
const fs2 = getFileSystem();
|
|
5823
|
+
const path2 = breakerPathFor(authPath);
|
|
4729
5824
|
try {
|
|
4730
|
-
if (await
|
|
4731
|
-
await
|
|
5825
|
+
if (await fs2.exists(path2)) {
|
|
5826
|
+
await fs2.rm(path2);
|
|
4732
5827
|
}
|
|
4733
5828
|
} catch {}
|
|
4734
5829
|
}
|
|
@@ -4749,43 +5844,43 @@ var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
|
4749
5844
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
4750
5845
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
4751
5846
|
var getRobotIpcPipeNames = async () => {
|
|
4752
|
-
const
|
|
4753
|
-
const username =
|
|
5847
|
+
const fs2 = getFileSystem();
|
|
5848
|
+
const username = fs2.env.getenv("USER") ?? fs2.env.getenv("USERNAME");
|
|
4754
5849
|
if (!username) {
|
|
4755
5850
|
throw new Error("Unable to determine current username");
|
|
4756
5851
|
}
|
|
4757
|
-
const tempPath =
|
|
4758
|
-
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) =>
|
|
5852
|
+
const tempPath = fs2.env.getenv("TMPDIR") ?? "/tmp/";
|
|
5853
|
+
return [ROBOT_USER_SERVICES_PIPE, ROBOT_USER_SERVICES_ALTERNATE_PIPE].map((baseName) => fs2.path.join(tempPath, `${baseName}_${username}`).substring(0, PIPE_NAME_MAX_LENGTH));
|
|
4759
5854
|
};
|
|
4760
5855
|
var defaultIsRobotIpcAvailable = async () => {
|
|
4761
5856
|
if (process.platform === "win32") {
|
|
4762
5857
|
return true;
|
|
4763
5858
|
}
|
|
4764
|
-
const [pipeNamesError, pipeNames] = await
|
|
5859
|
+
const [pipeNamesError, pipeNames] = await catchError2(getRobotIpcPipeNames());
|
|
4765
5860
|
if (pipeNamesError || !pipeNames) {
|
|
4766
5861
|
return false;
|
|
4767
5862
|
}
|
|
4768
|
-
const
|
|
5863
|
+
const fs2 = getFileSystem();
|
|
4769
5864
|
for (const pipeName of pipeNames) {
|
|
4770
|
-
const [existsError, exists] = await
|
|
5865
|
+
const [existsError, exists] = await catchError2(fs2.exists(pipeName));
|
|
4771
5866
|
if (!existsError && exists === true) {
|
|
4772
5867
|
return true;
|
|
4773
5868
|
}
|
|
4774
5869
|
}
|
|
4775
5870
|
return false;
|
|
4776
5871
|
};
|
|
4777
|
-
var withTimeout = (promise, timeoutMs) => new Promise((
|
|
5872
|
+
var withTimeout = (promise, timeoutMs) => new Promise((resolve2, reject) => {
|
|
4778
5873
|
const timer = setTimeout(() => reject(new Error(`Robot IPC call timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
4779
5874
|
promise.then((value) => {
|
|
4780
5875
|
clearTimeout(timer);
|
|
4781
|
-
|
|
5876
|
+
resolve2(value);
|
|
4782
5877
|
}, (error) => {
|
|
4783
5878
|
clearTimeout(timer);
|
|
4784
5879
|
reject(error);
|
|
4785
5880
|
});
|
|
4786
5881
|
});
|
|
4787
5882
|
var parseResourceUrl = (url) => {
|
|
4788
|
-
const [error, parsed] =
|
|
5883
|
+
const [error, parsed] = catchError2(() => new URL(url));
|
|
4789
5884
|
if (error || !parsed)
|
|
4790
5885
|
return;
|
|
4791
5886
|
const segments = parsed.pathname.split("/").filter(Boolean);
|
|
@@ -4805,7 +5900,7 @@ var defaultLoadModule = async () => {
|
|
|
4805
5900
|
if (!hostLoader) {
|
|
4806
5901
|
return;
|
|
4807
5902
|
}
|
|
4808
|
-
const [error, mod] = await
|
|
5903
|
+
const [error, mod] = await catchError2(() => hostLoader());
|
|
4809
5904
|
if (error || !mod) {
|
|
4810
5905
|
return;
|
|
4811
5906
|
}
|
|
@@ -4831,7 +5926,7 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
4831
5926
|
const mod = await loadModule();
|
|
4832
5927
|
if (!mod)
|
|
4833
5928
|
return;
|
|
4834
|
-
const [ctorError, proxy] =
|
|
5929
|
+
const [ctorError, proxy] = catchError2(() => new mod.RobotProxyConstructor);
|
|
4835
5930
|
if (ctorError || !proxy) {
|
|
4836
5931
|
return;
|
|
4837
5932
|
}
|
|
@@ -4854,7 +5949,7 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
4854
5949
|
let organizationIdFromToken;
|
|
4855
5950
|
let tenantIdFromToken;
|
|
4856
5951
|
let issuerFromToken;
|
|
4857
|
-
const [jwtError, claims] =
|
|
5952
|
+
const [jwtError, claims] = catchError2(() => parseJWT(accessToken));
|
|
4858
5953
|
if (!jwtError && claims) {
|
|
4859
5954
|
const rawOrgId = claims.prtId ?? claims.organizationId ?? claims.prt_id;
|
|
4860
5955
|
if (typeof rawOrgId === "string" && rawOrgId.length > 0) {
|
|
@@ -4881,7 +5976,7 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
4881
5976
|
} catch {
|
|
4882
5977
|
return;
|
|
4883
5978
|
} finally {
|
|
4884
|
-
await
|
|
5979
|
+
await catchError2(() => withTimeout(proxy.CloseAsync(), CLOSE_TIMEOUT_MS));
|
|
4885
5980
|
}
|
|
4886
5981
|
};
|
|
4887
5982
|
|
|
@@ -4935,7 +6030,7 @@ var refreshAccessToken = async ({
|
|
|
4935
6030
|
var AUTH_FLOW_ENV_VAR = "UIPATH_AUTH_FLOW";
|
|
4936
6031
|
|
|
4937
6032
|
// ../auth/src/utils/envFile.ts
|
|
4938
|
-
var DEFAULT_ENV_FILENAME = `${
|
|
6033
|
+
var DEFAULT_ENV_FILENAME = `${UIPATH_HOME_DIR2}/${AUTH_FILENAME}`;
|
|
4939
6034
|
var KNOWN_ERROR_CODES = new Set([
|
|
4940
6035
|
"EISDIR",
|
|
4941
6036
|
"EACCES",
|
|
@@ -4951,9 +6046,9 @@ var errorCode = (err) => {
|
|
|
4951
6046
|
}
|
|
4952
6047
|
return "EUNKNOWN";
|
|
4953
6048
|
};
|
|
4954
|
-
var probeAsync = async (
|
|
6049
|
+
var probeAsync = async (fs2, candidate) => {
|
|
4955
6050
|
try {
|
|
4956
|
-
const stats = await
|
|
6051
|
+
const stats = await fs2.stat(candidate);
|
|
4957
6052
|
if (stats === null) {
|
|
4958
6053
|
return { exists: false };
|
|
4959
6054
|
}
|
|
@@ -4980,9 +6075,9 @@ var probeAsync = async (fs, candidate) => {
|
|
|
4980
6075
|
}
|
|
4981
6076
|
};
|
|
4982
6077
|
var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
|
|
4983
|
-
const
|
|
4984
|
-
if (
|
|
4985
|
-
const probe2 = await probeAsync(
|
|
6078
|
+
const fs2 = getFileSystem();
|
|
6079
|
+
if (fs2.path.isAbsolute(envFilePath)) {
|
|
6080
|
+
const probe2 = await probeAsync(fs2, envFilePath);
|
|
4986
6081
|
return probe2.exists ? { exists: true, absolutePath: envFilePath, source: "absolute" } : {
|
|
4987
6082
|
exists: false,
|
|
4988
6083
|
absolutePath: envFilePath,
|
|
@@ -4990,11 +6085,11 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
|
|
|
4990
6085
|
...probe2.unusable ? { unusable: probe2.unusable } : {}
|
|
4991
6086
|
};
|
|
4992
6087
|
}
|
|
4993
|
-
const cwd = opts?.cwd ??
|
|
6088
|
+
const cwd = opts?.cwd ?? fs2.env.cwd();
|
|
4994
6089
|
let searchDir = cwd;
|
|
4995
6090
|
while (true) {
|
|
4996
|
-
const candidate =
|
|
4997
|
-
const probe2 = await probeAsync(
|
|
6091
|
+
const candidate = fs2.path.join(searchDir, envFilePath);
|
|
6092
|
+
const probe2 = await probeAsync(fs2, candidate);
|
|
4998
6093
|
if (probe2.exists) {
|
|
4999
6094
|
return {
|
|
5000
6095
|
exists: true,
|
|
@@ -5002,14 +6097,14 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opt
|
|
|
5002
6097
|
source: searchDir === cwd ? "cwd" : "ancestor"
|
|
5003
6098
|
};
|
|
5004
6099
|
}
|
|
5005
|
-
const parentDir =
|
|
6100
|
+
const parentDir = fs2.path.dirname(searchDir);
|
|
5006
6101
|
if (parentDir === searchDir) {
|
|
5007
6102
|
break;
|
|
5008
6103
|
}
|
|
5009
6104
|
searchDir = parentDir;
|
|
5010
6105
|
}
|
|
5011
|
-
const homePath =
|
|
5012
|
-
const probe = await probeAsync(
|
|
6106
|
+
const homePath = fs2.path.join(fs2.env.homedir(), envFilePath);
|
|
6107
|
+
const probe = await probeAsync(fs2, homePath);
|
|
5013
6108
|
if (probe.exists) {
|
|
5014
6109
|
return { exists: true, absolutePath: homePath, source: "home" };
|
|
5015
6110
|
}
|
|
@@ -5031,12 +6126,12 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
|
|
|
5031
6126
|
};
|
|
5032
6127
|
};
|
|
5033
6128
|
var loadEnvFileAsync = async ({ envPath }) => {
|
|
5034
|
-
const
|
|
5035
|
-
const absolutePath =
|
|
5036
|
-
if (!await
|
|
6129
|
+
const fs2 = getFileSystem();
|
|
6130
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
|
|
6131
|
+
if (!await fs2.exists(absolutePath)) {
|
|
5037
6132
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
5038
6133
|
}
|
|
5039
|
-
const content = await
|
|
6134
|
+
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
5040
6135
|
if (content === null) {
|
|
5041
6136
|
throw new Error(`Environment file not found: ${envPath}`);
|
|
5042
6137
|
}
|
|
@@ -5065,10 +6160,10 @@ var saveEnvFileAsync = async ({
|
|
|
5065
6160
|
data,
|
|
5066
6161
|
merge = true
|
|
5067
6162
|
}) => {
|
|
5068
|
-
const
|
|
5069
|
-
const absolutePath =
|
|
6163
|
+
const fs2 = getFileSystem();
|
|
6164
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.homedir(), envPath);
|
|
5070
6165
|
let existingData = {};
|
|
5071
|
-
if (merge && await
|
|
6166
|
+
if (merge && await fs2.exists(absolutePath)) {
|
|
5072
6167
|
try {
|
|
5073
6168
|
existingData = await loadEnvFileAsync({ envPath: absolutePath });
|
|
5074
6169
|
} catch {}
|
|
@@ -5086,11 +6181,11 @@ var saveEnvFileAsync = async ({
|
|
|
5086
6181
|
const content = `${lines.join(`
|
|
5087
6182
|
`)}
|
|
5088
6183
|
`;
|
|
5089
|
-
const dir =
|
|
5090
|
-
await
|
|
6184
|
+
const dir = fs2.path.dirname(absolutePath);
|
|
6185
|
+
await fs2.mkdir(dir);
|
|
5091
6186
|
const tempPath = `${absolutePath}.tmp`;
|
|
5092
|
-
await
|
|
5093
|
-
await
|
|
6187
|
+
await fs2.writeFile(tempPath, content);
|
|
6188
|
+
await fs2.rename(tempPath, absolutePath);
|
|
5094
6189
|
};
|
|
5095
6190
|
|
|
5096
6191
|
// ../auth/src/loginStatus.ts
|
|
@@ -5204,11 +6299,11 @@ async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
|
5204
6299
|
return { credentials };
|
|
5205
6300
|
}
|
|
5206
6301
|
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
5207
|
-
const
|
|
5208
|
-
const globalPath =
|
|
6302
|
+
const fs2 = getFs();
|
|
6303
|
+
const globalPath = fs2.path.join(fs2.env.homedir(), envFilePath);
|
|
5209
6304
|
if (absolutePath === globalPath)
|
|
5210
6305
|
return;
|
|
5211
|
-
if (!await
|
|
6306
|
+
if (!await fs2.exists(globalPath))
|
|
5212
6307
|
return;
|
|
5213
6308
|
try {
|
|
5214
6309
|
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
@@ -5610,16 +6705,16 @@ var TENANT_SELECTION_CODES = new Set([
|
|
|
5610
6705
|
]);
|
|
5611
6706
|
// ../uipath-python-bridge/src/cache.ts
|
|
5612
6707
|
async function readCache(cacheFile) {
|
|
5613
|
-
const
|
|
5614
|
-
const [existsError, exists] = await
|
|
6708
|
+
const fs2 = getFileSystem();
|
|
6709
|
+
const [existsError, exists] = await catchError(fs2.exists(cacheFile));
|
|
5615
6710
|
if (existsError || !exists)
|
|
5616
6711
|
return null;
|
|
5617
|
-
const [readError, content] = await
|
|
6712
|
+
const [readError, content] = await catchError(fs2.readFile(cacheFile, "utf-8"));
|
|
5618
6713
|
if (readError) {
|
|
5619
6714
|
logger.warn(`Failed to load cache: ${readError}`);
|
|
5620
6715
|
return null;
|
|
5621
6716
|
}
|
|
5622
|
-
const [parseError, cache] =
|
|
6717
|
+
const [parseError, cache] = catchError(() => JSON.parse(content));
|
|
5623
6718
|
if (parseError) {
|
|
5624
6719
|
logger.warn(`Failed to parse cache: ${parseError}`);
|
|
5625
6720
|
return null;
|
|
@@ -5736,16 +6831,16 @@ function envValueFromFile(content, name) {
|
|
|
5736
6831
|
const [, ...valueParts] = envLine.split("=");
|
|
5737
6832
|
return valueParts.join("=").trim().replace(/^["']|["']$/g, "") || null;
|
|
5738
6833
|
}
|
|
5739
|
-
async function getConfiguredEnvValue(
|
|
6834
|
+
async function getConfiguredEnvValue(fs2, name) {
|
|
5740
6835
|
const processValue = process.env[name]?.trim();
|
|
5741
6836
|
if (processValue) {
|
|
5742
6837
|
return processValue;
|
|
5743
6838
|
}
|
|
5744
|
-
const envPath =
|
|
5745
|
-
if (!await
|
|
6839
|
+
const envPath = fs2.path.join(fs2.env.cwd(), ENV_FILE_NAME);
|
|
6840
|
+
if (!await fs2.exists(envPath)) {
|
|
5746
6841
|
return null;
|
|
5747
6842
|
}
|
|
5748
|
-
const [readError, content] = await
|
|
6843
|
+
const [readError, content] = await catchError(fs2.readFile(envPath, "utf-8"));
|
|
5749
6844
|
return !readError && typeof content === "string" ? envValueFromFile(content, name) : null;
|
|
5750
6845
|
}
|
|
5751
6846
|
var fail = (reason, message, instructions, extras = {}) => ({
|
|
@@ -5757,14 +6852,14 @@ var fail = (reason, message, instructions, extras = {}) => ({
|
|
|
5757
6852
|
stderr: extras.stderr
|
|
5758
6853
|
});
|
|
5759
6854
|
async function runUipathPythonCommand(args, options = {}) {
|
|
5760
|
-
const
|
|
5761
|
-
const cacheFile =
|
|
6855
|
+
const fs2 = getFileSystem();
|
|
6856
|
+
const cacheFile = fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
|
|
5762
6857
|
const setupHint = `Run 'uip ${options.commandPrefix ?? "codedagent"} setup' first to configure the environment. ` + "If you are using a virtual environment, activate it first.";
|
|
5763
6858
|
const cache = await readCache(cacheFile);
|
|
5764
6859
|
if (!cache?.uipathExePath) {
|
|
5765
6860
|
return fail("python_not_configured", "Python not configured.", setupHint);
|
|
5766
6861
|
}
|
|
5767
|
-
if (!await
|
|
6862
|
+
if (!await fs2.exists(cache.uipathExePath)) {
|
|
5768
6863
|
return fail("uipath_exe_missing", "uipath executable not found. Please install it using 'pip install uipath' or 'uv add uipath'.", setupHint);
|
|
5769
6864
|
}
|
|
5770
6865
|
const processed = processCommandArgs(args, options.commandRules ?? []);
|
|
@@ -5779,7 +6874,7 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
5779
6874
|
if (!applies) {
|
|
5780
6875
|
continue;
|
|
5781
6876
|
}
|
|
5782
|
-
const value = await getConfiguredEnvValue(
|
|
6877
|
+
const value = await getConfiguredEnvValue(fs2, requirement.name);
|
|
5783
6878
|
if (!value) {
|
|
5784
6879
|
return fail("required_env_missing", `${requirement.name} environment variable not found.`, requirement.instructions);
|
|
5785
6880
|
}
|
|
@@ -5791,7 +6886,7 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
5791
6886
|
}
|
|
5792
6887
|
if (options.commandPreflight) {
|
|
5793
6888
|
const preflight = options.commandPreflight;
|
|
5794
|
-
const [preflightError, preflightResult] = await
|
|
6889
|
+
const [preflightError, preflightResult] = await catchError(Promise.resolve().then(() => preflight({
|
|
5795
6890
|
args: commandArgs,
|
|
5796
6891
|
loginStatus: loginStatus2,
|
|
5797
6892
|
authEnv
|
|
@@ -5804,7 +6899,7 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
5804
6899
|
}
|
|
5805
6900
|
}
|
|
5806
6901
|
const stdio = options.stdio ?? "inherit";
|
|
5807
|
-
const cwd = options.cwd ??
|
|
6902
|
+
const cwd = options.cwd ?? fs2.env.cwd();
|
|
5808
6903
|
const proc = spawn(cache.uipathExePath, commandArgs, {
|
|
5809
6904
|
cwd,
|
|
5810
6905
|
env: {
|
|
@@ -5825,8 +6920,8 @@ async function runUipathPythonCommand(args, options = {}) {
|
|
|
5825
6920
|
stderr += chunk.toString("utf8");
|
|
5826
6921
|
});
|
|
5827
6922
|
}
|
|
5828
|
-
const [spawnError, exitCode] = await
|
|
5829
|
-
proc.on("close", (code) =>
|
|
6923
|
+
const [spawnError, exitCode] = await catchError(new Promise((resolve2, reject) => {
|
|
6924
|
+
proc.on("close", (code) => resolve2(code ?? 1));
|
|
5830
6925
|
proc.on("error", reject);
|
|
5831
6926
|
}));
|
|
5832
6927
|
if (spawnError) {
|
|
@@ -5897,25 +6992,25 @@ class PythonService {
|
|
|
5897
6992
|
uipathExePath;
|
|
5898
6993
|
packageVersion;
|
|
5899
6994
|
constructor(config) {
|
|
5900
|
-
const
|
|
6995
|
+
const fs2 = getFileSystem();
|
|
5901
6996
|
this.config = config;
|
|
5902
|
-
this.cacheFile = config.cacheFile ||
|
|
6997
|
+
this.cacheFile = config.cacheFile || fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
|
|
5903
6998
|
}
|
|
5904
6999
|
async setup(packageName, force = false) {
|
|
5905
|
-
const [error, result] = await
|
|
7000
|
+
const [error, result] = await catchError(this._setupInternal(packageName, force));
|
|
5906
7001
|
if (error) {
|
|
5907
7002
|
return { success: false, error: error.message };
|
|
5908
7003
|
}
|
|
5909
7004
|
return result;
|
|
5910
7005
|
}
|
|
5911
7006
|
async _setupInternal(packageName, force) {
|
|
5912
|
-
const
|
|
7007
|
+
const fs2 = getFileSystem();
|
|
5913
7008
|
let pythonPath;
|
|
5914
7009
|
let version;
|
|
5915
7010
|
if (!force) {
|
|
5916
7011
|
logger.debug("Checking cache...");
|
|
5917
7012
|
const cached = await this.loadCache();
|
|
5918
|
-
if (cached?.uipathExePath && await
|
|
7013
|
+
if (cached?.uipathExePath && await fs2.exists(cached.uipathExePath)) {
|
|
5919
7014
|
pythonPath = cached.pythonPath;
|
|
5920
7015
|
version = cached.version;
|
|
5921
7016
|
this.uipathExePath = cached.uipathExePath;
|
|
@@ -6018,7 +7113,7 @@ To install the package, run:
|
|
|
6018
7113
|
};
|
|
6019
7114
|
}
|
|
6020
7115
|
async checkPythonCommand(command, args, checkedVersions, searchedCommands) {
|
|
6021
|
-
const
|
|
7116
|
+
const fs2 = getFileSystem();
|
|
6022
7117
|
const commandStr = args.length > 0 ? `${command} ${args.join(" ")}` : command;
|
|
6023
7118
|
searchedCommands.push(commandStr);
|
|
6024
7119
|
logger.debug(`Checking Python command: ${commandStr}`);
|
|
@@ -6030,8 +7125,8 @@ To install the package, run:
|
|
|
6030
7125
|
const stderrChunks = [];
|
|
6031
7126
|
versionProc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
6032
7127
|
versionProc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
|
|
6033
|
-
const [versionError, exitCode] = await
|
|
6034
|
-
versionProc.on("exit", (code) =>
|
|
7128
|
+
const [versionError, exitCode] = await catchError(new Promise((resolve2, reject) => {
|
|
7129
|
+
versionProc.on("exit", (code) => resolve2(code ?? 1));
|
|
6035
7130
|
versionProc.on("error", (error) => reject(error));
|
|
6036
7131
|
}));
|
|
6037
7132
|
if (versionError) {
|
|
@@ -6056,7 +7151,7 @@ To install the package, run:
|
|
|
6056
7151
|
return null;
|
|
6057
7152
|
}
|
|
6058
7153
|
logger.info(`Found valid Python: ${commandStr} - ${version}`);
|
|
6059
|
-
const uipathExePath = await this.findUipathExe(
|
|
7154
|
+
const uipathExePath = await this.findUipathExe(fs2, command, args);
|
|
6060
7155
|
return {
|
|
6061
7156
|
success: true,
|
|
6062
7157
|
pythonPath: commandStr,
|
|
@@ -6064,31 +7159,31 @@ To install the package, run:
|
|
|
6064
7159
|
uipathExePath
|
|
6065
7160
|
};
|
|
6066
7161
|
}
|
|
6067
|
-
async findUipathExe(
|
|
6068
|
-
const metadataPath = await this.findUipathExeFromMetadata(
|
|
7162
|
+
async findUipathExe(fs2, command, args) {
|
|
7163
|
+
const metadataPath = await this.findUipathExeFromMetadata(fs2, command, args);
|
|
6069
7164
|
if (metadataPath)
|
|
6070
7165
|
return metadataPath;
|
|
6071
7166
|
const isWindows = platform() === "win32";
|
|
6072
7167
|
const candidatePaths = [];
|
|
6073
7168
|
const virtualEnv = process.env.VIRTUAL_ENV;
|
|
6074
7169
|
if (virtualEnv) {
|
|
6075
|
-
candidatePaths.push(isWindows ?
|
|
7170
|
+
candidatePaths.push(isWindows ? fs2.path.join(virtualEnv, "Scripts", "uipath.exe") : fs2.path.join(virtualEnv, "bin", "uipath"));
|
|
6076
7171
|
}
|
|
6077
7172
|
const prefix = await this.getPythonPrefix(command, args);
|
|
6078
7173
|
if (prefix) {
|
|
6079
|
-
candidatePaths.push(isWindows ?
|
|
7174
|
+
candidatePaths.push(isWindows ? fs2.path.join(prefix, "Scripts", "uipath.exe") : fs2.path.join(prefix, "bin", "uipath"));
|
|
6080
7175
|
}
|
|
6081
7176
|
for (const candidate of candidatePaths) {
|
|
6082
7177
|
logger.debug(`Checking for uipath executable at: ${candidate}`);
|
|
6083
|
-
if (await
|
|
7178
|
+
if (await fs2.exists(candidate)) {
|
|
6084
7179
|
logger.info(`Found uipath executable at: ${candidate}`);
|
|
6085
7180
|
return candidate;
|
|
6086
7181
|
}
|
|
6087
7182
|
}
|
|
6088
|
-
const pathCandidates = this.getPathUipathCandidates(
|
|
7183
|
+
const pathCandidates = this.getPathUipathCandidates(fs2, isWindows);
|
|
6089
7184
|
for (const candidate of pathCandidates) {
|
|
6090
7185
|
logger.debug(`Checking for uipath executable on PATH at: ${candidate}`);
|
|
6091
|
-
if (await
|
|
7186
|
+
if (await fs2.exists(candidate)) {
|
|
6092
7187
|
logger.info(`Found uipath executable at: ${candidate}`);
|
|
6093
7188
|
return candidate;
|
|
6094
7189
|
}
|
|
@@ -6097,7 +7192,7 @@ To install the package, run:
|
|
|
6097
7192
|
logger.error(`uipath executable not found. Checked: ${checkedCandidates.join(", ")}`);
|
|
6098
7193
|
return;
|
|
6099
7194
|
}
|
|
6100
|
-
async findUipathExeFromMetadata(
|
|
7195
|
+
async findUipathExeFromMetadata(fs2, command, args) {
|
|
6101
7196
|
const script = `
|
|
6102
7197
|
from importlib.metadata import distribution, PackageNotFoundError
|
|
6103
7198
|
import sys
|
|
@@ -6118,8 +7213,8 @@ sys.exit(3)
|
|
|
6118
7213
|
const stderrChunks = [];
|
|
6119
7214
|
proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
6120
7215
|
proc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
|
|
6121
|
-
const [error, exitCode] = await
|
|
6122
|
-
proc.on("exit", (code) =>
|
|
7216
|
+
const [error, exitCode] = await catchError(new Promise((resolve2, reject) => {
|
|
7217
|
+
proc.on("exit", (code) => resolve2(code ?? 1));
|
|
6123
7218
|
proc.on("error", (err) => reject(err));
|
|
6124
7219
|
}));
|
|
6125
7220
|
if (error) {
|
|
@@ -6136,7 +7231,7 @@ sys.exit(3)
|
|
|
6136
7231
|
logger.debug("uipath executable metadata lookup returned empty path");
|
|
6137
7232
|
return;
|
|
6138
7233
|
}
|
|
6139
|
-
if (!await
|
|
7234
|
+
if (!await fs2.exists(resolved)) {
|
|
6140
7235
|
logger.debug(`uipath executable path from metadata does not exist: ${resolved}`);
|
|
6141
7236
|
return;
|
|
6142
7237
|
}
|
|
@@ -6149,8 +7244,8 @@ sys.exit(3)
|
|
|
6149
7244
|
});
|
|
6150
7245
|
const stdoutChunks = [];
|
|
6151
7246
|
proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
6152
|
-
const [error, exitCode] = await
|
|
6153
|
-
proc.on("exit", (code) =>
|
|
7247
|
+
const [error, exitCode] = await catchError(new Promise((resolve2, reject) => {
|
|
7248
|
+
proc.on("exit", (code) => resolve2(code ?? 1));
|
|
6154
7249
|
proc.on("error", (err) => reject(err));
|
|
6155
7250
|
}));
|
|
6156
7251
|
if (error) {
|
|
@@ -6170,8 +7265,8 @@ sys.exit(3)
|
|
|
6170
7265
|
const stderrChunks = [];
|
|
6171
7266
|
proc.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
6172
7267
|
proc.stderr.on("data", (chunk) => stderrChunks.push(chunk));
|
|
6173
|
-
const [spawnError, exitCode] = await
|
|
6174
|
-
proc.on("exit", (code) =>
|
|
7268
|
+
const [spawnError, exitCode] = await catchError(new Promise((resolve2, reject) => {
|
|
7269
|
+
proc.on("exit", (code) => resolve2(code ?? 1));
|
|
6175
7270
|
proc.on("error", (err) => reject(err));
|
|
6176
7271
|
}));
|
|
6177
7272
|
if (spawnError) {
|
|
@@ -6194,14 +7289,14 @@ sys.exit(3)
|
|
|
6194
7289
|
}
|
|
6195
7290
|
return { version: match[1] };
|
|
6196
7291
|
}
|
|
6197
|
-
getPathUipathCandidates(
|
|
7292
|
+
getPathUipathCandidates(fs2, isWindows) {
|
|
6198
7293
|
const pathValue = process.env.PATH || (isWindows ? process.env.Path : undefined);
|
|
6199
7294
|
if (!pathValue)
|
|
6200
7295
|
return [];
|
|
6201
7296
|
const delimiter = isWindows ? ";" : ":";
|
|
6202
7297
|
const pathEntries = pathValue.split(delimiter).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => entry.length > 0);
|
|
6203
7298
|
const executableNames = isWindows ? this.getWindowsExecutableNames() : ["uipath"];
|
|
6204
|
-
return pathEntries.flatMap((entry) => executableNames.map((name) =>
|
|
7299
|
+
return pathEntries.flatMap((entry) => executableNames.map((name) => fs2.path.join(entry, name)));
|
|
6205
7300
|
}
|
|
6206
7301
|
getWindowsExecutableNames() {
|
|
6207
7302
|
const pathExt = process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD";
|
|
@@ -6277,14 +7372,14 @@ Please install one of the required Python versions:
|
|
|
6277
7372
|
return readCache(this.cacheFile);
|
|
6278
7373
|
}
|
|
6279
7374
|
async saveCache(cache) {
|
|
6280
|
-
const
|
|
6281
|
-
const dir =
|
|
6282
|
-
const [mkdirError] = await
|
|
7375
|
+
const fs2 = getFileSystem();
|
|
7376
|
+
const dir = fs2.path.dirname(this.cacheFile);
|
|
7377
|
+
const [mkdirError] = await catchError(fs2.mkdir(dir));
|
|
6283
7378
|
if (mkdirError) {
|
|
6284
7379
|
logger.warn(`Failed to create cache directory: ${mkdirError}`);
|
|
6285
7380
|
return;
|
|
6286
7381
|
}
|
|
6287
|
-
const [writeError] = await
|
|
7382
|
+
const [writeError] = await catchError(fs2.writeFile(this.cacheFile, JSON.stringify(cache, null, 2)));
|
|
6288
7383
|
if (writeError) {
|
|
6289
7384
|
logger.warn(`Failed to save cache: ${writeError}`);
|
|
6290
7385
|
return;
|
|
@@ -6308,9 +7403,9 @@ function createSetupCommand(config) {
|
|
|
6308
7403
|
processContext.exit(1);
|
|
6309
7404
|
return;
|
|
6310
7405
|
}
|
|
6311
|
-
const
|
|
6312
|
-
const venvPath =
|
|
6313
|
-
if (await
|
|
7406
|
+
const fs2 = getFileSystem();
|
|
7407
|
+
const venvPath = fs2.path.join(fs2.env.cwd(), ".venv");
|
|
7408
|
+
if (await fs2.exists(venvPath) && !process.env.VIRTUAL_ENV) {
|
|
6314
7409
|
OutputFormatter.error({
|
|
6315
7410
|
Result: RESULTS.Failure,
|
|
6316
7411
|
Message: "Found .venv in current directory but no virtual environment is activated.",
|
|
@@ -6375,13 +7470,7 @@ var WHITELISTED_COMMANDS = [
|
|
|
6375
7470
|
{ name: "register", description: "Register a local resource." },
|
|
6376
7471
|
{ name: "run", description: "Execute the project." }
|
|
6377
7472
|
];
|
|
6378
|
-
var COMMAND_RULES = [
|
|
6379
|
-
{
|
|
6380
|
-
pattern: ["dev"],
|
|
6381
|
-
action: "append",
|
|
6382
|
-
appendArgs: ["--interactive"]
|
|
6383
|
-
}
|
|
6384
|
-
];
|
|
7473
|
+
var COMMAND_RULES = [];
|
|
6385
7474
|
function hasFlag(args, ...flags) {
|
|
6386
7475
|
return args.some((arg) => flags.includes(arg));
|
|
6387
7476
|
}
|
|
@@ -6390,7 +7479,7 @@ function needsPersonalWorkspaceLookup(args) {
|
|
|
6390
7479
|
return (command === "deploy" || command === "publish") && hasFlag(args, "--my-workspace", "-w");
|
|
6391
7480
|
}
|
|
6392
7481
|
function scopeListFromToken(token) {
|
|
6393
|
-
const [error, payload] =
|
|
7482
|
+
const [error, payload] = catchError(() => parseJWT(token));
|
|
6394
7483
|
if (error) {
|
|
6395
7484
|
return null;
|
|
6396
7485
|
}
|
|
@@ -6432,6 +7521,6 @@ var codedAgentCommandPreflight = ({
|
|
|
6432
7521
|
};
|
|
6433
7522
|
};
|
|
6434
7523
|
|
|
6435
|
-
export {
|
|
7524
|
+
export { getFileSystem, catchError, extractErrorMessageSync, RESULTS, OutputFormatter, Command, processContext, trackShipSucceeded, runUipathPythonCommand, createExecuteCommand, createSetupCommand, WHITELISTED_COMMANDS, COMMAND_RULES, codedAgentCommandPreflight };
|
|
6436
7525
|
|
|
6437
|
-
//# debugId=
|
|
7526
|
+
//# debugId=5AA8B2F233EFC85164756E2164756E21
|