@uipath/solution-tool 1.199.0-preview.92 → 1.199.0-preview.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/deploy.js CHANGED
@@ -34309,11 +34309,36 @@ class NodeContextStorage {
34309
34309
  return this.storage.getStore();
34310
34310
  }
34311
34311
  }
34312
+ // ../common/src/telemetry/trace-context.ts
34313
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
34314
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
34315
+ function getProcessEnv() {
34316
+ return globalThis.process?.env;
34317
+ }
34318
+ function parseInboundTraceparent(value) {
34319
+ if (!value) {
34320
+ return;
34321
+ }
34322
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
34323
+ if (!match) {
34324
+ return;
34325
+ }
34326
+ const [, traceId, parentSpanId] = match;
34327
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
34328
+ return;
34329
+ }
34330
+ return { traceId, parentSpanId };
34331
+ }
34332
+ function getInboundTraceContext() {
34333
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
34334
+ }
34335
+
34312
34336
  // ../common/src/telemetry/session-id.ts
34313
34337
  var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
34314
34338
  var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
34315
34339
  var telemetrySessionIdSlot = singleton("TelemetrySessionId");
34316
- function getProcessEnv() {
34340
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
34341
+ function getProcessEnv2() {
34317
34342
  return globalThis.process?.env;
34318
34343
  }
34319
34344
  function normalizeSessionId(value) {
@@ -34324,18 +34349,165 @@ function normalizeSessionId(value) {
34324
34349
  return trimmed || undefined;
34325
34350
  }
34326
34351
  function getConfiguredTelemetrySessionId() {
34327
- return normalizeSessionId(getProcessEnv()?.[TELEMETRY_SESSION_ID_ENV]);
34352
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
34328
34353
  }
34329
34354
  function resolveTelemetrySessionId(existingSessionId) {
34330
34355
  return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
34331
34356
  }
34357
+ function getTelemetryOperationId() {
34358
+ const existing = telemetryOperationIdSlot.get();
34359
+ if (existing) {
34360
+ return existing;
34361
+ }
34362
+ const inboundTraceId = getInboundTraceContext()?.traceId;
34363
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
34364
+ telemetryOperationIdSlot.set(generated);
34365
+ return generated;
34366
+ }
34332
34367
  // ../common/src/telemetry/global-telemetry-properties.ts
34333
34368
  var telemetryPropsSlot = singleton("TelemetryDefaultProps");
34334
34369
  function getGlobalTelemetryProperties() {
34335
34370
  return telemetryPropsSlot.get();
34336
34371
  }
34337
34372
 
34373
+ // ../common/src/telemetry/pii-redactor.ts
34374
+ var REDACTED = "[REDACTED]";
34375
+ var MAX_VALUE_LENGTH = 200;
34376
+ var SENSITIVE_NAME_TOKENS = new Set([
34377
+ "token",
34378
+ "tokens",
34379
+ "secret",
34380
+ "secrets",
34381
+ "password",
34382
+ "passwords",
34383
+ "pwd",
34384
+ "credential",
34385
+ "credentials",
34386
+ "auth",
34387
+ "authentication",
34388
+ "authorization",
34389
+ "authority",
34390
+ "cert",
34391
+ "certificate",
34392
+ "certificates"
34393
+ ]);
34394
+ var SENSITIVE_KEY_PREFIXES = new Set([
34395
+ "api",
34396
+ "access",
34397
+ "client",
34398
+ "private",
34399
+ "public",
34400
+ "signing",
34401
+ "encryption",
34402
+ "session",
34403
+ "master",
34404
+ "shared",
34405
+ "root",
34406
+ "ssh",
34407
+ "rsa",
34408
+ "aes",
34409
+ "hmac",
34410
+ "oauth"
34411
+ ]);
34412
+ 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;
34413
+ var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
34414
+ var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
34415
+ var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
34416
+ var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
34417
+ var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
34418
+ var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
34419
+ function shortHash(input) {
34420
+ let hash = 2166136261;
34421
+ for (let i = 0;i < input.length; i++) {
34422
+ hash ^= input.charCodeAt(i);
34423
+ hash = Math.imul(hash, 16777619);
34424
+ }
34425
+ return (hash >>> 0).toString(16).padStart(8, "0");
34426
+ }
34427
+ function redactUrl(raw) {
34428
+ try {
34429
+ const url = new URL(raw);
34430
+ return `${url.protocol}//${url.host}`;
34431
+ } catch {
34432
+ return `url#${shortHash(raw)}`;
34433
+ }
34434
+ }
34435
+ function redactValueDetectors(value) {
34436
+ let out = value;
34437
+ out = out.replace(JWT_PATTERN, () => REDACTED);
34438
+ out = out.replace(URL_PATTERN, (match) => {
34439
+ const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
34440
+ const core2 = trailing ? match.slice(0, -trailing.length) : match;
34441
+ return `${redactUrl(core2)}${trailing}`;
34442
+ });
34443
+ out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
34444
+ out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
34445
+ out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
34446
+ out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
34447
+ if (out.length > MAX_VALUE_LENGTH) {
34448
+ out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
34449
+ }
34450
+ return out;
34451
+ }
34452
+ function redactValue(value) {
34453
+ return redactValueDetectors(value);
34454
+ }
34455
+ function redactError(error) {
34456
+ const safe = new Error(redactValueDetectors(error.message ?? ""));
34457
+ safe.name = error.name;
34458
+ safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
34459
+ return safe;
34460
+ }
34461
+ function nameTokens(name) {
34462
+ 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);
34463
+ }
34464
+ function isSensitiveName(name) {
34465
+ const tokens = nameTokens(name);
34466
+ for (let i = 0;i < tokens.length; i++) {
34467
+ const token = tokens[i];
34468
+ if (SENSITIVE_NAME_TOKENS.has(token)) {
34469
+ return true;
34470
+ }
34471
+ if (token === "key" || token === "keys") {
34472
+ const prev = tokens[i - 1];
34473
+ if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
34474
+ return true;
34475
+ }
34476
+ }
34477
+ }
34478
+ return false;
34479
+ }
34480
+ function redactProperty(name, value) {
34481
+ if (value === undefined || value === null) {
34482
+ return;
34483
+ }
34484
+ if (isSensitiveName(name)) {
34485
+ return REDACTED;
34486
+ }
34487
+ if (typeof value === "boolean" || typeof value === "number") {
34488
+ return value;
34489
+ }
34490
+ if (typeof value !== "string") {
34491
+ return "[OBJECT]";
34492
+ }
34493
+ return redactValueDetectors(value);
34494
+ }
34495
+ function redactProperties(properties) {
34496
+ const out = {};
34497
+ for (const [name, value] of Object.entries(properties)) {
34498
+ const redacted = redactProperty(name, value);
34499
+ if (redacted !== undefined) {
34500
+ out[name] = redacted;
34501
+ }
34502
+ }
34503
+ return out;
34504
+ }
34505
+
34338
34506
  // ../common/src/telemetry/telemetry-service.ts
