@uipath/solution-tool 1.198.0-preview.95 → 1.198.0

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/publish.js CHANGED
@@ -27362,11 +27362,36 @@ class NodeContextStorage {
27362
27362
  return this.storage.getStore();
27363
27363
  }
27364
27364
  }
27365
+ // ../common/src/telemetry/trace-context.ts
27366
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
27367
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
27368
+ function getProcessEnv() {
27369
+ return globalThis.process?.env;
27370
+ }
27371
+ function parseInboundTraceparent(value) {
27372
+ if (!value) {
27373
+ return;
27374
+ }
27375
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
27376
+ if (!match) {
27377
+ return;
27378
+ }
27379
+ const [, traceId, parentSpanId] = match;
27380
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
27381
+ return;
27382
+ }
27383
+ return { traceId, parentSpanId };
27384
+ }
27385
+ function getInboundTraceContext() {
27386
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
27387
+ }
27388
+
27365
27389
  // ../common/src/telemetry/session-id.ts
27366
27390
  var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
27367
27391
  var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
27368
27392
  var telemetrySessionIdSlot = singleton("TelemetrySessionId");
27369
- function getProcessEnv() {
27393
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
27394
+ function getProcessEnv2() {
27370
27395
  return globalThis.process?.env;
27371
27396
  }
27372
27397
  function normalizeSessionId(value) {
@@ -27377,18 +27402,165 @@ function normalizeSessionId(value) {
27377
27402
  return trimmed || undefined;
27378
27403
  }
27379
27404
  function getConfiguredTelemetrySessionId() {
27380
- return normalizeSessionId(getProcessEnv()?.[TELEMETRY_SESSION_ID_ENV]);
27405
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
27381
27406
  }
27382
27407
  function resolveTelemetrySessionId(existingSessionId) {
27383
27408
  return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
27384
27409
  }
27410
+ function getTelemetryOperationId() {
27411
+ const existing = telemetryOperationIdSlot.get();
27412
+ if (existing) {
27413
+ return existing;
27414
+ }
27415
+ const inboundTraceId = getInboundTraceContext()?.traceId;
27416
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
27417
+ telemetryOperationIdSlot.set(generated);
27418
+ return generated;
27419
+ }
27385
27420
  // ../common/src/telemetry/global-telemetry-properties.ts
27386
27421
  var telemetryPropsSlot = singleton("TelemetryDefaultProps");
27387
27422
  function getGlobalTelemetryProperties() {
27388
27423
  return telemetryPropsSlot.get();
27389
27424
  }
27390
27425
 
27426
+ // ../common/src/telemetry/pii-redactor.ts
27427
+ var REDACTED = "[REDACTED]";
27428
+ var MAX_VALUE_LENGTH = 200;
27429
+ var SENSITIVE_NAME_TOKENS = new Set([
27430
+ "token",
27431
+ "tokens",
27432
+ "secret",
27433
+ "secrets",
27434
+ "password",
27435
+ "passwords",
27436
+ "pwd",
27437
+ "credential",
27438
+ "credentials",
27439
+ "auth",
27440
+ "authentication",
27441
+ "authorization",
27442
+ "authority",
27443
+ "cert",
27444
+ "certificate",
27445
+ "certificates"
27446
+ ]);
27447
+ var SENSITIVE_KEY_PREFIXES = new Set([
27448
+ "api",
27449
+ "access",
27450
+ "client",
27451
+ "private",
27452
+ "public",
27453
+ "signing",
27454
+ "encryption",
27455
+ "session",
27456
+ "master",
27457
+ "shared",
27458
+ "root",
27459
+ "ssh",
27460
+ "rsa",
27461
+ "aes",
27462
+ "hmac",
27463
+ "oauth"
27464
+ ]);
27465
+ 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;
27466
+ var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
27467
+ var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
27468
+ var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
27469
+ var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
27470
+ var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
27471
+ var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
27472
+ function shortHash(input) {
27473
+ let hash = 2166136261;
27474
+ for (let i = 0;i < input.length; i++) {
27475
+ hash ^= input.charCodeAt(i);
27476
+ hash = Math.imul(hash, 16777619);
27477
+ }
27478
+ return (hash >>> 0).toString(16).padStart(8, "0");
27479
+ }
27480
+ function redactUrl(raw) {
27481
+ try {
27482
+ const url = new URL(raw);
27483
+ return `${url.protocol}//${url.host}`;
27484
+ } catch {
27485
+ return `url#${shortHash(raw)}`;
27486
+ }
27487
+ }
27488
+ function redactValueDetectors(value) {
27489
+ let out = value;
27490
+ out = out.replace(JWT_PATTERN, () => REDACTED);
27491
+ out = out.replace(URL_PATTERN, (match) => {
27492
+ const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
27493
+ const core2 = trailing ? match.slice(0, -trailing.length) : match;
27494
+ return `${redactUrl(core2)}${trailing}`;
27495
+ });
27496
+ out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
27497
+ out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
27498
+ out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
27499
+ out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
27500
+ if (out.length > MAX_VALUE_LENGTH) {
27501
+ out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
27502
+ }
27503
+ return out;
27504
+ }
27505
+ function redactValue(value) {
27506
+ return redactValueDetectors(value);
27507
+ }
27508
+ function redactError(error) {
27509
+ const safe = new Error(redactValueDetectors(error.message ?? ""));
27510
+ safe.name = error.name;
27511
+ safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
27512
+ return safe;
27513
+ }
27514
+ function nameTokens(name) {
27515
+ 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);
27516
+ }
27517
+ function isSensitiveName(name) {
27518
+ const tokens = nameTokens(name);
27519
+ for (let i = 0;i < tokens.length; i++) {
27520
+ const token = tokens[i];
27521
+ if (SENSITIVE_NAME_TOKENS.has(token)) {
27522
+ return true;
27523
+ }
27524
+ if (token === "key" || token === "keys") {
27525
+ const prev = tokens[i - 1];
27526
+ if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
27527
+ return true;
27528
+ }
27529
+ }
27530
+ }
27531
+ return false;
27532
+ }
27533
+ function redactProperty(name, value) {
27534
+ if (value === undefined || value === null) {
27535
+ return;
27536
+ }
27537
+ if (isSensitiveName(name)) {
27538
+ return REDACTED;
27539
+ }
27540
+ if (typeof value === "boolean" || typeof value === "number") {
27541
+ return value;
27542
+ }
27543
+ if (typeof value !== "string") {
27544
+ return "[OBJECT]";
27545
+ }
27546
+ return redactValueDetectors(value);
27547
+ }
27548
+ function redactProperties(properties) {
27549
+ const out = {};
27550
+ for (const [name, value] of Object.entries(properties)) {
27551
+ const redacted = redactProperty(name, value);
27552
+ if (redacted !== undefined) {
27553
+ out[name] = redacted;
27554
+ }
27555
+ }
27556
+ return out;
27557
+ }
27558
+
27391
27559
  // ../common/src/telemetry/telemetry-service.ts
