@uipath/solution-tool 1.204.0 → 1.205.0-preview.258
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 +3 -3
- package/dist/THIRD-PARTY-NOTICES.md +2 -2
- package/dist/archive-extract-x35t9ktj.js +120 -0
- package/dist/cleanup-command-service-rc5e42hk.js +149 -0
- package/dist/deploy-delete-service-qdbtj3qd.js +25 -0
- package/dist/deploy-run-service-m9mg34n5.js +25 -0
- package/dist/{deploy-status-service-3req7hje.js → deploy-status-service-kz3nk43q.js} +41 -33
- package/dist/deploy.js +23 -17
- package/dist/{deployment-search-3mah6f0a.js → deployment-search-jvwyaqek.js} +16 -10
- package/dist/{embedded-file-reader-rf2g1kfj.js → embedded-file-reader-z4becc02.js} +2 -2
- package/dist/{feed-resolver-bxj9xkgr.js → feed-resolver-3xb7ayx4.js} +10 -9
- package/dist/feed-scope-failure-qps17dv3.js +19 -0
- package/dist/{feed-session-sxga31vn.js → feed-session-7xqphdrg.js} +3 -3
- package/dist/governance-options-amc1v319.js +32 -0
- package/dist/index-6wak6hg6.js +667 -0
- package/dist/index-prm27bvm.js +138 -0
- package/dist/index.js +27 -29
- package/dist/init.js +11 -10
- package/dist/{list-s5pkkefj.js → list-7jy11vb4.js} +10 -8
- package/dist/models/pack-command-types.d.ts +15 -0
- package/dist/node-p1scvsw8.js +86 -0
- package/dist/pack-command-service-8etwpgm9.js +35 -0
- package/dist/pack-project-hjvbvhgx.js +97 -0
- package/dist/pack.js +24 -14
- package/dist/package-id-c18sx4mz.js +13 -0
- package/dist/packager-tool-09fwj7e8.js +171 -0
- package/dist/{packager-tool-nfmygm61.js → packager-tool-361zx07h.js} +74 -23
- package/dist/packager-tool-37jmavap.js +42 -0
- package/dist/{packager-tool-px1j9kre.js → packager-tool-3bwnkjdq.js} +2 -2
- package/dist/{packager-tool-gb35b4qs.js → packager-tool-43ahv5mn.js} +192 -96
- package/dist/packager-tool-47wzvqw0.js +86 -0
- package/dist/{packager-tool-gfhdpkp3.js → packager-tool-4bq36bf5.js} +25 -4
- package/dist/packager-tool-4jekgh4s.js +517 -0
- package/dist/{packager-tool-zns6n8zp.js → packager-tool-5ddtwzva.js} +1 -1
- package/dist/packager-tool-5edvzz80.js +543 -0
- package/dist/packager-tool-5y09xhx5.js +1333 -0
- package/dist/packager-tool-60af1hw2.js +26 -0
- package/dist/{packager-tool-f5gq77m5.js → packager-tool-61pwb567.js} +2 -2
- package/dist/{packager-tool-kdwsw2x7.js → packager-tool-69jmxeh0.js} +196 -1519
- package/dist/{packager-tool-yrz4mwfn.js → packager-tool-6kz1pv9f.js} +1373 -486
- package/dist/{packager-tool-stsnbewn.js → packager-tool-6x35kvbx.js} +17 -8
- package/dist/packager-tool-6ybywxxn.js +1809 -0
- package/dist/{packager-tool-wfkv9v8b.js → packager-tool-85pen8t9.js} +2196 -3455
- package/dist/packager-tool-8ptbmmmp.js +2132 -0
- package/dist/{packager-tool-9ex75r32.js → packager-tool-8q4tvv8d.js} +6 -4
- package/dist/packager-tool-8rg0s4w9.js +109 -0
- package/dist/{packager-tool-7gr2nphb.js → packager-tool-97rcgwvv.js} +224 -6
- package/dist/packager-tool-act5r386.js +239 -0
- package/dist/packager-tool-amhyxzz6.js +125 -0
- package/dist/{packager-tool-j3520gxw.js → packager-tool-an5bpbwe.js} +3556 -1646
- package/dist/{packager-tool-e2rtr49j.js → packager-tool-b2nhscfk.js} +15 -31
- package/dist/packager-tool-bqw7edje.js +188 -0
- package/dist/{packager-tool-4gs8y6pr.js → packager-tool-dwxswyv4.js} +149 -53
- package/dist/{packager-tool-fehvgd51.js → packager-tool-e7vczxa8.js} +357 -1370
- package/dist/{packager-tool-v8bkkqdb.js → packager-tool-gmwva4yv.js} +5 -5
- package/dist/packager-tool-gs3f3tf7.js +103 -0
- package/dist/packager-tool-kkfb5kgn.js +182 -0
- package/dist/{packager-tool-ds45xby2.js → packager-tool-m74zqwmh.js} +104 -14
- package/dist/{packager-tool-fv7xyzg2.js → packager-tool-pbmqk39a.js} +126 -128
- package/dist/packager-tool-q5j6k3fy.js +1510 -0
- package/dist/packager-tool-qk21gk5m.js +445 -0
- package/dist/{packager-tool-bqre28m1.js → packager-tool-qw47eyw7.js} +1 -1
- package/dist/packager-tool-resolver-994z3jkj.js +23 -0
- package/dist/{packager-tool-gab9y5ct.js → packager-tool-t8gh825q.js} +37 -13
- package/dist/{packager-tool-kswwd3hp.js → packager-tool-tx834spe.js} +2376 -4077
- package/dist/{packager-tool-zf3929se.js → packager-tool-v1f5e8t9.js} +11 -1
- package/dist/{packager-tool-g8kjzrg7.js → packager-tool-wknfv4p5.js} +13 -11
- package/dist/{packager-tool-1rzssy0x.js → packager-tool-wy4fx250.js} +19 -18
- package/dist/packager-tool-y2k2f6yg.js +68 -0
- package/dist/packager-tool.js +2 -2
- package/dist/prepare-solution-resources-m1djfj62.js +29 -0
- package/dist/project-command-utils-t6pmpvq3.js +90 -0
- package/dist/project-contributions-79ndycrx.js +32 -0
- package/dist/publish.js +13 -12
- package/dist/resource-mutations-c3krjqze.js +36 -0
- package/dist/resource-version-lookup-0e3e2j58.js +99 -0
- package/dist/resource.js +10 -9
- package/dist/restore-command-service-eyx911f2.js +155 -0
- package/dist/run-service-p1vzzqe3.js +428 -0
- package/dist/services/deploy-activate-service.d.ts +10 -5
- package/dist/services/deploy-delete-service.d.ts +8 -4
- package/dist/services/deploy-run-service.d.ts +34 -1
- package/dist/services/deploy-uninstall-service.d.ts +21 -3
- package/dist/services/deploy-upgrade-service.d.ts +35 -1
- package/dist/services/deployment-feed-locator.d.ts +15 -4
- package/dist/services/deployment-search-client.d.ts +5 -53
- package/dist/services/deployment-search.d.ts +58 -3
- package/dist/services/deployment-state.d.ts +84 -24
- package/dist/services/deployment-validation.d.ts +5 -0
- package/dist/services/emit-runtime-dependencies.d.ts +2 -1
- package/dist/services/feed-resolver.d.ts +6 -4
- package/dist/services/feed-selection.d.ts +47 -0
- package/dist/services/http-status.d.ts +2 -7
- package/dist/services/pack-command-service.d.ts +9 -0
- package/dist/services/pack-project-selection.d.ts +51 -0
- package/dist/services/pack-project.d.ts +26 -0
- package/dist/services/pack-service.d.ts +7 -3
- package/dist/services/package-search-client.d.ts +7 -0
- package/dist/services/packager-tool-resolver.d.ts +7 -1
- package/dist/services/packages-list-service.d.ts +1 -1
- package/dist/services/permanent-deletion-consent.d.ts +110 -0
- package/dist/services/pipeline-deploy-poll.d.ts +7 -0
- package/dist/services/prepare-solution-resources.d.ts +12 -2
- package/dist/services/project-contributions.d.ts +5 -4
- package/dist/services/search-failure.d.ts +9 -13
- package/dist/services/solution-packager-helpers.d.ts +5 -2
- package/dist/services/solution-path.d.ts +1 -1
- package/dist/services/uninstall-consent.d.ts +82 -0
- package/dist/ship-telemetry-myes7ak5.js +21 -0
- package/dist/solution-auth-aead70sw.js +11 -0
- package/dist/templates/AGENTS.md +125 -12
- package/dist/tool.js +27 -29
- package/dist/utils/deployment-errors.d.ts +9 -1
- package/package.json +2 -2
- package/dist/deploy-delete-service-1zydyyhj.js +0 -22
- package/dist/feed-scope-failure-2kndwpf6.js +0 -18
- package/dist/packager-tool-f2e9rzxk.js +0 -104
- package/dist/packager-tool-resolver-6zwhec62.js +0 -20
- package/dist/packager-tool-zdfn32bc.js +0 -4465
- package/dist/prepare-solution-resources-jpb5as2s.js +0 -25
- package/dist/project-contributions-6wpff2hm.js +0 -30
- package/dist/services/legacy-deployment-search-v3.d.ts +0 -23
|
@@ -0,0 +1,1809 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "./packager-tool-1de529jm.js";
|
|
4
|
+
|
|
5
|
+
// ../common/src/telemetry/pseudonymize.ts
|
|
6
|
+
var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
|
|
7
|
+
var PSEUDONYM_HEX_LENGTH = 32;
|
|
8
|
+
var SHA256_K = new Uint32Array([
|
|
9
|
+
1116352408,
|
|
10
|
+
1899447441,
|
|
11
|
+
3049323471,
|
|
12
|
+
3921009573,
|
|
13
|
+
961987163,
|
|
14
|
+
1508970993,
|
|
15
|
+
2453635748,
|
|
16
|
+
2870763221,
|
|
17
|
+
3624381080,
|
|
18
|
+
310598401,
|
|
19
|
+
607225278,
|
|
20
|
+
1426881987,
|
|
21
|
+
1925078388,
|
|
22
|
+
2162078206,
|
|
23
|
+
2614888103,
|
|
24
|
+
3248222580,
|
|
25
|
+
3835390401,
|
|
26
|
+
4022224774,
|
|
27
|
+
264347078,
|
|
28
|
+
604807628,
|
|
29
|
+
770255983,
|
|
30
|
+
1249150122,
|
|
31
|
+
1555081692,
|
|
32
|
+
1996064986,
|
|
33
|
+
2554220882,
|
|
34
|
+
2821834349,
|
|
35
|
+
2952996808,
|
|
36
|
+
3210313671,
|
|
37
|
+
3336571891,
|
|
38
|
+
3584528711,
|
|
39
|
+
113926993,
|
|
40
|
+
338241895,
|
|
41
|
+
666307205,
|
|
42
|
+
773529912,
|
|
43
|
+
1294757372,
|
|
44
|
+
1396182291,
|
|
45
|
+
1695183700,
|
|
46
|
+
1986661051,
|
|
47
|
+
2177026350,
|
|
48
|
+
2456956037,
|
|
49
|
+
2730485921,
|
|
50
|
+
2820302411,
|
|
51
|
+
3259730800,
|
|
52
|
+
3345764771,
|
|
53
|
+
3516065817,
|
|
54
|
+
3600352804,
|
|
55
|
+
4094571909,
|
|
56
|
+
275423344,
|
|
57
|
+
430227734,
|
|
58
|
+
506948616,
|
|
59
|
+
659060556,
|
|
60
|
+
883997877,
|
|
61
|
+
958139571,
|
|
62
|
+
1322822218,
|
|
63
|
+
1537002063,
|
|
64
|
+
1747873779,
|
|
65
|
+
1955562222,
|
|
66
|
+
2024104815,
|
|
67
|
+
2227730452,
|
|
68
|
+
2361852424,
|
|
69
|
+
2428436474,
|
|
70
|
+
2756734187,
|
|
71
|
+
3204031479,
|
|
72
|
+
3329325298
|
|
73
|
+
]);
|
|
74
|
+
var SHA256_INITIAL_STATE = new Uint32Array([
|
|
75
|
+
1779033703,
|
|
76
|
+
3144134277,
|
|
77
|
+
1013904242,
|
|
78
|
+
2773480762,
|
|
79
|
+
1359893119,
|
|
80
|
+
2600822924,
|
|
81
|
+
528734635,
|
|
82
|
+
1541459225
|
|
83
|
+
]);
|
|
84
|
+
function rotr(value, bits) {
|
|
85
|
+
return (value >>> bits | value << 32 - bits) >>> 0;
|
|
86
|
+
}
|
|
87
|
+
function sha256Hex(input) {
|
|
88
|
+
const bytes = new TextEncoder().encode(input);
|
|
89
|
+
const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
|
|
90
|
+
const buffer = new Uint8Array(paddedLength);
|
|
91
|
+
buffer.set(bytes);
|
|
92
|
+
buffer[bytes.length] = 128;
|
|
93
|
+
const view = new DataView(buffer.buffer);
|
|
94
|
+
const bitLength = bytes.length * 8;
|
|
95
|
+
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
|
|
96
|
+
view.setUint32(paddedLength - 4, bitLength >>> 0);
|
|
97
|
+
const state = SHA256_INITIAL_STATE.slice();
|
|
98
|
+
const schedule = new Uint32Array(64);
|
|
99
|
+
for (let offset = 0;offset < paddedLength; offset += 64) {
|
|
100
|
+
for (let i = 0;i < 16; i++) {
|
|
101
|
+
schedule[i] = view.getUint32(offset + i * 4);
|
|
102
|
+
}
|
|
103
|
+
for (let i = 16;i < 64; i++) {
|
|
104
|
+
const x = schedule[i - 15];
|
|
105
|
+
const y = schedule[i - 2];
|
|
106
|
+
const s0 = (rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3) >>> 0;
|
|
107
|
+
const s1 = (rotr(y, 17) ^ rotr(y, 19) ^ y >>> 10) >>> 0;
|
|
108
|
+
schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1 >>> 0;
|
|
109
|
+
}
|
|
110
|
+
let a = state[0];
|
|
111
|
+
let b = state[1];
|
|
112
|
+
let c = state[2];
|
|
113
|
+
let d = state[3];
|
|
114
|
+
let e = state[4];
|
|
115
|
+
let f = state[5];
|
|
116
|
+
let g = state[6];
|
|
117
|
+
let h = state[7];
|
|
118
|
+
for (let i = 0;i < 64; i++) {
|
|
119
|
+
const s1 = (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) >>> 0;
|
|
120
|
+
const ch = (e & f ^ ~e & g) >>> 0;
|
|
121
|
+
const temp1 = h + s1 + ch + SHA256_K[i] + schedule[i] >>> 0;
|
|
122
|
+
const s0 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) >>> 0;
|
|
123
|
+
const maj = (a & b ^ a & c ^ b & c) >>> 0;
|
|
124
|
+
const temp2 = s0 + maj >>> 0;
|
|
125
|
+
h = g;
|
|
126
|
+
g = f;
|
|
127
|
+
f = e;
|
|
128
|
+
e = d + temp1 >>> 0;
|
|
129
|
+
d = c;
|
|
130
|
+
c = b;
|
|
131
|
+
b = a;
|
|
132
|
+
a = temp1 + temp2 >>> 0;
|
|
133
|
+
}
|
|
134
|
+
state[0] = state[0] + a >>> 0;
|
|
135
|
+
state[1] = state[1] + b >>> 0;
|
|
136
|
+
state[2] = state[2] + c >>> 0;
|
|
137
|
+
state[3] = state[3] + d >>> 0;
|
|
138
|
+
state[4] = state[4] + e >>> 0;
|
|
139
|
+
state[5] = state[5] + f >>> 0;
|
|
140
|
+
state[6] = state[6] + g >>> 0;
|
|
141
|
+
state[7] = state[7] + h >>> 0;
|
|
142
|
+
}
|
|
143
|
+
let hex = "";
|
|
144
|
+
for (const word of state) {
|
|
145
|
+
hex += word.toString(16).padStart(8, "0");
|
|
146
|
+
}
|
|
147
|
+
return hex;
|
|
148
|
+
}
|
|
149
|
+
function resolveSha256Hex() {
|
|
150
|
+
try {
|
|
151
|
+
const nodeCrypto = __require("node:crypto");
|
|
152
|
+
const createHash = nodeCrypto?.createHash;
|
|
153
|
+
if (typeof createHash !== "function") {
|
|
154
|
+
return sha256Hex;
|
|
155
|
+
}
|
|
156
|
+
const native = (input) => createHash("sha256").update(input, "utf8").digest("hex");
|
|
157
|
+
return native("abc") === sha256Hex("abc") ? native : sha256Hex;
|
|
158
|
+
} catch {
|
|
159
|
+
return sha256Hex;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
var cachedSha256Hex;
|
|
163
|
+
function digest(input) {
|
|
164
|
+
cachedSha256Hex ??= resolveSha256Hex();
|
|
165
|
+
return cachedSha256Hex(input);
|
|
166
|
+
}
|
|
167
|
+
function pseudonymize(input) {
|
|
168
|
+
return digest(`${PSEUDONYM_DOMAIN}${input}`).slice(0, PSEUDONYM_HEX_LENGTH);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ../common/src/singleton.ts
|
|
172
|
+
var PREFIX = "@uipath/common/";
|
|
173
|
+
var _g = globalThis;
|
|
174
|
+
function singleton(ctorOrName) {
|
|
175
|
+
const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
|
|
176
|
+
const key = Symbol.for(PREFIX + name);
|
|
177
|
+
return {
|
|
178
|
+
get(fallback) {
|
|
179
|
+
return _g[key] ?? fallback;
|
|
180
|
+
},
|
|
181
|
+
set(value) {
|
|
182
|
+
_g[key] = value;
|
|
183
|
+
},
|
|
184
|
+
clear() {
|
|
185
|
+
delete _g[key];
|
|
186
|
+
},
|
|
187
|
+
getOrInit(factory, guard) {
|
|
188
|
+
const existing = _g[key];
|
|
189
|
+
if (existing != null && typeof existing === "object") {
|
|
190
|
+
if (!guard || guard(existing)) {
|
|
191
|
+
return existing;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const instance = factory();
|
|
195
|
+
_g[key] = instance;
|
|
196
|
+
return instance;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ../common/src/telemetry/supplied-values.ts
|
|
202
|
+
var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
|
|
203
|
+
function activeEntries() {
|
|
204
|
+
const existing = suppliedValuesSlot.get();
|
|
205
|
+
return Array.isArray(existing) ? existing : [];
|
|
206
|
+
}
|
|
207
|
+
var MIN_SCRUBBABLE_LENGTH = 4;
|
|
208
|
+
function recordSuppliedArgumentValues(values) {
|
|
209
|
+
const flat = [];
|
|
210
|
+
const push = (value) => {
|
|
211
|
+
if (Array.isArray(value)) {
|
|
212
|
+
for (const item of value) {
|
|
213
|
+
push(item);
|
|
214
|
+
}
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (typeof value === "string" && value.length >= MIN_SCRUBBABLE_LENGTH) {
|
|
218
|
+
flat.push(value);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
push(values);
|
|
222
|
+
const entry = { values: flat };
|
|
223
|
+
suppliedValuesSlot.set([...activeEntries(), entry]);
|
|
224
|
+
return entry;
|
|
225
|
+
}
|
|
226
|
+
function releaseSuppliedArgumentValues(entry) {
|
|
227
|
+
suppliedValuesSlot.set(activeEntries().filter((held) => held !== entry));
|
|
228
|
+
}
|
|
229
|
+
function getSuppliedArgumentValues() {
|
|
230
|
+
const all = new Set;
|
|
231
|
+
for (const entry of activeEntries()) {
|
|
232
|
+
for (const value of entry.values) {
|
|
233
|
+
all.add(value);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return [...all].sort((a, b) => b.length - a.length);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// ../common/src/telemetry/pii-redactor.ts
|
|
240
|
+
var REDACTED = "[REDACTED]";
|
|
241
|
+
var MAX_VALUE_LENGTH = 280;
|
|
242
|
+
var MAX_STACK_LENGTH = 4096;
|
|
243
|
+
var MAX_SCAN_LENGTH = MAX_STACK_LENGTH;
|
|
244
|
+
function truncate(value, maxLength) {
|
|
245
|
+
return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;
|
|
246
|
+
}
|
|
247
|
+
var SENSITIVE_NAME_TOKENS = new Set([
|
|
248
|
+
"token",
|
|
249
|
+
"tokens",
|
|
250
|
+
"secret",
|
|
251
|
+
"secrets",
|
|
252
|
+
"password",
|
|
253
|
+
"passwords",
|
|
254
|
+
"pwd",
|
|
255
|
+
"credential",
|
|
256
|
+
"credentials",
|
|
257
|
+
"auth",
|
|
258
|
+
"authentication",
|
|
259
|
+
"authorization",
|
|
260
|
+
"authority",
|
|
261
|
+
"cert",
|
|
262
|
+
"certificate",
|
|
263
|
+
"certificates"
|
|
264
|
+
]);
|
|
265
|
+
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
266
|
+
"api",
|
|
267
|
+
"access",
|
|
268
|
+
"client",
|
|
269
|
+
"private",
|
|
270
|
+
"public",
|
|
271
|
+
"signing",
|
|
272
|
+
"encryption",
|
|
273
|
+
"session",
|
|
274
|
+
"master",
|
|
275
|
+
"shared",
|
|
276
|
+
"root",
|
|
277
|
+
"ssh",
|
|
278
|
+
"rsa",
|
|
279
|
+
"aes",
|
|
280
|
+
"hmac",
|
|
281
|
+
"oauth"
|
|
282
|
+
]);
|
|
283
|
+
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;
|
|
284
|
+
var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
285
|
+
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
286
|
+
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
287
|
+
var PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
288
|
+
var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
|
|
289
|
+
var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
|
|
290
|
+
var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
|
|
291
|
+
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;
|
|
292
|
+
var SOURCE_FILE_EXTENSIONS = new Set([
|
|
293
|
+
"ts",
|
|
294
|
+
"tsx",
|
|
295
|
+
"js",
|
|
296
|
+
"jsx",
|
|
297
|
+
"mjs",
|
|
298
|
+
"cjs",
|
|
299
|
+
"cts",
|
|
300
|
+
"mts",
|
|
301
|
+
"py",
|
|
302
|
+
"cs",
|
|
303
|
+
"java",
|
|
304
|
+
"go",
|
|
305
|
+
"rs",
|
|
306
|
+
"rb",
|
|
307
|
+
"php",
|
|
308
|
+
"sh",
|
|
309
|
+
"ps1",
|
|
310
|
+
"json",
|
|
311
|
+
"jsonc",
|
|
312
|
+
"yaml",
|
|
313
|
+
"yml",
|
|
314
|
+
"xml",
|
|
315
|
+
"xaml",
|
|
316
|
+
"md",
|
|
317
|
+
"txt",
|
|
318
|
+
"log",
|
|
319
|
+
"css",
|
|
320
|
+
"html",
|
|
321
|
+
"htm",
|
|
322
|
+
"csproj",
|
|
323
|
+
"nuspec",
|
|
324
|
+
"sql"
|
|
325
|
+
]);
|
|
326
|
+
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
327
|
+
var QUOTED_LITERAL_MAX_SPAN = 200;
|
|
328
|
+
var QUOTED_LITERAL_PATTERN = new RegExp([
|
|
329
|
+
`(?<![A-Za-z0-9])'(?:[^\\
|
|
330
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
|
|
331
|
+
`(?<![A-Za-z0-9])"(?:[^\\
|
|
332
|
+
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
|
|
333
|
+
].join("|"), "g");
|
|
334
|
+
var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
|
|
335
|
+
var COLLAPSED_BODY = "{…}";
|
|
336
|
+
var COLLAPSED_BODY_MARKER = "\x01body\x01";
|
|
337
|
+
var MAX_BODY_NESTING = 8;
|
|
338
|
+
function collapseJsonBodies(text) {
|
|
339
|
+
let out = text;
|
|
340
|
+
for (let pass = 0;pass < MAX_BODY_NESTING; pass++) {
|
|
341
|
+
const next = out.replace(JSON_BODY_PATTERN, COLLAPSED_BODY_MARKER);
|
|
342
|
+
if (next === out) {
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
out = next;
|
|
346
|
+
}
|
|
347
|
+
return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
|
|
348
|
+
}
|
|
349
|
+
var TRAILING_PROSE_PUNCT = `.,;:!?)]}>'"`;
|
|
350
|
+
function peelTrailingPunctuation(match) {
|
|
351
|
+
let end = match.length;
|
|
352
|
+
while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
|
|
353
|
+
end -= 1;
|
|
354
|
+
}
|
|
355
|
+
return [match.slice(0, end), match.slice(end)];
|
|
356
|
+
}
|
|
357
|
+
function redactUrl(raw) {
|
|
358
|
+
try {
|
|
359
|
+
const url = new URL(raw);
|
|
360
|
+
return `${url.protocol}//${url.host}`;
|
|
361
|
+
} catch {
|
|
362
|
+
return `url#${pseudonymize(raw)}`;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
|
|
366
|
+
let out = truncate(value, MAX_SCAN_LENGTH);
|
|
367
|
+
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
368
|
+
out = out.replace(URL_PATTERN, (match) => {
|
|
369
|
+
const [core, trailing] = peelTrailingPunctuation(match);
|
|
370
|
+
return `${redactUrl(core)}${trailing}`;
|
|
371
|
+
});
|
|
372
|
+
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
373
|
+
out = out.replace(UNC_PATH_PATTERN, (_match, before, path) => {
|
|
374
|
+
const [core, trailing] = peelTrailingPunctuation(path);
|
|
375
|
+
return `${before}unc#${pseudonymize(core)}${trailing}`;
|
|
376
|
+
});
|
|
377
|
+
out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
|
|
378
|
+
out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
|
|
379
|
+
out = out.replace(HOST_PORT_PATTERN, (match) => {
|
|
380
|
+
const split = match.lastIndexOf(":");
|
|
381
|
+
const host = match.slice(0, split);
|
|
382
|
+
const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
|
|
383
|
+
if (SOURCE_FILE_EXTENSIONS.has(extension)) {
|
|
384
|
+
return match;
|
|
385
|
+
}
|
|
386
|
+
return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
|
|
387
|
+
});
|
|
388
|
+
out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
|
|
389
|
+
out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
|
|
390
|
+
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
391
|
+
return truncate(out, maxLength);
|
|
392
|
+
}
|
|
393
|
+
function redactSpanName(name) {
|
|
394
|
+
return redactValueDetectors(truncate(name, MAX_SCAN_LENGTH).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`));
|
|
395
|
+
}
|
|
396
|
+
var HTTP_DEPENDENCY_NAME = /^([A-Z]+) (\/.*)$/s;
|
|
397
|
+
function redactHttpDependencyName(name) {
|
|
398
|
+
const parts = HTTP_DEPENDENCY_NAME.exec(name);
|
|
399
|
+
if (!parts) {
|
|
400
|
+
return redactMessage(name);
|
|
401
|
+
}
|
|
402
|
+
return `${parts[1]} ${redactMessage(parts[2])}`;
|
|
403
|
+
}
|
|
404
|
+
function redactMessage(value) {
|
|
405
|
+
let out = collapseJsonBodies(truncate(value, MAX_SCAN_LENGTH)).replace(QUOTED_LITERAL_PATTERN, (match) => `${match[0]}<redacted>${match[0]}`);
|
|
406
|
+
for (const supplied of getSuppliedArgumentValues()) {
|
|
407
|
+
out = out.split(supplied).join(REDACTED);
|
|
408
|
+
}
|
|
409
|
+
return redactValueDetectors(out);
|
|
410
|
+
}
|
|
411
|
+
var MESSAGE_NAMES = new Set([
|
|
412
|
+
"message",
|
|
413
|
+
"errormessage",
|
|
414
|
+
"errmessage",
|
|
415
|
+
"error_message",
|
|
416
|
+
"msg",
|
|
417
|
+
"detail",
|
|
418
|
+
"details",
|
|
419
|
+
"reason",
|
|
420
|
+
"instructions",
|
|
421
|
+
"warning"
|
|
422
|
+
]);
|
|
423
|
+
function isFreeFormValue(name, value) {
|
|
424
|
+
return MESSAGE_NAMES.has(name.toLowerCase()) || /['"{[]/.test(value);
|
|
425
|
+
}
|
|
426
|
+
function redactError(error) {
|
|
427
|
+
const safe = new Error(redactMessage(error.message ?? ""));
|
|
428
|
+
safe.name = error.name;
|
|
429
|
+
safe.stack = typeof error.stack === "string" ? redactStack(error.stack) : undefined;
|
|
430
|
+
return safe;
|
|
431
|
+
}
|
|
432
|
+
function redactStack(stack) {
|
|
433
|
+
const bounded = truncate(stack, MAX_STACK_LENGTH);
|
|
434
|
+
const firstBreak = bounded.indexOf(`
|
|
435
|
+
`);
|
|
436
|
+
if (firstBreak === -1) {
|
|
437
|
+
return redactMessage(bounded);
|
|
438
|
+
}
|
|
439
|
+
return `${redactMessage(bounded.slice(0, firstBreak))}
|
|
440
|
+
${redactValueDetectors(bounded.slice(firstBreak + 1), MAX_STACK_LENGTH)}`;
|
|
441
|
+
}
|
|
442
|
+
function nameTokens(name) {
|
|
443
|
+
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);
|
|
444
|
+
}
|
|
445
|
+
function isSensitiveName(name) {
|
|
446
|
+
const tokens = nameTokens(name);
|
|
447
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
448
|
+
const token = tokens[i];
|
|
449
|
+
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
if (token === "key" || token === "keys") {
|
|
453
|
+
const prev = tokens[i - 1];
|
|
454
|
+
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
function redactProperty(name, value) {
|
|
462
|
+
if (value === undefined || value === null) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
if (isSensitiveName(name)) {
|
|
466
|
+
return REDACTED;
|
|
467
|
+
}
|
|
468
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
469
|
+
return value;
|
|
470
|
+
}
|
|
471
|
+
if (typeof value !== "string") {
|
|
472
|
+
return "[OBJECT]";
|
|
473
|
+
}
|
|
474
|
+
return isFreeFormValue(name, value) ? redactMessage(value) : redactValueDetectors(value);
|
|
475
|
+
}
|
|
476
|
+
function redactProperties(properties) {
|
|
477
|
+
const out = {};
|
|
478
|
+
for (const [name, value] of Object.entries(properties)) {
|
|
479
|
+
const redacted = redactProperty(name, value);
|
|
480
|
+
if (redacted !== undefined) {
|
|
481
|
+
out[name] = redacted;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return out;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// ../common/src/catch-error.ts
|
|
488
|
+
var MAX_SERIALIZED_LENGTH = 500;
|
|
489
|
+
var TRUNCATION_SUFFIX = "…(truncated)";
|
|
490
|
+
var REDACTED2 = "[REDACTED]";
|
|
491
|
+
function cap(text) {
|
|
492
|
+
return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
|
|
493
|
+
}
|
|
494
|
+
function omitSensitive(key, value) {
|
|
495
|
+
return key.length > 0 && isSensitiveName(key) ? REDACTED2 : value;
|
|
496
|
+
}
|
|
497
|
+
function describeThrownValue(value) {
|
|
498
|
+
if (typeof value !== "object" || value === null) {
|
|
499
|
+
return String(value);
|
|
500
|
+
}
|
|
501
|
+
let message;
|
|
502
|
+
try {
|
|
503
|
+
message = value.message;
|
|
504
|
+
} catch {
|
|
505
|
+
message = undefined;
|
|
506
|
+
}
|
|
507
|
+
if (typeof message === "string" && message.length > 0) {
|
|
508
|
+
return cap(message);
|
|
509
|
+
}
|
|
510
|
+
try {
|
|
511
|
+
const json = JSON.stringify(value, omitSensitive);
|
|
512
|
+
if (json !== undefined) {
|
|
513
|
+
return cap(json);
|
|
514
|
+
}
|
|
515
|
+
} catch {}
|
|
516
|
+
return String(value);
|
|
517
|
+
}
|
|
518
|
+
function toError(error) {
|
|
519
|
+
return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
|
|
520
|
+
}
|
|
521
|
+
function isPromiseLike(value) {
|
|
522
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
523
|
+
}
|
|
524
|
+
function catchError(fnOrPromise) {
|
|
525
|
+
if (isPromiseLike(fnOrPromise)) {
|
|
526
|
+
return settlePromiseLike(fnOrPromise);
|
|
527
|
+
}
|
|
528
|
+
try {
|
|
529
|
+
const result = fnOrPromise();
|
|
530
|
+
if (isPromiseLike(result)) {
|
|
531
|
+
return settlePromiseLike(result);
|
|
532
|
+
}
|
|
533
|
+
return [undefined, result];
|
|
534
|
+
} catch (error) {
|
|
535
|
+
return [toError(error), undefined];
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
function settlePromiseLike(thenable) {
|
|
539
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// ../common/src/error-graph.ts
|
|
543
|
+
function* walkErrorGraph(error) {
|
|
544
|
+
const queue = [error];
|
|
545
|
+
const seen = new Set;
|
|
546
|
+
for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
|
|
547
|
+
const current = queue.shift();
|
|
548
|
+
if (current === null || typeof current !== "object")
|
|
549
|
+
continue;
|
|
550
|
+
if (seen.has(current))
|
|
551
|
+
continue;
|
|
552
|
+
seen.add(current);
|
|
553
|
+
const cur = current;
|
|
554
|
+
yield cur;
|
|
555
|
+
if (cur.cause !== undefined)
|
|
556
|
+
queue.push(cur.cause);
|
|
557
|
+
if (Array.isArray(cur.errors))
|
|
558
|
+
queue.push(...cur.errors);
|
|
559
|
+
}
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
function parseHttpStatusFromMessage(message) {
|
|
563
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
564
|
+
if (!match)
|
|
565
|
+
return;
|
|
566
|
+
const status = Number(match[1]);
|
|
567
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
568
|
+
}
|
|
569
|
+
function findHttpStatusInGraph(error) {
|
|
570
|
+
for (const node of walkErrorGraph(error)) {
|
|
571
|
+
const response = node.response;
|
|
572
|
+
const explicit = typeof node.status === "number" ? node.status : response?.status;
|
|
573
|
+
if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
|
|
574
|
+
return explicit;
|
|
575
|
+
}
|
|
576
|
+
if (typeof node.message === "string") {
|
|
577
|
+
const parsed = parseHttpStatusFromMessage(node.message);
|
|
578
|
+
if (parsed !== undefined && parsed >= 400) {
|
|
579
|
+
return parsed;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
// ../common/src/local-permission-codes.ts
|
|
587
|
+
var LOCAL_PERMISSION_ERROR_CODES = new Set([
|
|
588
|
+
"EACCES",
|
|
589
|
+
"EPERM",
|
|
590
|
+
"EROFS"
|
|
591
|
+
]);
|
|
592
|
+
|
|
593
|
+
// ../common/src/error-handler.ts
|
|
594
|
+
var DEFAULT_401 = "Unauthorized (401). The session is missing or expired, or its token carries no scope for this API. Run `uip login status --detailed` to see the session and its scopes.";
|
|
595
|
+
var DEFAULT_403 = "Forbidden (403). The account lacks permission for this operation, or the token carries no scope for this API. Run `uip login status --detailed` to see the token's scopes.";
|
|
596
|
+
var DEFAULT_405 = "Method Not Allowed (405). The endpoint may not exist or the base URL may be incorrect.";
|
|
597
|
+
var DEFAULT_413 = "Payload too large (413). The upload exceeded the server or CDN size limit. Reduce the package size — for example, exclude unused dependencies or remove large files from the project — and try again.";
|
|
598
|
+
var HTML_RESPONSE_MESSAGE = "Received HTML instead of the expected JSON response.";
|
|
599
|
+
var NETWORK_ERROR_CODES = new Set([
|
|
600
|
+
"ECONNREFUSED",
|
|
601
|
+
"ECONNRESET",
|
|
602
|
+
"ENOTFOUND",
|
|
603
|
+
"EAI_AGAIN",
|
|
604
|
+
"ETIMEDOUT",
|
|
605
|
+
"EPIPE",
|
|
606
|
+
"EHOSTUNREACH",
|
|
607
|
+
"ENETUNREACH",
|
|
608
|
+
"EAI_FAIL"
|
|
609
|
+
]);
|
|
610
|
+
var TLS_ERROR_CODES = new Set([
|
|
611
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
612
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
613
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
614
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
615
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
616
|
+
"CERT_HAS_EXPIRED",
|
|
617
|
+
"CERT_UNTRUSTED",
|
|
618
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
619
|
+
]);
|
|
620
|
+
var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
|
|
621
|
+
var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
|
|
622
|
+
var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
|
|
623
|
+
function localPermissionInstructions(code, path) {
|
|
624
|
+
const target = path !== undefined ? `'${path}'` : "a local file or resource";
|
|
625
|
+
if (code === "EROFS") {
|
|
626
|
+
return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
|
|
627
|
+
}
|
|
628
|
+
const onWindows = typeof process !== "undefined" && process.platform === "win32";
|
|
629
|
+
const remedy = onWindows ? "Re-run from an elevated terminal, close any program holding " + "the file open, or grant your user access to the path." : "Grant this user (or the sandbox the command runs in) access " + "to the path, or run the command outside the sandbox.";
|
|
630
|
+
return `The operating system denied access to ${target} (${code}). This is ` + "a local permission problem, not a UiPath service error — retrying " + `without a permission change will not help. ${remedy}`;
|
|
631
|
+
}
|
|
632
|
+
function carriedInstructions(error) {
|
|
633
|
+
if (!error || typeof error !== "object")
|
|
634
|
+
return;
|
|
635
|
+
const e = error;
|
|
636
|
+
return typeof e.instructions === "string" ? e.instructions : undefined;
|
|
637
|
+
}
|
|
638
|
+
function describeConnectivityError(error) {
|
|
639
|
+
for (const cur of walkErrorGraph(error)) {
|
|
640
|
+
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
641
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
642
|
+
if (code && TLS_ERROR_CODES.has(code)) {
|
|
643
|
+
return {
|
|
644
|
+
code,
|
|
645
|
+
kind: "tls",
|
|
646
|
+
message: message ?? code,
|
|
647
|
+
instructions: TLS_INSTRUCTIONS
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
651
|
+
return {
|
|
652
|
+
code,
|
|
653
|
+
kind: "network",
|
|
654
|
+
message: message ?? code,
|
|
655
|
+
instructions: NETWORK_INSTRUCTIONS
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
function describePermissionError(error) {
|
|
662
|
+
for (const cur of walkErrorGraph(error)) {
|
|
663
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
664
|
+
const code = matchLocalPermissionCode(cur.code, message);
|
|
665
|
+
if (!code)
|
|
666
|
+
continue;
|
|
667
|
+
const path = localPermissionPath(cur.path, message);
|
|
668
|
+
return {
|
|
669
|
+
code,
|
|
670
|
+
message: message ?? code,
|
|
671
|
+
...path !== undefined ? { path } : {},
|
|
672
|
+
instructions: localPermissionInstructions(code, path)
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
function matchLocalPermissionCode(code, message) {
|
|
678
|
+
if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
|
|
679
|
+
return code;
|
|
680
|
+
}
|
|
681
|
+
const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
|
|
682
|
+
return match ? match[1] : undefined;
|
|
683
|
+
}
|
|
684
|
+
function localPermissionPath(path, message) {
|
|
685
|
+
if (typeof path === "string")
|
|
686
|
+
return path;
|
|
687
|
+
return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
|
|
688
|
+
}
|
|
689
|
+
function isHtmlDocument(body) {
|
|
690
|
+
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
691
|
+
}
|
|
692
|
+
function retryHintForRetryAfter(seconds) {
|
|
693
|
+
if (seconds <= 1) {
|
|
694
|
+
return "RetryAfter1Second";
|
|
695
|
+
}
|
|
696
|
+
if (seconds <= 10) {
|
|
697
|
+
return "RetryAfter10Seconds";
|
|
698
|
+
}
|
|
699
|
+
if (seconds <= 30) {
|
|
700
|
+
return "RetryAfter30Seconds";
|
|
701
|
+
}
|
|
702
|
+
return "RetryAfter60Seconds";
|
|
703
|
+
}
|
|
704
|
+
function classifyError(status, error) {
|
|
705
|
+
if (status === 400 || status === 409 || status === 422) {
|
|
706
|
+
return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
|
|
707
|
+
}
|
|
708
|
+
if (status === 401) {
|
|
709
|
+
return {
|
|
710
|
+
errorCode: "authentication_required",
|
|
711
|
+
retry: "RetryWillNotFix"
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
if (status === 403) {
|
|
715
|
+
return { errorCode: "permission_denied", retry: "RetryWillNotFix" };
|
|
716
|
+
}
|
|
717
|
+
if (status === 404) {
|
|
718
|
+
return { errorCode: "not_found", retry: "RetryWillNotFix" };
|
|
719
|
+
}
|
|
720
|
+
if (status === 405) {
|
|
721
|
+
return { errorCode: "method_not_allowed", retry: "RetryWillNotFix" };
|
|
722
|
+
}
|
|
723
|
+
if (status === 413) {
|
|
724
|
+
return { errorCode: "invalid_argument", retry: "RetryWillNotFix" };
|
|
725
|
+
}
|
|
726
|
+
if (status === 408) {
|
|
727
|
+
return { errorCode: "timeout", retry: "RetryLater" };
|
|
728
|
+
}
|
|
729
|
+
if (status === 429) {
|
|
730
|
+
return { errorCode: "rate_limited", retry: "RetryLater" };
|
|
731
|
+
}
|
|
732
|
+
if (status !== undefined && status >= 500 && status < 600) {
|
|
733
|
+
return { errorCode: "server_error", retry: "RetryLater" };
|
|
734
|
+
}
|
|
735
|
+
if (status === undefined && describePermissionError(error)) {
|
|
736
|
+
return {
|
|
737
|
+
errorCode: "local_permission_denied",
|
|
738
|
+
retry: "RetryWillNotFix"
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
const connectivity = describeConnectivityError(error);
|
|
742
|
+
if (connectivity) {
|
|
743
|
+
return {
|
|
744
|
+
errorCode: "network_error",
|
|
745
|
+
retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
749
|
+
}
|
|
750
|
+
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
751
|
+
if (extractedMessage) {
|
|
752
|
+
return `HTTP ${status}: ${extractedMessage}`;
|
|
753
|
+
}
|
|
754
|
+
return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
|
|
755
|
+
}
|
|
756
|
+
async function extractErrorDetails(error, options) {
|
|
757
|
+
const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
|
|
758
|
+
const response = err.response;
|
|
759
|
+
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
760
|
+
const explicitStatus = err.status ?? response?.status;
|
|
761
|
+
const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
|
|
762
|
+
const status = explicitStatus ?? inferredStatus;
|
|
763
|
+
const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
|
|
764
|
+
let rawBody;
|
|
765
|
+
let extractedMessage;
|
|
766
|
+
let parsedBody;
|
|
767
|
+
const textFn = response?.text?.bind(response);
|
|
768
|
+
if (textFn) {
|
|
769
|
+
const [bodyError, body] = await catchError((async () => textFn())());
|
|
770
|
+
if (!bodyError && body) {
|
|
771
|
+
rawBody = body;
|
|
772
|
+
const [parseError, parsed] = catchError(() => JSON.parse(body));
|
|
773
|
+
if (!parseError && parsed && typeof parsed === "object") {
|
|
774
|
+
parsedBody = parsed;
|
|
775
|
+
if (parsedBody.errors && typeof parsedBody.errors === "object") {
|
|
776
|
+
for (const field of Object.values(parsedBody.errors)) {
|
|
777
|
+
if (Array.isArray(field) && field.length > 0) {
|
|
778
|
+
const first = field[0];
|
|
779
|
+
if (first && typeof first.message === "string") {
|
|
780
|
+
extractedMessage = first.message;
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
if (!extractedMessage) {
|
|
787
|
+
extractedMessage = typeof parsedBody.message === "string" ? parsedBody.message : typeof parsedBody.errorMessage === "string" ? parsedBody.errorMessage : typeof parsedBody.title === "string" ? parsedBody.title : undefined;
|
|
788
|
+
}
|
|
789
|
+
if (!extractedMessage) {
|
|
790
|
+
extractedMessage = body;
|
|
791
|
+
}
|
|
792
|
+
if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
|
|
793
|
+
extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
|
|
794
|
+
}
|
|
795
|
+
} else {
|
|
796
|
+
extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
let message;
|
|
801
|
+
let result = "Failure";
|
|
802
|
+
const classificationStatus = status ?? findHttpStatusInGraph(error);
|
|
803
|
+
const classification = classifyError(classificationStatus, error);
|
|
804
|
+
let retry = classification.retry;
|
|
805
|
+
if (status === 401) {
|
|
806
|
+
message = DEFAULT_401;
|
|
807
|
+
result = "AuthenticationError";
|
|
808
|
+
} else if (status === 403) {
|
|
809
|
+
message = options?.forbiddenMessage ?? DEFAULT_403;
|
|
810
|
+
result = "AuthenticationError";
|
|
811
|
+
} else if (status === 405) {
|
|
812
|
+
message = DEFAULT_405;
|
|
813
|
+
} else if (status === 413) {
|
|
814
|
+
message = DEFAULT_413;
|
|
815
|
+
} else if (status === 400 || status === 422) {
|
|
816
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
817
|
+
result = "ValidationError";
|
|
818
|
+
} else if (status === 429) {
|
|
819
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
820
|
+
} else if (extractedMessage) {
|
|
821
|
+
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
822
|
+
message = rawMessage;
|
|
823
|
+
} else {
|
|
824
|
+
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
825
|
+
}
|
|
826
|
+
} else if (status) {
|
|
827
|
+
if (inferredStatus !== undefined) {
|
|
828
|
+
message = rawMessage;
|
|
829
|
+
} else if (rawMessage === "Unknown error" && response) {
|
|
830
|
+
const statusText = response.statusText;
|
|
831
|
+
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
832
|
+
} else {
|
|
833
|
+
message = `HTTP ${status}: ${rawMessage}`;
|
|
834
|
+
}
|
|
835
|
+
} else {
|
|
836
|
+
message = rawMessage;
|
|
837
|
+
}
|
|
838
|
+
if (status === undefined) {
|
|
839
|
+
const connectivity = describeConnectivityError(error);
|
|
840
|
+
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
841
|
+
message = `${message}: ${connectivity.message}`;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
const permission = status === undefined ? describePermissionError(error) : undefined;
|
|
845
|
+
if (permission) {
|
|
846
|
+
if (permission.message !== message && !message.includes(permission.message)) {
|
|
847
|
+
message = `${message}: ${permission.message}`;
|
|
848
|
+
}
|
|
849
|
+
if (!message.includes(permission.instructions)) {
|
|
850
|
+
const punctuated = message.endsWith(".") ? message : `${message}.`;
|
|
851
|
+
message = `${punctuated} ${permission.instructions}`;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
let details = rawMessage;
|
|
855
|
+
if (rawBody) {
|
|
856
|
+
if (parsedBody) {
|
|
857
|
+
const extra = {};
|
|
858
|
+
if (parsedBody.errorCode)
|
|
859
|
+
extra.errorCode = parsedBody.errorCode;
|
|
860
|
+
if (parsedBody.detail)
|
|
861
|
+
extra.detail = parsedBody.detail;
|
|
862
|
+
if (parsedBody.details)
|
|
863
|
+
extra.details = parsedBody.details;
|
|
864
|
+
if (parsedBody.errors != null)
|
|
865
|
+
extra.errors = parsedBody.errors;
|
|
866
|
+
if (parsedBody.data && typeof parsedBody.data === "object" && Object.keys(parsedBody.data).length > 0) {
|
|
867
|
+
extra.data = parsedBody.data;
|
|
868
|
+
}
|
|
869
|
+
details = Object.keys(extra).length > 0 ? JSON.stringify(extra) : rawBody;
|
|
870
|
+
} else {
|
|
871
|
+
details = rawBody;
|
|
872
|
+
}
|
|
873
|
+
} else if (typeof err.message === "string") {
|
|
874
|
+
details = err.message;
|
|
875
|
+
} else {
|
|
876
|
+
details = describeThrownValue(error);
|
|
877
|
+
}
|
|
878
|
+
const context = {};
|
|
879
|
+
if (classificationStatus) {
|
|
880
|
+
context.httpStatus = classificationStatus;
|
|
881
|
+
}
|
|
882
|
+
if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
|
|
883
|
+
context.errorCode = parsedBody.errorCode;
|
|
884
|
+
} else if (parsedBody?.code && typeof parsedBody.code === "string") {
|
|
885
|
+
context.errorCode = parsedBody.code;
|
|
886
|
+
}
|
|
887
|
+
if (parsedBody?.requestId && typeof parsedBody.requestId === "string") {
|
|
888
|
+
context.requestId = parsedBody.requestId;
|
|
889
|
+
}
|
|
890
|
+
if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
|
|
891
|
+
context.traceId = parsedBody.traceId;
|
|
892
|
+
}
|
|
893
|
+
if (permission?.path !== undefined) {
|
|
894
|
+
context.path = permission.path;
|
|
895
|
+
}
|
|
896
|
+
if (status === 429) {
|
|
897
|
+
const resp = response;
|
|
898
|
+
const headersObj = resp?.headers;
|
|
899
|
+
let retryAfterValue;
|
|
900
|
+
if (headersObj && typeof headersObj === "object" && typeof headersObj.get === "function") {
|
|
901
|
+
retryAfterValue = headersObj.get("retry-after") ?? undefined;
|
|
902
|
+
}
|
|
903
|
+
if (!retryAfterValue && headersObj && typeof headersObj === "object") {
|
|
904
|
+
const headers = headersObj;
|
|
905
|
+
retryAfterValue = headers["retry-after"] ?? headers["Retry-After"];
|
|
906
|
+
}
|
|
907
|
+
if (retryAfterValue) {
|
|
908
|
+
const seconds = Number(retryAfterValue);
|
|
909
|
+
if (!Number.isNaN(seconds)) {
|
|
910
|
+
context.retryAfter = seconds;
|
|
911
|
+
retry = retryHintForRetryAfter(seconds);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
const hasContext = Object.keys(context).length > 0;
|
|
916
|
+
let parsedErrors;
|
|
917
|
+
if (parsedBody?.errors && typeof parsedBody.errors === "object") {
|
|
918
|
+
const errors = {};
|
|
919
|
+
for (const [field, raw] of Object.entries(parsedBody.errors)) {
|
|
920
|
+
if (Array.isArray(raw)) {
|
|
921
|
+
const messages = raw.map((entry) => {
|
|
922
|
+
if (typeof entry === "string")
|
|
923
|
+
return entry;
|
|
924
|
+
if (entry && typeof entry === "object" && typeof entry.message === "string") {
|
|
925
|
+
return entry.message;
|
|
926
|
+
}
|
|
927
|
+
return String(entry);
|
|
928
|
+
}).filter(Boolean);
|
|
929
|
+
if (messages.length > 0)
|
|
930
|
+
errors[field] = messages;
|
|
931
|
+
} else if (typeof raw === "string") {
|
|
932
|
+
errors[field] = [raw];
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
if (Object.keys(errors).length > 0)
|
|
936
|
+
parsedErrors = errors;
|
|
937
|
+
}
|
|
938
|
+
return {
|
|
939
|
+
result,
|
|
940
|
+
errorCode: classification.errorCode,
|
|
941
|
+
message,
|
|
942
|
+
retry,
|
|
943
|
+
details,
|
|
944
|
+
...hasContext ? { context } : {},
|
|
945
|
+
...parsedErrors ? { parsedErrors } : {}
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
async function extractErrorMessage(error, options) {
|
|
949
|
+
const { message } = await extractErrorDetails(error, options);
|
|
950
|
+
return message;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
// ../common/src/telemetry/telemetry-dimensions.ts
|
|
954
|
+
var BaseDimensions = {
|
|
955
|
+
ApplicationName: "ApplicationName",
|
|
956
|
+
ProductVersion: "ProductVersion",
|
|
957
|
+
InstallationId: "InstallationId",
|
|
958
|
+
CloudUserId: "CloudUserId",
|
|
959
|
+
CloudTenantId: "CloudTenantId",
|
|
960
|
+
CloudOrganizationId: "CloudOrganizationId",
|
|
961
|
+
IsInternalUser: "IsInternalUser",
|
|
962
|
+
Environment: "Environment",
|
|
963
|
+
BaseUrl: "BaseUrl",
|
|
964
|
+
Region: "Region",
|
|
965
|
+
Agent: "Agent",
|
|
966
|
+
AgentVersion: "AgentVersion",
|
|
967
|
+
AgentModel: "AgentModel",
|
|
968
|
+
ToolName: "ToolName",
|
|
969
|
+
ToolVersion: "ToolVersion",
|
|
970
|
+
ExecutionContext: "ExecutionContext",
|
|
971
|
+
CiProvider: "CiProvider",
|
|
972
|
+
SessionIdSource: "SessionIdSource",
|
|
973
|
+
SessionId: "SessionId"
|
|
974
|
+
};
|
|
975
|
+
var CommandDimensions = {
|
|
976
|
+
IsCommand: "IsCommand",
|
|
977
|
+
IsReexec: "IsReexec",
|
|
978
|
+
CommandName: "CommandName",
|
|
979
|
+
ExitCode: "ExitCode",
|
|
980
|
+
TerminalOutcome: "TerminalOutcome",
|
|
981
|
+
ErrorClass: "ErrorClass",
|
|
982
|
+
TerminalSignal: "TerminalSignal",
|
|
983
|
+
ErrorMessage: "ErrorMessage",
|
|
984
|
+
SkillName: "SkillName",
|
|
985
|
+
ProductArea: "ProductArea",
|
|
986
|
+
Mode: "Mode"
|
|
987
|
+
};
|
|
988
|
+
var ShipDimensions = {
|
|
989
|
+
ShipKind: "ShipKind",
|
|
990
|
+
Target: "Target",
|
|
991
|
+
ProjectType: "ProjectType",
|
|
992
|
+
ProjectTypes: "ProjectTypes",
|
|
993
|
+
ArtifactCorrelationKey: "ArtifactCorrelationKey",
|
|
994
|
+
PackageName: "PackageName",
|
|
995
|
+
PackageVersion: "PackageVersion",
|
|
996
|
+
PackageVersionKey: "PackageVersionKey",
|
|
997
|
+
DeploymentKey: "DeploymentKey",
|
|
998
|
+
SolutionId: "SolutionId",
|
|
999
|
+
FolderKey: "FolderKey",
|
|
1000
|
+
FeedId: "FeedId"
|
|
1001
|
+
};
|
|
1002
|
+
var ErrorDimensions = {
|
|
1003
|
+
Result: "Result",
|
|
1004
|
+
ErrorCode: "ErrorCode",
|
|
1005
|
+
Retry: "Retry",
|
|
1006
|
+
ErrorMessage: "ErrorMessage",
|
|
1007
|
+
HttpStatus: "HttpStatus",
|
|
1008
|
+
UpstreamErrorCode: "UpstreamErrorCode"
|
|
1009
|
+
};
|
|
1010
|
+
var AuthDimensions = {
|
|
1011
|
+
AuthenticationMethod: "AuthenticationMethod",
|
|
1012
|
+
Success: "Success",
|
|
1013
|
+
Reason: "Reason"
|
|
1014
|
+
};
|
|
1015
|
+
var SkillsDimensions = {
|
|
1016
|
+
SchemaVersion: "SchemaVersion",
|
|
1017
|
+
AgentType: "AgentType",
|
|
1018
|
+
SkillsVersion: "SkillsVersion",
|
|
1019
|
+
UipSubcommand: "UipSubcommand",
|
|
1020
|
+
FileExtension: "FileExtension",
|
|
1021
|
+
SubagentModel: "SubagentModel",
|
|
1022
|
+
SubagentType: "SubagentType",
|
|
1023
|
+
PermissionMode: "PermissionMode",
|
|
1024
|
+
EffortLevel: "EffortLevel",
|
|
1025
|
+
SessionSource: "SessionSource",
|
|
1026
|
+
Outcome: "Outcome",
|
|
1027
|
+
DurationMs: "DurationMs",
|
|
1028
|
+
Source: "Source"
|
|
1029
|
+
};
|
|
1030
|
+
var PackagerDimensions = {
|
|
1031
|
+
ProjectId: "ProjectId",
|
|
1032
|
+
ProjectType: "ProjectType",
|
|
1033
|
+
SolutionId: "SolutionId"
|
|
1034
|
+
};
|
|
1035
|
+
var ScopeDimensions = {
|
|
1036
|
+
FolderId: "FolderId"
|
|
1037
|
+
};
|
|
1038
|
+
var ID_DIMENSIONS = new Set([
|
|
1039
|
+
BaseDimensions.CloudUserId,
|
|
1040
|
+
BaseDimensions.CloudTenantId,
|
|
1041
|
+
BaseDimensions.CloudOrganizationId,
|
|
1042
|
+
BaseDimensions.InstallationId,
|
|
1043
|
+
ShipDimensions.ArtifactCorrelationKey,
|
|
1044
|
+
ShipDimensions.PackageVersionKey,
|
|
1045
|
+
ShipDimensions.DeploymentKey,
|
|
1046
|
+
ShipDimensions.SolutionId,
|
|
1047
|
+
ShipDimensions.FolderKey,
|
|
1048
|
+
ShipDimensions.FeedId,
|
|
1049
|
+
PackagerDimensions.ProjectId
|
|
1050
|
+
]);
|
|
1051
|
+
var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
|
|
1052
|
+
var RESERVED_DIMENSION_NAMES = new Set([
|
|
1053
|
+
...Object.values(BaseDimensions),
|
|
1054
|
+
...Object.values(CommandDimensions),
|
|
1055
|
+
...Object.values(ShipDimensions),
|
|
1056
|
+
...Object.values(ErrorDimensions),
|
|
1057
|
+
...Object.values(AuthDimensions),
|
|
1058
|
+
...Object.values(SkillsDimensions),
|
|
1059
|
+
...Object.values(PackagerDimensions),
|
|
1060
|
+
...Object.values(ScopeDimensions)
|
|
1061
|
+
]);
|
|
1062
|
+
var CURATED_DIMENSIONS = new Set([
|
|
1063
|
+
BaseDimensions.ApplicationName,
|
|
1064
|
+
BaseDimensions.ProductVersion,
|
|
1065
|
+
BaseDimensions.InstallationId,
|
|
1066
|
+
BaseDimensions.CloudUserId,
|
|
1067
|
+
BaseDimensions.CloudTenantId,
|
|
1068
|
+
BaseDimensions.CloudOrganizationId,
|
|
1069
|
+
BaseDimensions.IsInternalUser,
|
|
1070
|
+
BaseDimensions.Environment,
|
|
1071
|
+
BaseDimensions.BaseUrl,
|
|
1072
|
+
BaseDimensions.Region,
|
|
1073
|
+
BaseDimensions.Agent,
|
|
1074
|
+
BaseDimensions.AgentVersion,
|
|
1075
|
+
BaseDimensions.ToolVersion,
|
|
1076
|
+
BaseDimensions.ExecutionContext,
|
|
1077
|
+
BaseDimensions.CiProvider,
|
|
1078
|
+
BaseDimensions.SessionIdSource,
|
|
1079
|
+
BaseDimensions.SessionId,
|
|
1080
|
+
...Object.values(CommandDimensions),
|
|
1081
|
+
...Object.values(ShipDimensions)
|
|
1082
|
+
]);
|
|
1083
|
+
function lowercaseIdDimensionValues(properties) {
|
|
1084
|
+
let changed = false;
|
|
1085
|
+
const result = {
|
|
1086
|
+
...properties
|
|
1087
|
+
};
|
|
1088
|
+
for (const key of Object.keys(result)) {
|
|
1089
|
+
const value = result[key];
|
|
1090
|
+
if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
|
|
1091
|
+
continue;
|
|
1092
|
+
}
|
|
1093
|
+
const lowered = value.toLowerCase();
|
|
1094
|
+
if (lowered !== value) {
|
|
1095
|
+
result[key] = lowered;
|
|
1096
|
+
changed = true;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
return changed ? result : properties;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
// ../common/src/telemetry/detect-agent.ts
|
|
1103
|
+
var KNOWN_AGENTS = [
|
|
1104
|
+
{ envVar: "CLAUDECODE", value: "1", id: "claude-code" },
|
|
1105
|
+
{ envVar: "CURSOR_AGENT", value: "1", id: "cursor" },
|
|
1106
|
+
{ envVar: "GEMINI_CLI", value: "1", id: "gemini-cli" },
|
|
1107
|
+
{ envVar: "CODEX_THREAD_ID", id: "codex" },
|
|
1108
|
+
{ envVar: "CODEX_SANDBOX", id: "codex" },
|
|
1109
|
+
{ envVar: "AUGMENT_AGENT", value: "1", id: "augment" },
|
|
1110
|
+
{ envVar: "CLINE_ACTIVE", value: "true", id: "cline" }
|
|
1111
|
+
];
|
|
1112
|
+
function detectAgentFromEnv(env) {
|
|
1113
|
+
for (const agent of KNOWN_AGENTS) {
|
|
1114
|
+
const envValue = env[agent.envVar];
|
|
1115
|
+
if (agent.value !== undefined) {
|
|
1116
|
+
if (envValue === agent.value)
|
|
1117
|
+
return agent.id;
|
|
1118
|
+
} else {
|
|
1119
|
+
if (envValue)
|
|
1120
|
+
return agent.id;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
const agentEnv = env.AGENT;
|
|
1124
|
+
if (agentEnv) {
|
|
1125
|
+
if (agentEnv === "1" || agentEnv === "true")
|
|
1126
|
+
return "unknown";
|
|
1127
|
+
if (agentEnv.length <= 32)
|
|
1128
|
+
return agentEnv.toLowerCase();
|
|
1129
|
+
}
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
// ../common/src/telemetry/execution-context.ts
|
|
1134
|
+
var authSignalSlot = singleton("TelemetryExecutionContextAuthSignal");
|
|
1135
|
+
var isTruthy = (value) => value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
1136
|
+
var isEqual = (value, expected) => value?.toLowerCase() === expected;
|
|
1137
|
+
var CI_SIGNATURES = [
|
|
1138
|
+
{
|
|
1139
|
+
provider: "github_actions",
|
|
1140
|
+
matches: (env) => isTruthy(env.GITHUB_ACTIONS),
|
|
1141
|
+
isScheduler: (env) => env.GITHUB_EVENT_NAME === "schedule"
|
|
1142
|
+
},
|
|
1143
|
+
{
|
|
1144
|
+
provider: "azure_devops",
|
|
1145
|
+
matches: (env) => isTruthy(env.TF_BUILD),
|
|
1146
|
+
isScheduler: (env) => isEqual(env.BUILD_REASON, "schedule")
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
provider: "gitlab",
|
|
1150
|
+
matches: (env) => isTruthy(env.GITLAB_CI),
|
|
1151
|
+
isScheduler: (env) => env.CI_PIPELINE_SOURCE === "schedule"
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
provider: "circleci",
|
|
1155
|
+
matches: (env) => isTruthy(env.CIRCLECI),
|
|
1156
|
+
isScheduler: (env) => env.CIRCLE_PIPELINE_TRIGGER_SOURCE === "scheduled_pipeline"
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
provider: "jenkins",
|
|
1160
|
+
matches: (env) => isTruthy(env.JENKINS_URL) || isTruthy(env.JENKINS_HOME)
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
provider: "teamcity",
|
|
1164
|
+
matches: (env) => isTruthy(env.TEAMCITY_VERSION)
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
provider: "buildkite",
|
|
1168
|
+
matches: (env) => isTruthy(env.BUILDKITE),
|
|
1169
|
+
isScheduler: (env) => env.BUILDKITE_SOURCE === "schedule"
|
|
1170
|
+
},
|
|
1171
|
+
{
|
|
1172
|
+
provider: "bitbucket",
|
|
1173
|
+
matches: (env) => isTruthy(env.BITBUCKET_BUILD_NUMBER)
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
provider: "travis",
|
|
1177
|
+
matches: (env) => isTruthy(env.TRAVIS)
|
|
1178
|
+
},
|
|
1179
|
+
{
|
|
1180
|
+
provider: "appveyor",
|
|
1181
|
+
matches: (env) => isTruthy(env.APPVEYOR)
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
provider: "generic",
|
|
1185
|
+
matches: (env) => isTruthy(env.CI)
|
|
1186
|
+
}
|
|
1187
|
+
];
|
|
1188
|
+
function currentEnv() {
|
|
1189
|
+
return typeof process === "undefined" ? {} : process.env;
|
|
1190
|
+
}
|
|
1191
|
+
function currentTtyState() {
|
|
1192
|
+
if (typeof process === "undefined")
|
|
1193
|
+
return false;
|
|
1194
|
+
return Boolean(process.stdout?.isTTY || process.stdin?.isTTY || process.stderr?.isTTY);
|
|
1195
|
+
}
|
|
1196
|
+
function detectCi(env) {
|
|
1197
|
+
const signature = CI_SIGNATURES.find((candidate) => candidate.matches(env));
|
|
1198
|
+
if (!signature)
|
|
1199
|
+
return;
|
|
1200
|
+
return {
|
|
1201
|
+
executionContext: signature.isScheduler?.(env) ? "scheduler" : "ci",
|
|
1202
|
+
ciProvider: signature.provider
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
function detectExecutionContext(options = {}) {
|
|
1206
|
+
const env = options.env ?? currentEnv();
|
|
1207
|
+
const ci = detectCi(env);
|
|
1208
|
+
if (ci)
|
|
1209
|
+
return ci;
|
|
1210
|
+
const agent = options.agent ?? detectAgentFromEnv(env);
|
|
1211
|
+
if (agent) {
|
|
1212
|
+
return { executionContext: "agent" };
|
|
1213
|
+
}
|
|
1214
|
+
const authSignal = options.authSignal ?? authSignalSlot.get();
|
|
1215
|
+
if (authSignal === "service_account") {
|
|
1216
|
+
return { executionContext: "service_account" };
|
|
1217
|
+
}
|
|
1218
|
+
const isTty = options.isTty ?? currentTtyState();
|
|
1219
|
+
if (isTty) {
|
|
1220
|
+
return { executionContext: "manual" };
|
|
1221
|
+
}
|
|
1222
|
+
return { executionContext: "unknown" };
|
|
1223
|
+
}
|
|
1224
|
+
function getExecutionContextTelemetryProperties() {
|
|
1225
|
+
const detected = detectExecutionContext();
|
|
1226
|
+
return {
|
|
1227
|
+
[BaseDimensions.ExecutionContext]: detected.executionContext,
|
|
1228
|
+
...detected.ciProvider ? { [BaseDimensions.CiProvider]: detected.ciProvider } : {}
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
// ../common/src/telemetry/global-telemetry-properties.ts
|
|
1233
|
+
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
1234
|
+
function getGlobalTelemetryProperties() {
|
|
1235
|
+
return telemetryPropsSlot.get();
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
// ../common/src/telemetry/trace-context.ts
|
|
1239
|
+
var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
|
|
1240
|
+
var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
|
|
1241
|
+
function getProcessEnv() {
|
|
1242
|
+
return globalThis.process?.env;
|
|
1243
|
+
}
|
|
1244
|
+
function parseInboundTraceparent(value) {
|
|
1245
|
+
if (!value) {
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
|
|
1249
|
+
if (!match) {
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
const [, traceId, parentSpanId] = match;
|
|
1253
|
+
if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
return { traceId, parentSpanId };
|
|
1257
|
+
}
|
|
1258
|
+
function getInboundTraceContext() {
|
|
1259
|
+
return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
// ../common/src/telemetry/session-id.ts
|
|
1263
|
+
var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
1264
|
+
var SESSION_ID_MAX_LENGTH = 64;
|
|
1265
|
+
var RANDOM_SESSION_ID_LENGTH = 32;
|
|
1266
|
+
var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
|
|
1267
|
+
var CONTROL_CHARACTERS = /\p{Cc}/gu;
|
|
1268
|
+
var INHERITED_SESSION_SOURCES = [
|
|
1269
|
+
{ envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
|
|
1270
|
+
{ envVar: "CODEX_THREAD_ID", source: "codex" },
|
|
1271
|
+
{ envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
|
|
1272
|
+
{ envVar: "TERM_SESSION_ID", source: "terminal" },
|
|
1273
|
+
{ envVar: "WT_SESSION", source: "terminal" }
|
|
1274
|
+
];
|
|
1275
|
+
var telemetrySessionSlot = singleton("TelemetrySession");
|
|
1276
|
+
var telemetryOperationIdSlot = singleton("TelemetryOperationId");
|
|
1277
|
+
function getProcessEnv2() {
|
|
1278
|
+
return globalThis.process?.env;
|
|
1279
|
+
}
|
|
1280
|
+
function normalizeSessionId(value) {
|
|
1281
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
|
|
1285
|
+
return cleaned || undefined;
|
|
1286
|
+
}
|
|
1287
|
+
function getConfiguredTelemetrySessionId() {
|
|
1288
|
+
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
1289
|
+
}
|
|
1290
|
+
function getInheritedSession(env) {
|
|
1291
|
+
for (const candidate of INHERITED_SESSION_SOURCES) {
|
|
1292
|
+
const handle = normalizeSessionId(env[candidate.envVar]);
|
|
1293
|
+
if (handle) {
|
|
1294
|
+
return { id: handle, source: candidate.source };
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
function generateRandomSession() {
|
|
1300
|
+
const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
|
|
1301
|
+
crypto.getRandomValues(bytes);
|
|
1302
|
+
let hex = "";
|
|
1303
|
+
for (const byte of bytes) {
|
|
1304
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
1305
|
+
}
|
|
1306
|
+
return { id: hex, source: "random" };
|
|
1307
|
+
}
|
|
1308
|
+
function resolveTelemetrySession() {
|
|
1309
|
+
const existing = telemetrySessionSlot.get();
|
|
1310
|
+
if (existing) {
|
|
1311
|
+
return existing;
|
|
1312
|
+
}
|
|
1313
|
+
const declaredHandle = getConfiguredTelemetrySessionId();
|
|
1314
|
+
const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
|
|
1315
|
+
telemetrySessionSlot.set(resolved);
|
|
1316
|
+
return resolved;
|
|
1317
|
+
}
|
|
1318
|
+
function getTelemetrySessionId() {
|
|
1319
|
+
return resolveTelemetrySession().id;
|
|
1320
|
+
}
|
|
1321
|
+
function getTelemetrySessionSource() {
|
|
1322
|
+
return resolveTelemetrySession().source;
|
|
1323
|
+
}
|
|
1324
|
+
function getTelemetryOperationId() {
|
|
1325
|
+
const existing = telemetryOperationIdSlot.get();
|
|
1326
|
+
if (existing) {
|
|
1327
|
+
return existing;
|
|
1328
|
+
}
|
|
1329
|
+
const inboundTraceId = getInboundTraceContext()?.traceId;
|
|
1330
|
+
const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
|
|
1331
|
+
telemetryOperationIdSlot.set(generated);
|
|
1332
|
+
return generated;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
// ../common/src/telemetry/span-clock.ts
|
|
1336
|
+
function startSpanClock() {
|
|
1337
|
+
const started = performance.now();
|
|
1338
|
+
return {
|
|
1339
|
+
startedAt: new Date(performance.timeOrigin + started),
|
|
1340
|
+
elapsedMs: () => performance.now() - started
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
// ../common/src/telemetry/telemetry-service.ts
|
|
1345
|
+
class TelemetryService {
|
|
1346
|
+
telemetryProvider;
|
|
1347
|
+
contextStorage;
|
|
1348
|
+
operationId;
|
|
1349
|
+
defaultProperties;
|
|
1350
|
+
constructor(telemetryProvider, contextStorage) {
|
|
1351
|
+
this.telemetryProvider = telemetryProvider;
|
|
1352
|
+
this.contextStorage = contextStorage;
|
|
1353
|
+
}
|
|
1354
|
+
setOperationId(operationId) {
|
|
1355
|
+
this.operationId = operationId;
|
|
1356
|
+
}
|
|
1357
|
+
setProvider(provider) {
|
|
1358
|
+
this.telemetryProvider = provider;
|
|
1359
|
+
}
|
|
1360
|
+
setDefaultProperties(properties) {
|
|
1361
|
+
this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
|
|
1362
|
+
}
|
|
1363
|
+
trackEvent(name, properties) {
|
|
1364
|
+
this.telemetryProvider.trackEvent({
|
|
1365
|
+
name: redactSpanName(name),
|
|
1366
|
+
properties: this.enrichProperties(properties),
|
|
1367
|
+
...this.leafCorrelation()
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
trackException(error, properties, context) {
|
|
1371
|
+
this.telemetryProvider.trackException({
|
|
1372
|
+
error: redactError(error),
|
|
1373
|
+
properties: this.enrichProperties(properties),
|
|
1374
|
+
...this.leafCorrelation(context)
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
async trackRequest(name, fn, properties) {
|
|
1378
|
+
const parentContext = this.getActiveContext();
|
|
1379
|
+
const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
|
|
1380
|
+
const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
|
|
1381
|
+
const clock = startSpanClock();
|
|
1382
|
+
const context = {
|
|
1383
|
+
operationId,
|
|
1384
|
+
...parentId !== undefined ? { parentId } : {},
|
|
1385
|
+
id: this.generateId(),
|
|
1386
|
+
startedAt: clock.startedAt
|
|
1387
|
+
};
|
|
1388
|
+
try {
|
|
1389
|
+
const result = await this.contextStorage.run(context, fn);
|
|
1390
|
+
const durationMs = clock.elapsedMs();
|
|
1391
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, true, properties, context));
|
|
1392
|
+
return result;
|
|
1393
|
+
} catch (error) {
|
|
1394
|
+
const durationMs = clock.elapsedMs();
|
|
1395
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
1396
|
+
await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, {
|
|
1397
|
+
...properties,
|
|
1398
|
+
[CommandDimensions.ErrorMessage]: err.message
|
|
1399
|
+
}, context));
|
|
1400
|
+
throw error;
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
trackRequestResult(name, durationMs, success, properties, context) {
|
|
1404
|
+
const requestContext = context ?? {
|
|
1405
|
+
operationId: this.operationId ?? getTelemetryOperationId(),
|
|
1406
|
+
id: this.generateId()
|
|
1407
|
+
};
|
|
1408
|
+
this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, success, properties, requestContext));
|
|
1409
|
+
}
|
|
1410
|
+
createRequestContext() {
|
|
1411
|
+
const operationId = this.operationId ?? getTelemetryOperationId();
|
|
1412
|
+
const parentId = this.inboundParentIdFor(operationId);
|
|
1413
|
+
return {
|
|
1414
|
+
operationId,
|
|
1415
|
+
...parentId !== undefined ? { parentId } : {},
|
|
1416
|
+
id: this.generateId(),
|
|
1417
|
+
startedAt: startSpanClock().startedAt
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
inboundParentIdFor(operationId) {
|
|
1421
|
+
const inbound = getInboundTraceContext();
|
|
1422
|
+
return inbound && inbound.traceId === operationId ? inbound.parentSpanId : undefined;
|
|
1423
|
+
}
|
|
1424
|
+
runWithContext(context, fn) {
|
|
1425
|
+
return this.contextStorage.run(context, fn);
|
|
1426
|
+
}
|
|
1427
|
+
createDependencyContext() {
|
|
1428
|
+
const parentContext = this.getActiveContext();
|
|
1429
|
+
if (!parentContext) {
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
return {
|
|
1433
|
+
operationId: parentContext.operationId,
|
|
1434
|
+
parentId: parentContext.id,
|
|
1435
|
+
id: this.generateId(),
|
|
1436
|
+
startedAt: startSpanClock().startedAt
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
trackDependencyResult(name, type, durationMs, success, properties, context, resultCode) {
|
|
1440
|
+
this.telemetryProvider.trackDependency({
|
|
1441
|
+
...this.spanFor(redactHttpDependencyName(name), durationMs, success, properties, context),
|
|
1442
|
+
type,
|
|
1443
|
+
...resultCode !== undefined ? { resultCode } : {}
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
async trackDependencyOperation(name, type, fn, properties) {
|
|
1447
|
+
const clock = startSpanClock();
|
|
1448
|
+
const parentContext = this.getActiveContext();
|
|
1449
|
+
const childContext = parentContext !== undefined ? {
|
|
1450
|
+
operationId: parentContext.operationId,
|
|
1451
|
+
parentId: parentContext.id,
|
|
1452
|
+
id: this.generateId(),
|
|
1453
|
+
startedAt: clock.startedAt
|
|
1454
|
+
} : {
|
|
1455
|
+
...this.createRequestContext(),
|
|
1456
|
+
startedAt: clock.startedAt
|
|
1457
|
+
};
|
|
1458
|
+
try {
|
|
1459
|
+
const result = await this.contextStorage.run(childContext, fn);
|
|
1460
|
+
const durationMs = clock.elapsedMs();
|
|
1461
|
+
await this.telemetryProvider.trackDependency({
|
|
1462
|
+
...this.spanFor(name, durationMs, true, properties, childContext),
|
|
1463
|
+
type
|
|
1464
|
+
});
|
|
1465
|
+
return result;
|
|
1466
|
+
} catch (error) {
|
|
1467
|
+
const durationMs = clock.elapsedMs();
|
|
1468
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
1469
|
+
await this.telemetryProvider.trackDependency({
|
|
1470
|
+
...this.spanFor(name, durationMs, false, {
|
|
1471
|
+
...properties,
|
|
1472
|
+
[CommandDimensions.ErrorMessage]: err.message
|
|
1473
|
+
}, childContext),
|
|
1474
|
+
type
|
|
1475
|
+
});
|
|
1476
|
+
throw error;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
getActiveContext() {
|
|
1480
|
+
return this.contextStorage.getContext();
|
|
1481
|
+
}
|
|
1482
|
+
leafCorrelation(explicit) {
|
|
1483
|
+
const context = explicit ?? this.getActiveContext();
|
|
1484
|
+
return {
|
|
1485
|
+
operationId: context?.operationId ?? this.operationId ?? getTelemetryOperationId(),
|
|
1486
|
+
...context !== undefined ? { parentId: context.id } : {}
|
|
1487
|
+
};
|
|
1488
|
+
}
|
|
1489
|
+
spanFor(name, durationMs, success, properties, context) {
|
|
1490
|
+
return {
|
|
1491
|
+
name: redactSpanName(name),
|
|
1492
|
+
durationMs,
|
|
1493
|
+
success,
|
|
1494
|
+
properties: this.enrichProperties(properties),
|
|
1495
|
+
operationId: context.operationId,
|
|
1496
|
+
...context.parentId !== undefined ? { parentId: context.parentId } : {},
|
|
1497
|
+
id: context.id,
|
|
1498
|
+
...context.startedAt !== undefined ? { startedAt: context.startedAt } : {}
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1501
|
+
enrichProperties(properties) {
|
|
1502
|
+
const globalProperties = getGlobalTelemetryProperties();
|
|
1503
|
+
const enriched = {
|
|
1504
|
+
...getExecutionContextTelemetryProperties(),
|
|
1505
|
+
...globalProperties,
|
|
1506
|
+
...this.defaultProperties,
|
|
1507
|
+
...redactProperties(properties ?? {}),
|
|
1508
|
+
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
|
|
1509
|
+
[BaseDimensions.SessionId]: this.telemetryProvider.getSessionId?.() ?? getTelemetrySessionId()
|
|
1510
|
+
};
|
|
1511
|
+
return lowercaseIdDimensionValues(enriched);
|
|
1512
|
+
}
|
|
1513
|
+
generateId() {
|
|
1514
|
+
const bytes = new Uint8Array(8);
|
|
1515
|
+
let hex = "";
|
|
1516
|
+
do {
|
|
1517
|
+
crypto.getRandomValues(bytes);
|
|
1518
|
+
hex = "";
|
|
1519
|
+
for (const byte of bytes) {
|
|
1520
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
1521
|
+
}
|
|
1522
|
+
} while (/^0+$/.test(hex));
|
|
1523
|
+
return hex;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
// ../common/src/telemetry/console-telemetry-provider.ts
|
|
1528
|
+
class ConsoleTelemetryProvider {
|
|
1529
|
+
async trackEvent({ name }) {
|
|
1530
|
+
console.debug(`[Telemetry] Event: ${name}`);
|
|
1531
|
+
}
|
|
1532
|
+
async trackException({ error }) {
|
|
1533
|
+
console.error(`[Telemetry] Exception: ${error.message}`);
|
|
1534
|
+
}
|
|
1535
|
+
async trackRequest({
|
|
1536
|
+
name,
|
|
1537
|
+
durationMs,
|
|
1538
|
+
success
|
|
1539
|
+
}) {
|
|
1540
|
+
console.debug(`[Telemetry] Request: ${name} (${durationMs}ms, ${success ? "ok" : "fail"})`);
|
|
1541
|
+
}
|
|
1542
|
+
async trackDependency({
|
|
1543
|
+
name,
|
|
1544
|
+
type,
|
|
1545
|
+
durationMs,
|
|
1546
|
+
success
|
|
1547
|
+
}) {
|
|
1548
|
+
console.debug(`[Telemetry] Dependency: ${name} [${type}] (${durationMs}ms, ${success ? "ok" : "fail"})`);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// ../common/src/telemetry/environment-info.ts
|
|
1553
|
+
var LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
1554
|
+
|
|
1555
|
+
// ../common/src/telemetry/command-attribution.ts
|
|
1556
|
+
var LEGACY_SKILL_NAMESPACE = "uipath:";
|
|
1557
|
+
var MAX_SKILL_NAME_LENGTH = 80;
|
|
1558
|
+
var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
|
|
1559
|
+
function productMode(productArea, mode) {
|
|
1560
|
+
return { ProductArea: productArea, Mode: mode };
|
|
1561
|
+
}
|
|
1562
|
+
function attributionRecord(groups) {
|
|
1563
|
+
const record = {};
|
|
1564
|
+
for (const [productArea, mode, names] of groups) {
|
|
1565
|
+
const attribution = productMode(productArea, mode);
|
|
1566
|
+
for (const name of names) {
|
|
1567
|
+
record[name] = attribution;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
return record;
|
|
1571
|
+
}
|
|
1572
|
+
function commandAttribution(groups) {
|
|
1573
|
+
const entries = [];
|
|
1574
|
+
for (const [productArea, mode, prefixes] of groups) {
|
|
1575
|
+
const attribution = productMode(productArea, mode);
|
|
1576
|
+
for (const prefix of prefixes) {
|
|
1577
|
+
entries.push({ prefix, attribution });
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
return entries;
|
|
1581
|
+
}
|
|
1582
|
+
var SKILL_ATTRIBUTION = attributionRecord([
|
|
1583
|
+
["admin", "operate", ["uipath-admin"]],
|
|
1584
|
+
["agents", "build", ["uipath-agents"]],
|
|
1585
|
+
["api-workflow", "build", ["uipath-api-workflow"]],
|
|
1586
|
+
["automation-discovery", "build", ["uipath-automation-discovery"]],
|
|
1587
|
+
["coded-apps", "build", ["uipath-coded-apps"]],
|
|
1588
|
+
["data-fabric", "operate", ["uipath-data-fabric"]],
|
|
1589
|
+
["cli", "troubleshoot", ["uipath-feedback"]],
|
|
1590
|
+
["governance", "operate", ["uipath-governance"]],
|
|
1591
|
+
["action-center", "build", ["uipath-human-in-the-loop"]],
|
|
1592
|
+
["document-understanding", "build", ["uipath-ixp"]],
|
|
1593
|
+
[
|
|
1594
|
+
"maestro",
|
|
1595
|
+
"build",
|
|
1596
|
+
["uipath-maestro-bpmn", "uipath-maestro-case", "uipath-maestro-flow"]
|
|
1597
|
+
],
|
|
1598
|
+
["agenthub", "build", ["uipath-mcp-servers"]],
|
|
1599
|
+
["solution", "build", ["uipath-planner", "uipath-solution"]],
|
|
1600
|
+
["platform", "operate", ["uipath-platform"]],
|
|
1601
|
+
["quality", "troubleshoot", ["uipath-review"]],
|
|
1602
|
+
["rpa", "build", ["uipath-rpa"]],
|
|
1603
|
+
["business-rules", "build", ["uipath-rules"]],
|
|
1604
|
+
["cli", "operate", ["uipath-skill-catalog"]],
|
|
1605
|
+
["action-center", "operate", ["uipath-tasks"]],
|
|
1606
|
+
["test-manager", "operate", ["uipath-test"]],
|
|
1607
|
+
["platform", "troubleshoot", ["uipath-troubleshoot"]]
|
|
1608
|
+
]);
|
|
1609
|
+
var KNOWN_SKILL_NAMES = new Set(Object.keys(SKILL_ATTRIBUTION));
|
|
1610
|
+
var COMMAND_ATTRIBUTION = commandAttribution([
|
|
1611
|
+
["cli", "troubleshoot", ["uip.feedback"]],
|
|
1612
|
+
["llm-gateway", "operate", ["uip.llm-gateway"]],
|
|
1613
|
+
["llm-gateway", "operate", ["uip.llm-configuration", "uip.model-hub"]],
|
|
1614
|
+
["context-grounding", "build", ["uip.context-grounding"]],
|
|
1615
|
+
["api-workflow", "build", ["uip.api-workflow"]],
|
|
1616
|
+
["rpa", "build", ["uip.rpa-legacy"]],
|
|
1617
|
+
["conversational", "operate", ["uip.conversational"]],
|
|
1618
|
+
["agents", "build", ["uip.codedagent", "uip.agent"]],
|
|
1619
|
+
["coding-agents", "build", ["uip.coder"]],
|
|
1620
|
+
["agenthub", "build", ["uip.agenthub"]],
|
|
1621
|
+
["coded-apps", "build", ["uip.codedapp"]],
|
|
1622
|
+
["functions", "build", ["uip.function", "uip.functions"]],
|
|
1623
|
+
["solution", "build", ["uip.solution"]],
|
|
1624
|
+
["business-rules", "build", ["uip.rules"]],
|
|
1625
|
+
["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
|
|
1626
|
+
["llm-observability", "troubleshoot", ["uip.traces"]],
|
|
1627
|
+
["platform", "operate", ["uip.platform"]],
|
|
1628
|
+
["admin", "operate", ["uip.admin"]],
|
|
1629
|
+
["automation-ops", "operate", ["uip.aops"]],
|
|
1630
|
+
["documentation", "troubleshoot", ["uip.docsai"]],
|
|
1631
|
+
["governance", "operate", ["uip.gov"]],
|
|
1632
|
+
["insights", "operate", ["uip.insights"]],
|
|
1633
|
+
["document-understanding", "build", ["uip.ixp"]],
|
|
1634
|
+
["process-mining", "operate", ["uip.pm"]],
|
|
1635
|
+
["action-center", "operate", ["uip.tasks"]],
|
|
1636
|
+
["test-manager", "operate", ["uip.tm"]],
|
|
1637
|
+
["vertical-solutions", "build", ["uip.vss"]],
|
|
1638
|
+
["data-fabric", "operate", ["uip.df"]],
|
|
1639
|
+
["integration-service", "build", ["uip.is"]],
|
|
1640
|
+
["orchestrator", "operate", ["uip.or"]],
|
|
1641
|
+
[
|
|
1642
|
+
"cli",
|
|
1643
|
+
"operate",
|
|
1644
|
+
[
|
|
1645
|
+
"uip.login",
|
|
1646
|
+
"uip.logout",
|
|
1647
|
+
"uip.user",
|
|
1648
|
+
"uip.config",
|
|
1649
|
+
"uip.tools",
|
|
1650
|
+
"uip.skills",
|
|
1651
|
+
"uip.completion",
|
|
1652
|
+
"uip.update",
|
|
1653
|
+
"uip.mcp",
|
|
1654
|
+
"uip.track"
|
|
1655
|
+
]
|
|
1656
|
+
]
|
|
1657
|
+
]).sort((a, b) => b.prefix.length - a.prefix.length);
|
|
1658
|
+
function normalizeCommandPath(value) {
|
|
1659
|
+
if (typeof value !== "string") {
|
|
1660
|
+
return;
|
|
1661
|
+
}
|
|
1662
|
+
const trimmed = value.trim().toLowerCase();
|
|
1663
|
+
if (!trimmed) {
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
const tokens = trimmed.includes(" ") ? trimmed.split(/\s+/).filter((token) => token.length > 0).filter((token) => !token.startsWith("-")) : trimmed.split(".").filter((token) => token.length > 0);
|
|
1667
|
+
if (tokens.length === 0) {
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
const commandTokens = tokens[0] === "uip" ? tokens : ["uip", ...tokens];
|
|
1671
|
+
return commandTokens.join(".");
|
|
1672
|
+
}
|
|
1673
|
+
function getCommandProductModeAttribution(commandPath) {
|
|
1674
|
+
const normalized = normalizeCommandPath(commandPath);
|
|
1675
|
+
if (!normalized) {
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1678
|
+
return COMMAND_ATTRIBUTION.find(({ prefix }) => normalized === prefix || normalized.startsWith(`${prefix}.`))?.attribution;
|
|
1679
|
+
}
|
|
1680
|
+
function normalizeSkillNameWithOptions(value, options) {
|
|
1681
|
+
if (typeof value !== "string") {
|
|
1682
|
+
return;
|
|
1683
|
+
}
|
|
1684
|
+
const normalized = value.trim().toLowerCase();
|
|
1685
|
+
if (!normalized) {
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
const hasLegacyNamespace = normalized.startsWith(LEGACY_SKILL_NAMESPACE);
|
|
1689
|
+
if (hasLegacyNamespace && !options.allowLegacyNamespace) {
|
|
1690
|
+
return;
|
|
1691
|
+
}
|
|
1692
|
+
const skillName = hasLegacyNamespace ? normalized.slice(LEGACY_SKILL_NAMESPACE.length) : normalized;
|
|
1693
|
+
if (skillName.length > MAX_SKILL_NAME_LENGTH || !SKILL_NAME_PATTERN.test(skillName) || !KNOWN_SKILL_NAMES.has(skillName)) {
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
return skillName;
|
|
1697
|
+
}
|
|
1698
|
+
function normalizeSkillName(value) {
|
|
1699
|
+
return normalizeSkillNameWithOptions(value, {
|
|
1700
|
+
allowLegacyNamespace: false
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
function buildCommandTelemetryAttribution(commandPath, skillSource) {
|
|
1704
|
+
const skillName = normalizeSkillName(skillSource);
|
|
1705
|
+
return {
|
|
1706
|
+
...skillName ? { SkillName: skillName } : {},
|
|
1707
|
+
...getCommandProductModeAttribution(commandPath)
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
var AGENT_SESSION_ENV = {
|
|
1711
|
+
[BaseDimensions.AgentModel]: "UIPATH_AGENT_MODEL",
|
|
1712
|
+
[SkillsDimensions.PermissionMode]: "UIPATH_PERMISSION_MODE",
|
|
1713
|
+
[SkillsDimensions.EffortLevel]: "UIPATH_EFFORT_LEVEL",
|
|
1714
|
+
[SkillsDimensions.SkillsVersion]: "UIPATH_SKILLS_VERSION"
|
|
1715
|
+
};
|
|
1716
|
+
var MAX_TELEMETRY_TOKEN_LENGTH = 120;
|
|
1717
|
+
function sanitizeTelemetryToken(value) {
|
|
1718
|
+
return value.replace(/[^A-Za-z0-9:._/ -]/g, "_").slice(0, MAX_TELEMETRY_TOKEN_LENGTH);
|
|
1719
|
+
}
|
|
1720
|
+
function buildAgentSessionTelemetry(env) {
|
|
1721
|
+
const dimensions = {};
|
|
1722
|
+
for (const [key, variable] of Object.entries(AGENT_SESSION_ENV)) {
|
|
1723
|
+
const value = env[variable]?.trim();
|
|
1724
|
+
if (value) {
|
|
1725
|
+
dimensions[key] = sanitizeTelemetryToken(value);
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
return dimensions;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
// ../common/src/sdk-user-agent.ts
|
|
1732
|
+
var USER_AGENT_HEADER = "User-Agent";
|
|
1733
|
+
var AGENT_PROPERTY = BaseDimensions.Agent;
|
|
1734
|
+
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
1735
|
+
function userAgentPatchKey(userAgent) {
|
|
1736
|
+
return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
|
|
1737
|
+
}
|
|
1738
|
+
function splitUserAgentTokens(value) {
|
|
1739
|
+
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
1740
|
+
}
|
|
1741
|
+
function appendUserAgentToken(value, userAgent) {
|
|
1742
|
+
const tokens = splitUserAgentTokens(value);
|
|
1743
|
+
const seen = new Set(tokens);
|
|
1744
|
+
for (const token of splitUserAgentTokens(userAgent)) {
|
|
1745
|
+
if (!seen.has(token)) {
|
|
1746
|
+
tokens.push(token);
|
|
1747
|
+
seen.add(token);
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
return tokens.join(" ");
|
|
1751
|
+
}
|
|
1752
|
+
function getEffectiveUserAgent(userAgent) {
|
|
1753
|
+
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
1754
|
+
}
|
|
1755
|
+
function getHeaderName(headers, headerName) {
|
|
1756
|
+
return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
|
|
1757
|
+
}
|
|
1758
|
+
function getSdkUserAgentToken(pkg) {
|
|
1759
|
+
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
1760
|
+
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
1761
|
+
}
|
|
1762
|
+
function addSdkUserAgentHeader(headers, userAgent) {
|
|
1763
|
+
const result = { ...headers ?? {} };
|
|
1764
|
+
const headerName = getHeaderName(result, USER_AGENT_HEADER);
|
|
1765
|
+
result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
|
|
1766
|
+
return result;
|
|
1767
|
+
}
|
|
1768
|
+
function asHeaderRecord(headers) {
|
|
1769
|
+
return typeof headers === "object" && headers !== null ? { ...headers } : {};
|
|
1770
|
+
}
|
|
1771
|
+
function withForwardedHeadersInitOverride(initOverrides, forward) {
|
|
1772
|
+
return async (requestContext) => {
|
|
1773
|
+
const initWithHeaders = {
|
|
1774
|
+
...requestContext.init,
|
|
1775
|
+
headers: forward(asHeaderRecord(requestContext.init.headers))
|
|
1776
|
+
};
|
|
1777
|
+
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
1778
|
+
...requestContext,
|
|
1779
|
+
init: initWithHeaders
|
|
1780
|
+
}) : initOverrides;
|
|
1781
|
+
return {
|
|
1782
|
+
...override ?? {},
|
|
1783
|
+
headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
|
|
1784
|
+
};
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
|
|
1788
|
+
const prototype = BaseApiClass.prototype;
|
|
1789
|
+
if (prototype[patchKey]) {
|
|
1790
|
+
return;
|
|
1791
|
+
}
|
|
1792
|
+
if (typeof prototype.request !== "function") {
|
|
1793
|
+
throw new Error("Generated BaseAPI request function not found.");
|
|
1794
|
+
}
|
|
1795
|
+
const originalRequest = prototype.request;
|
|
1796
|
+
prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
|
|
1797
|
+
return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
|
|
1798
|
+
};
|
|
1799
|
+
Object.defineProperty(prototype, patchKey, {
|
|
1800
|
+
value: true
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
1804
|
+
installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
export { pseudonymize, singleton, recordSuppliedArgumentValues, releaseSuppliedArgumentValues, redactProperties, catchError, walkErrorGraph, findHttpStatusInGraph, LOCAL_PERMISSION_ERROR_CODES, carriedInstructions, extractErrorDetails, extractErrorMessage, CommandDimensions, ShipDimensions, ErrorDimensions, PackagerDimensions, TelemetryService, buildCommandTelemetryAttribution, buildAgentSessionTelemetry, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, ConsoleTelemetryProvider };
|
|
1808
|
+
|
|
1809
|
+
//# debugId=171078CE229ED45A64756E2164756E21
|