34507
+ var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
34508
+ var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
34509
+ var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
34510
+
34339
34511
  class TelemetryService {
34340
34512
  telemetryProvider;
34341
34513
  contextStorage;
@@ -34362,11 +34534,15 @@ class TelemetryService {
34362
34534
  trackException(error, properties) {
34363
34535
  const context = this.getCurrentContext();
34364
34536
  const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
34365
- this.telemetryProvider.trackException(error, enrichedProperties);
34537
+ this.telemetryProvider.trackException(redactError(error), enrichedProperties);
34366
34538
  }
34367
34539
  async trackRequest(name, fn, properties) {
34540
+ const parentContext = this.getCurrentContext();
34541
+ const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
34542
+ const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
34368
34543
  const context = {
34369
- operationId: this.operationId ?? this.generateId(),
34544
+ operationId,
34545
+ ...parentId !== undefined ? { parentId } : {},
34370
34546
  id: this.generateId()
34371
34547
  };
34372
34548
  const startTime = performance.now();
@@ -34384,6 +34560,45 @@ class TelemetryService {
34384
34560
  throw error;
34385
34561
  }
34386
34562
  }
34563
+ trackRequestResult(name, durationMs, success, properties, context) {
34564
+ const requestContext = context ?? {
34565
+ operationId: this.operationId ?? getTelemetryOperationId(),
34566
+ id: this.generateId()
34567
+ };
34568
+ const enrichedProperties = this.enrichPropertiesWithContext(properties, requestContext);
34569
+ this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
34570
+ }
34571
+ createRequestContext() {
34572
+ const operationId = this.operationId ?? getTelemetryOperationId();
34573
+ const parentId = this.inboundParentIdFor(operationId);
34574
+ return {
34575
+ operationId,
34576
+ ...parentId !== undefined ? { parentId } : {},
34577
+ id: this.generateId()
34578
+ };
34579
+ }
34580
+ inboundParentIdFor(operationId) {
34581
+ const inbound = getInboundTraceContext();
34582
+ return inbound && inbound.traceId === operationId ? inbound.parentSpanId : undefined;
34583
+ }
34584
+ runWithContext(context, fn) {
34585
+ return this.contextStorage.run(context, fn);
34586
+ }
34587
+ createDependencyContext() {
34588
+ const parentContext = this.getCurrentContext();
34589
+ if (!parentContext) {
34590
+ return;
34591
+ }
34592
+ return {
34593
+ operationId: parentContext.operationId,
34594
+ parentId: parentContext.id,
34595
+ id: this.generateId()
34596
+ };
34597
+ }
34598
+ trackDependencyResult(name, type2, durationMs, success, properties, context, resultCode) {
34599
+ const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
34600
+ this.telemetryProvider.trackDependency(redactValue(name), type2, durationMs, success, enrichedProperties, resultCode);
34601
+ }
34387
34602
  async trackDependencyOperation(name, type2, fn, properties) {
34388
34603
  const parentContext = this.getCurrentContext();
34389
34604
  if (!parentContext) {
@@ -34420,8 +34635,12 @@ class TelemetryService {
34420
34635
  ...getExecutionContextTelemetryProperties(),
34421
34636
  ...globalProperties,
34422
34637
  ...this.defaultProperties,
34423
- ...properties,
34424
- ...context
34638
+ ...redactProperties(properties ?? {}),
34639
+ ...context ? {
34640
+ [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
34641
+ ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
34642
+ [TELEMETRY_SPAN_ID_PROPERTY]: context.id
34643
+ } : {}
34425
34644
  };
34426
34645
  if (sessionId === undefined) {
34427
34646
  delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
@@ -34431,7 +34650,16 @@ class TelemetryService {
34431
34650
  return enriched;
34432
34651
  }
34433
34652
  generateId() {
34434
- return crypto.randomUUID().replaceAll("-", "");
34653
+ const bytes = new Uint8Array(8);
34654
+ let hex = "";
34655
+ do {
34656
+ crypto.getRandomValues(bytes);
34657
+ hex = "";
34658
+ for (const byte of bytes) {
34659
+ hex += byte.toString(16).padStart(2, "0");
34660
+ }
34661
+ } while (/^0+$/.test(hex));
34662
+ return hex;
34435
34663
  }
34436
34664
  }
34437
34665
  // ../common/src/telemetry/node-appinsights-telemetry-provider.ts
@@ -35134,134 +35362,11 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
35134
35362
  };
35135
35363
  }
35136
35364
 
35137
- // ../common/src/telemetry/pii-redactor.ts
35138
- var REDACTED = "[REDACTED]";
35139
- var MAX_VALUE_LENGTH = 200;
35140
- var SENSITIVE_NAME_TOKENS = new Set([
35141
- "token",
35142
- "tokens",
35143
- "secret",
35144
- "secrets",
35145
- "password",
35146
- "passwords",
35147
- "pwd",
35148
- "credential",
35149
- "credentials",
35150
- "auth",
35151
- "authentication",
35152
- "authorization",
35153
- "authority",
35154
- "cert",
35155
- "certificate",
35156
- "certificates"
35157
- ]);
35158
- var SENSITIVE_KEY_PREFIXES = new Set([
35159
- "api",
35160
- "access",
35161
- "client",
35162
- "private",
35163
- "public",
35164
- "signing",
35165
- "encryption",
35166
- "session",
35167
- "master",
35168
- "shared",
35169
- "root",
35170
- "ssh",
35171
- "rsa",
35172
- "aes",
35173
- "hmac",
35174
- "oauth"
35175
- ]);
35176
- 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;
35177
- var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
35178
- var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
35179
- var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
35180
- var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
35181
- var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
35182
- var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
35183
- function shortHash(input) {
35184
- let hash = 2166136261;
35185
- for (let i = 0;i < input.length; i++) {
35186
- hash ^= input.charCodeAt(i);
35187
- hash = Math.imul(hash, 16777619);
35188
- }
35189
- return (hash >>> 0).toString(16).padStart(8, "0");
35190
- }
35191
- function redactUrl(raw) {
35192
- try {
35193
- const url = new URL(raw);
35194
- return `${url.protocol}//${url.host}`;
35195
- } catch {
35196
- return `url#${shortHash(raw)}`;
35197
- }
35198
- }
35199
- function redactValueDetectors(value) {
35200
- let out = value;
35201
- out = out.replace(JWT_PATTERN, () => REDACTED);
35202
- out = out.replace(URL_PATTERN, (match) => {
35203
- const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
35204
- const core2 = trailing ? match.slice(0, -trailing.length) : match;
35205
- return `${redactUrl(core2)}${trailing}`;
35206
- });
35207
- out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
35208
- out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
35209
- out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
35210
- out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
35211
- if (out.length > MAX_VALUE_LENGTH) {
35212
- out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
35213
- }
35214
- return out;
35215
- }
35216
- function nameTokens(name) {
35217
- 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);
35218
- }
35219
- function isSensitiveName(name) {
35220
- const tokens = nameTokens(name);
35221
- for (let i = 0;i < tokens.length; i++) {
35222
- const token = tokens[i];
35223
- if (SENSITIVE_NAME_TOKENS.has(token)) {
35224
- return true;
35225
- }
35226
- if (token === "key" || token === "keys") {
35227
- const prev = tokens[i - 1];
35228
- if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
35229
- return true;
35230
- }
35231
- }
35232
- }
35233
- return false;
35234
- }
35235
- function redactProperty(name, value) {
35236
- if (value === undefined || value === null) {
35237
- return;
35238
- }
35239
- if (isSensitiveName(name)) {
35240
- return REDACTED;
35241
- }
35242
- if (typeof value === "boolean" || typeof value === "number") {
35243
- return value;
35244
- }
35245
- if (typeof value !== "string") {
35246
- return "[OBJECT]";
35247
- }
35248
- return redactValueDetectors(value);
35249
- }
35250
- function redactProperties(properties) {
35251
- const out = {};
35252
- for (const [name, value] of Object.entries(properties)) {
35253
- const redacted = redactProperty(name, value);
35254
- if (redacted !== undefined) {
35255
- out[name] = redacted;
35256
- }
35257
- }
35258
- return out;
35259
- }
35260
-
35261
35365
  // ../common/src/trackedAction.ts
35262
35366
  var pollSignalSlot = singleton("PollSignal");
35263
35367
  var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
35264
35368
  var retryHintValues = new Set(RETRY_HINTS);
35369
+ var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
35265
35370
  var processContext = {
35266
35371
  exit: (code) => {
35267
35372
  process.exitCode = code;
@@ -35272,22 +35377,18 @@ var processContext = {
35272
35377
  };
35273
35378
  function extractCommandParams(cmd) {
35274
35379
  const params = {};
35380
+ const add2 = (name, value) => {
35381
+ if (name && value !== undefined) {
35382
+ params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = value;
35383
+ }
35384
+ };
35275
35385
  const registered = cmd.registeredArguments ?? [];
35276
35386
  const processed = cmd.processedArgs ?? [];
35277
35387
  for (let i = 0;i < registered.length; i++) {
35278
- const value = processed[i];
35279
- if (value === undefined) {
35280
- continue;
35281
- }
35282
- const name = registered[i].name();
35283
- if (name) {
35284
- params[name] = value;
35285
- }
35388
+ add2(registered[i].name(), processed[i]);
35286
35389
  }
35287
35390
  for (const [key, value] of Object.entries(cmd.opts())) {
35288
- if (value !== undefined) {
35289
- params[key] = value;
35290
- }
35391
+ add2(key, value);
35291
35392
  }
35292
35393
  return params;
35293
35394
  }
@@ -35330,11 +35431,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
35330
35431
  return this.action(async (...args) => {
35331
35432
  const telemetryName = deriveCommandPath(command);
35332
35433
  const props = typeof properties === "function" ? properties(...args) : properties;
35434
+ const requestContext = telemetry.createRequestContext();
35333
35435
  const startTime = performance.now();
35334
35436
  let errorMessage;
35335
35437
  let fallbackExitCode = EXIT_CODES.Success;
35336
35438
  clearRecordedCommandFailureTelemetry();
35337
- const [error] = await catchError(fn(...args));
35439
+ const [error] = await catchError(telemetry.runWithContext(requestContext, () => fn(...args)));
35338
35440
  if (error) {
35339
35441
  errorMessage = error instanceof Error ? error.message : String(error);
35340
35442
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
@@ -35370,16 +35472,21 @@ Command.prototype.trackedAction = function(context, fn, properties) {
35370
35472
  recordedFailure,
35371
35473
  pollSignal: context.pollSignal
35372
35474
  });
35373
- telemetry.trackEvent(telemetryName, redactProperties({
35374
- ...extractCommandParams(command),
35475
+ const commandParams = extractCommandParams(command);
35476
+ if (props) {
35477
+ for (const key of Object.keys(props)) {
35478
+ delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
35479
+ }
35480
+ }
35481
+ const baseProperties = redactProperties({
35482
+ ...commandParams,
35375
35483
  ...props,
35376
35484
  ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
35377
35485
  command: "true",
35378
- duration: String(durationMs),
35379
- success: String(success),
35380
35486
  ...terminalTelemetry,
35381
35487
  ...errorMessage ? { errorMessage } : {}
35382
- }));
35488
+ });
35489
+ telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
35383
35490
  });
35384
35491
  };
35385
35492
  // ../common/src/console-guard.ts
@@ -37634,7 +37741,7 @@ class JSONApiResponse2 {
37634
37741
  var package_default2 = {
37635
37742
  name: "@uipath/solution-sdk",
37636
37743
  license: "MIT",
37637
- version: "1.199.0-preview.92",
37744
+ version: "1.199.0-preview.97",
37638
37745
  repository: {
37639
37746
  type: "git",
37640
37747
  url: "https://github.com/UiPath/cli.git",
@@ -43314,4 +43421,4 @@ export {
43314
43421
  activateDeploymentAsync
43315
43422
  };
43316
43423
 
43317
- //# debugId=0561FD16BFA852C864756E2164756E21
43424
+ //# debugId=329BA2D0DEF82DFC64756E2164756E21