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

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