27560
+ var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
27561
+ var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
27562
+ var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
27563
+
27392
27564
  class TelemetryService {
27393
27565
  telemetryProvider;
27394
27566
  contextStorage;
@@ -27415,11 +27587,15 @@ class TelemetryService {
27415
27587
  trackException(error, properties) {
27416
27588
  const context = this.getCurrentContext();
27417
27589
  const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
27418
- this.telemetryProvider.trackException(error, enrichedProperties);
27590
+ this.telemetryProvider.trackException(redactError(error), enrichedProperties);
27419
27591
  }
27420
27592
  async trackRequest(name, fn, properties) {
27593
+ const parentContext = this.getCurrentContext();
27594
+ const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
27595
+ const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
27421
27596
  const context = {
27422
- operationId: this.operationId ?? this.generateId(),
27597
+ operationId,
27598
+ ...parentId !== undefined ? { parentId } : {},
27423
27599
  id: this.generateId()
27424
27600
  };
27425
27601
  const startTime = performance.now();
@@ -27437,6 +27613,45 @@ class TelemetryService {
27437
27613
  throw error;
27438
27614
  }
27439
27615
  }
27616
+ trackRequestResult(name, durationMs, success, properties, context) {
27617
+ const requestContext = context ?? {
27618
+ operationId: this.operationId ?? getTelemetryOperationId(),
27619
+ id: this.generateId()
27620
+ };
27621
+ const enrichedProperties = this.enrichPropertiesWithContext(properties, requestContext);
27622
+ this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
27623
+ }
27624
+ createRequestContext() {
27625
+ const operationId = this.operationId ?? getTelemetryOperationId();
27626
+ const parentId = this.inboundParentIdFor(operationId);
27627
+ return {
27628
+ operationId,
27629
+ ...parentId !== undefined ? { parentId } : {},
27630
+ id: this.generateId()
27631
+ };
27632
+ }
27633
+ inboundParentIdFor(operationId) {
27634
+ const inbound = getInboundTraceContext();
27635
+ return inbound && inbound.traceId === operationId ? inbound.parentSpanId : undefined;
27636
+ }
27637
+ runWithContext(context, fn) {
27638
+ return this.contextStorage.run(context, fn);
27639
+ }
27640
+ createDependencyContext() {
27641
+ const parentContext = this.getCurrentContext();
27642
+ if (!parentContext) {
27643
+ return;
27644
+ }
27645
+ return {
27646
+ operationId: parentContext.operationId,
27647
+ parentId: parentContext.id,
27648
+ id: this.generateId()
27649
+ };
27650
+ }
27651
+ trackDependencyResult(name, type2, durationMs, success, properties, context, resultCode) {
27652
+ const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
27653
+ this.telemetryProvider.trackDependency(redactValue(name), type2, durationMs, success, enrichedProperties, resultCode);
27654
+ }
27440
27655
  async trackDependencyOperation(name, type2, fn, properties) {
27441
27656
  const parentContext = this.getCurrentContext();
27442
27657
  if (!parentContext) {
@@ -27473,8 +27688,12 @@ class TelemetryService {
27473
27688
  ...getExecutionContextTelemetryProperties(),
27474
27689
  ...globalProperties,
27475
27690
  ...this.defaultProperties,
27476
- ...properties,
27477
- ...context
27691
+ ...redactProperties(properties ?? {}),
27692
+ ...context ? {
27693
+ [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
27694
+ ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
27695
+ [TELEMETRY_SPAN_ID_PROPERTY]: context.id
27696
+ } : {}
27478
27697
  };
27479
27698
  if (sessionId === undefined) {
27480
27699
  delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
@@ -27484,7 +27703,16 @@ class TelemetryService {
27484
27703
  return enriched;
27485
27704
  }
27486
27705
  generateId() {
27487
- return crypto.randomUUID().replaceAll("-", "");
27706
+ const bytes = new Uint8Array(8);
27707
+ let hex = "";
27708
+ do {
27709
+ crypto.getRandomValues(bytes);
27710
+ hex = "";
27711
+ for (const byte of bytes) {
27712
+ hex += byte.toString(16).padStart(2, "0");
27713
+ }
27714
+ } while (/^0+$/.test(hex));
27715
+ return hex;
27488
27716
  }
27489
27717
  }
27490
27718
  // ../common/src/telemetry/node-appinsights-telemetry-provider.ts
@@ -28186,152 +28414,25 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
28186
28414
  };
28187
28415
  }
28188
28416
 
28189
- // ../common/src/telemetry/pii-redactor.ts
28190
- var REDACTED = "[REDACTED]";
28191
- var MAX_VALUE_LENGTH = 200;
28192
- var SENSITIVE_NAME_TOKENS = new Set([
28193
- "token",
28194
- "tokens",
28195
- "secret",
28196
- "secrets",
28197
- "password",
28198
- "passwords",
28199
- "pwd",
28200
- "credential",
28201
- "credentials",
28202
- "auth",
28203
- "authentication",
28204
- "authorization",
28205
- "authority",
28206
- "cert",
28207
- "certificate",
28208
- "certificates"
28209
- ]);
28210
- var SENSITIVE_KEY_PREFIXES = new Set([
28211
- "api",
28212
- "access",
28213
- "client",
28214
- "private",
28215
- "public",
28216
- "signing",
28217
- "encryption",
28218
- "session",
28219
- "master",
28220
- "shared",
28221
- "root",
28222
- "ssh",
28223
- "rsa",
28224
- "aes",
28225
- "hmac",
28226
- "oauth"
28227
- ]);
28228
- 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;
28229
- var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
28230
- var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
28231
- var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
28232
- var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
28233
- var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
28234
- var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
28235
- function shortHash(input) {
28236
- let hash = 2166136261;
28237
- for (let i = 0;i < input.length; i++) {
28238
- hash ^= input.charCodeAt(i);
28239
- hash = Math.imul(hash, 16777619);
28240
- }
28241
- return (hash >>> 0).toString(16).padStart(8, "0");
28242
- }
28243
- function redactUrl(raw) {
28244
- try {
28245
- const url = new URL(raw);
28246
- return `${url.protocol}//${url.host}`;
28247
- } catch {
28248
- return `url#${shortHash(raw)}`;
28249
- }
28250
- }
28251
- function redactValueDetectors(value) {
28252
- let out = value;
28253
- out = out.replace(JWT_PATTERN, () => REDACTED);
28254
- out = out.replace(URL_PATTERN, (match) => {
28255
- const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
28256
- const core2 = trailing ? match.slice(0, -trailing.length) : match;
28257
- return `${redactUrl(core2)}${trailing}`;
28258
- });
28259
- out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
28260
- out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
28261
- out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
28262
- out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
28263
- if (out.length > MAX_VALUE_LENGTH) {
28264
- out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
28265
- }
28266
- return out;
28267
- }
28268
- function nameTokens(name) {
28269
- 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);
28270
- }
28271
- function isSensitiveName(name) {
28272
- const tokens = nameTokens(name);
28273
- for (let i = 0;i < tokens.length; i++) {
28274
- const token = tokens[i];
28275
- if (SENSITIVE_NAME_TOKENS.has(token)) {
28276
- return true;
28277
- }
28278
- if (token === "key" || token === "keys") {
28279
- const prev = tokens[i - 1];
28280
- if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
28281
- return true;
28282
- }
28283
- }
28284
- }
28285
- return false;
28286
- }
28287
- function redactProperty(name, value) {
28288
- if (value === undefined || value === null) {
28289
- return;
28290
- }
28291
- if (isSensitiveName(name)) {
28292
- return REDACTED;
28293
- }
28294
- if (typeof value === "boolean" || typeof value === "number") {
28295
- return value;
28296
- }
28297
- if (typeof value !== "string") {
28298
- return "[OBJECT]";
28299
- }
28300
- return redactValueDetectors(value);
28301
- }
28302
- function redactProperties(properties) {
28303
- const out = {};
28304
- for (const [name, value] of Object.entries(properties)) {
28305
- const redacted = redactProperty(name, value);
28306
- if (redacted !== undefined) {
28307
- out[name] = redacted;
28308
- }
28309
- }
28310
- return out;
28311
- }
28312
-
28313
28417
  // ../common/src/trackedAction.ts
28314
28418
  var pollSignalSlot = singleton("PollSignal");
28315
28419
  var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
28316
28420
  var retryHintValues = new Set(RETRY_HINTS);
28421
+ var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
28317
28422
  function extractCommandParams(cmd) {
28318
28423
  const params = {};
28424
+ const add2 = (name, value) => {
28425
+ if (name && value !== undefined) {
28426
+ params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = value;
28427
+ }
28428
+ };
28319
28429
  const registered = cmd.registeredArguments ?? [];
28320
28430
  const processed = cmd.processedArgs ?? [];
28321
28431
  for (let i = 0;i < registered.length; i++) {
28322
- const value = processed[i];
28323
- if (value === undefined) {
28324
- continue;
28325
- }
28326
- const name = registered[i].name();
28327
- if (name) {
28328
- params[name] = value;
28329
- }
28432
+ add2(registered[i].name(), processed[i]);
28330
28433
  }
28331
28434
  for (const [key, value] of Object.entries(cmd.opts())) {
28332
- if (value !== undefined) {
28333
- params[key] = value;
28334
- }
28435
+ add2(key, value);
28335
28436
  }
28336
28437
  return params;
28337
28438
  }
@@ -28374,11 +28475,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
28374
28475
  return this.action(async (...args) => {
28375
28476
  const telemetryName = deriveCommandPath(command);
28376
28477
  const props = typeof properties === "function" ? properties(...args) : properties;
28478
+ const requestContext = telemetry.createRequestContext();
28377
28479
  const startTime = performance.now();
28378
28480
  let errorMessage;
28379
28481
  let fallbackExitCode = EXIT_CODES.Success;
28380
28482
  clearRecordedCommandFailureTelemetry();
28381
- const [error] = await catchError(fn(...args));
28483
+ const [error] = await catchError(telemetry.runWithContext(requestContext, () => fn(...args)));
28382
28484
  if (error) {
28383
28485
  errorMessage = error instanceof Error ? error.message : String(error);
28384
28486
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
@@ -28414,16 +28516,21 @@ Command.prototype.trackedAction = function(context, fn, properties) {
28414
28516
  recordedFailure,
28415
28517
  pollSignal: context.pollSignal
28416
28518
  });
28417
- telemetry.trackEvent(telemetryName, redactProperties({
28418
- ...extractCommandParams(command),
28519
+ const commandParams = extractCommandParams(command);
28520
+ if (props) {
28521
+ for (const key of Object.keys(props)) {
28522
+ delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
28523
+ }
28524
+ }
28525
+ const baseProperties = redactProperties({
28526
+ ...commandParams,
28419
28527
  ...props,
28420
28528
  ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
28421
28529
  command: "true",
28422
- duration: String(durationMs),
28423
- success: String(success),
28424
28530
  ...terminalTelemetry,
28425
28531
  ...errorMessage ? { errorMessage } : {}
28426
- }));
28532
+ });
28533
+ telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
28427
28534
  });
28428
28535
  };
28429
28536
  // ../common/src/console-guard.ts
@@ -30589,7 +30696,7 @@ class TextApiResponse2 {
30589
30696
  var package_default2 = {
30590
30697
  name: "@uipath/solution-sdk",
30591
30698
  license: "MIT",
30592
- version: "1.198.0-preview.95",
30699
+ version: "1.198.0",
30593
30700
  repository: {
30594
30701
  type: "git",
30595
30702
  url: "https://github.com/UiPath/cli.git",
@@ -33364,4 +33471,4 @@ export {
33364
33471
  publishSolutionAsync
33365
33472
  };
33366
33473
 
33367
- //# debugId=15FF64751E0E7FEB64756E2164756E21
33474
+ //# debugId=BDF44030723049A264756E2164756E21