@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/init.js CHANGED
@@ -29448,11 +29448,36 @@ class NodeContextStorage {
29448
29448
  return this.storage.getStore();
29449
29449
  }
29450
29450
  }
29451
+ // ../common/src/telemetry/trace-context.ts
29452
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
29453
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
29454
+ function getProcessEnv() {
29455
+ return globalThis.process?.env;
29456
+ }
29457
+ function parseInboundTraceparent(value) {
29458
+ if (!value) {
29459
+ return;
29460
+ }
29461
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
29462
+ if (!match) {
29463
+ return;
29464
+ }
29465
+ const [, traceId, parentSpanId] = match;
29466
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
29467
+ return;
29468
+ }
29469
+ return { traceId, parentSpanId };
29470
+ }
29471
+ function getInboundTraceContext() {
29472
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
29473
+ }
29474
+
29451
29475
  // ../common/src/telemetry/session-id.ts
29452
29476
  var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
29453
29477
  var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
29454
29478
  var telemetrySessionIdSlot = singleton("TelemetrySessionId");
29455
- function getProcessEnv() {
29479
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
29480
+ function getProcessEnv2() {
29456
29481
  return globalThis.process?.env;
29457
29482
  }
29458
29483
  function normalizeSessionId(value) {
@@ -29463,18 +29488,165 @@ function normalizeSessionId(value) {
29463
29488
  return trimmed || undefined;
29464
29489
  }
29465
29490
  function getConfiguredTelemetrySessionId() {
29466
- return normalizeSessionId(getProcessEnv()?.[TELEMETRY_SESSION_ID_ENV]);
29491
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
29467
29492
  }
29468
29493
  function resolveTelemetrySessionId(existingSessionId) {
29469
29494
  return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
29470
29495
  }
29496
+ function getTelemetryOperationId() {
29497
+ const existing = telemetryOperationIdSlot.get();
29498
+ if (existing) {
29499
+ return existing;
29500
+ }
29501
+ const inboundTraceId = getInboundTraceContext()?.traceId;
29502
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
29503
+ telemetryOperationIdSlot.set(generated);
29504
+ return generated;
29505
+ }
29471
29506
  // ../common/src/telemetry/global-telemetry-properties.ts
29472
29507
  var telemetryPropsSlot = singleton("TelemetryDefaultProps");
29473
29508
  function getGlobalTelemetryProperties() {
29474
29509
  return telemetryPropsSlot.get();
29475
29510
  }
29476
29511
 
29512
+ // ../common/src/telemetry/pii-redactor.ts
29513
+ var REDACTED = "[REDACTED]";
29514
+ var MAX_VALUE_LENGTH = 200;
29515
+ var SENSITIVE_NAME_TOKENS = new Set([
29516
+ "token",
29517
+ "tokens",
29518
+ "secret",
29519
+ "secrets",
29520
+ "password",
29521
+ "passwords",
29522
+ "pwd",
29523
+ "credential",
29524
+ "credentials",
29525
+ "auth",
29526
+ "authentication",
29527
+ "authorization",
29528
+ "authority",
29529
+ "cert",
29530
+ "certificate",
29531
+ "certificates"
29532
+ ]);
29533
+ var SENSITIVE_KEY_PREFIXES = new Set([
29534
+ "api",
29535
+ "access",
29536
+ "client",
29537
+ "private",
29538
+ "public",
29539
+ "signing",
29540
+ "encryption",
29541
+ "session",
29542
+ "master",
29543
+ "shared",
29544
+ "root",
29545
+ "ssh",
29546
+ "rsa",
29547
+ "aes",
29548
+ "hmac",
29549
+ "oauth"
29550
+ ]);
29551
+ 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;
29552
+ var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
29553
+ var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
29554
+ var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
29555
+ var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
29556
+ var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
29557
+ var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
29558
+ function shortHash(input) {
29559
+ let hash = 2166136261;
29560
+ for (let i = 0;i < input.length; i++) {
29561
+ hash ^= input.charCodeAt(i);
29562
+ hash = Math.imul(hash, 16777619);
29563
+ }
29564
+ return (hash >>> 0).toString(16).padStart(8, "0");
29565
+ }
29566
+ function redactUrl(raw) {
29567
+ try {
29568
+ const url = new URL(raw);
29569
+ return `${url.protocol}//${url.host}`;
29570
+ } catch {
29571
+ return `url#${shortHash(raw)}`;
29572
+ }
29573
+ }
29574
+ function redactValueDetectors(value) {
29575
+ let out = value;
29576
+ out = out.replace(JWT_PATTERN, () => REDACTED);
29577
+ out = out.replace(URL_PATTERN, (match) => {
29578
+ const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
29579
+ const core2 = trailing ? match.slice(0, -trailing.length) : match;
29580
+ return `${redactUrl(core2)}${trailing}`;
29581
+ });
29582
+ out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
29583
+ out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
29584
+ out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
29585
+ out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
29586
+ if (out.length > MAX_VALUE_LENGTH) {
29587
+ out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
29588
+ }
29589
+ return out;
29590
+ }
29591
+ function redactValue(value) {
29592
+ return redactValueDetectors(value);
29593
+ }
29594
+ function redactError(error) {
29595
+ const safe = new Error(redactValueDetectors(error.message ?? ""));
29596
+ safe.name = error.name;
29597
+ safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
29598
+ return safe;
29599
+ }
29600
+ function nameTokens(name) {
29601
+ 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);
29602
+ }
29603
+ function isSensitiveName(name) {
29604
+ const tokens = nameTokens(name);
29605
+ for (let i = 0;i < tokens.length; i++) {
29606
+ const token = tokens[i];
29607
+ if (SENSITIVE_NAME_TOKENS.has(token)) {
29608
+ return true;
29609
+ }
29610
+ if (token === "key" || token === "keys") {
29611
+ const prev = tokens[i - 1];
29612
+ if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
29613
+ return true;
29614
+ }
29615
+ }
29616
+ }
29617
+ return false;
29618
+ }
29619
+ function redactProperty(name, value) {
29620
+ if (value === undefined || value === null) {
29621
+ return;
29622
+ }
29623
+ if (isSensitiveName(name)) {
29624
+ return REDACTED;
29625
+ }
29626
+ if (typeof value === "boolean" || typeof value === "number") {
29627
+ return value;
29628
+ }
29629
+ if (typeof value !== "string") {
29630
+ return "[OBJECT]";
29631
+ }
29632
+ return redactValueDetectors(value);
29633
+ }
29634
+ function redactProperties(properties) {
29635
+ const out = {};
29636
+ for (const [name, value] of Object.entries(properties)) {
29637
+ const redacted = redactProperty(name, value);
29638
+ if (redacted !== undefined) {
29639
+ out[name] = redacted;
29640
+ }
29641
+ }
29642
+ return out;
29643
+ }
29644
+
29477
29645
  // ../common/src/telemetry/telemetry-service.ts
29646
+ var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
29647
+ var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
29648
+ var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
29649
+
29478
29650
  class TelemetryService {
29479
29651
  telemetryProvider;
29480
29652
  contextStorage;
@@ -29501,11 +29673,15 @@ class TelemetryService {
29501
29673
  trackException(error, properties) {
29502
29674
  const context = this.getCurrentContext();
29503
29675
  const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
29504
- this.telemetryProvider.trackException(error, enrichedProperties);
29676
+ this.telemetryProvider.trackException(redactError(error), enrichedProperties);
29505
29677
  }
29506
29678
  async trackRequest(name, fn, properties) {
29679
+ const parentContext = this.getCurrentContext();
29680
+ const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
29681
+ const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
29507
29682
  const context = {
29508
- operationId: this.operationId ?? this.generateId(),
29683
+ operationId,
29684
+ ...parentId !== undefined ? { parentId } : {},
29509
29685
  id: this.generateId()
29510
29686
  };
29511
29687
  const startTime = performance.now();
@@ -29523,6 +29699,45 @@ class TelemetryService {
29523
29699
  throw error;
29524
29700
  }
29525
29701
  }
29702
+ trackRequestResult(name, durationMs, success, properties, context) {
29703
+ const requestContext = context ?? {
29704
+ operationId: this.operationId ?? getTelemetryOperationId(),
29705
+ id: this.generateId()
29706
+ };
29707
+ const enrichedProperties = this.enrichPropertiesWithContext(properties, requestContext);
29708
+ this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
29709
+ }
29710
+ createRequestContext() {
29711
+ const operationId = this.operationId ?? getTelemetryOperationId();
29712
+ const parentId = this.inboundParentIdFor(operationId);
29713
+ return {
29714
+ operationId,
29715
+ ...parentId !== undefined ? { parentId } : {},
29716
+ id: this.generateId()
29717
+ };
29718
+ }
29719
+ inboundParentIdFor(operationId) {
29720
+ const inbound = getInboundTraceContext();
29721
+ return inbound && inbound.traceId === operationId ? inbound.parentSpanId : undefined;
29722
+ }
29723
+ runWithContext(context, fn) {
29724
+ return this.contextStorage.run(context, fn);
29725
+ }
29726
+ createDependencyContext() {
29727
+ const parentContext = this.getCurrentContext();
29728
+ if (!parentContext) {
29729
+ return;
29730
+ }
29731
+ return {
29732
+ operationId: parentContext.operationId,
29733
+ parentId: parentContext.id,
29734
+ id: this.generateId()
29735
+ };
29736
+ }
29737
+ trackDependencyResult(name, type2, durationMs, success, properties, context, resultCode) {
29738
+ const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
29739
+ this.telemetryProvider.trackDependency(redactValue(name), type2, durationMs, success, enrichedProperties, resultCode);
29740
+ }
29526
29741
  async trackDependencyOperation(name, type2, fn, properties) {
29527
29742
  const parentContext = this.getCurrentContext();
29528
29743
  if (!parentContext) {
@@ -29559,8 +29774,12 @@ class TelemetryService {
29559
29774
  ...getExecutionContextTelemetryProperties(),
29560
29775
  ...globalProperties,
29561
29776
  ...this.defaultProperties,
29562
- ...properties,
29563
- ...context
29777
+ ...redactProperties(properties ?? {}),
29778
+ ...context ? {
29779
+ [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
29780
+ ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
29781
+ [TELEMETRY_SPAN_ID_PROPERTY]: context.id
29782
+ } : {}
29564
29783
  };
29565
29784
  if (sessionId === undefined) {
29566
29785
  delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
@@ -29570,7 +29789,16 @@ class TelemetryService {
29570
29789
  return enriched;
29571
29790
  }
29572
29791
  generateId() {
29573
- return crypto.randomUUID().replaceAll("-", "");
29792
+ const bytes = new Uint8Array(8);
29793
+ let hex = "";
29794
+ do {
29795
+ crypto.getRandomValues(bytes);
29796
+ hex = "";
29797
+ for (const byte of bytes) {
29798
+ hex += byte.toString(16).padStart(2, "0");
29799
+ }
29800
+ } while (/^0+$/.test(hex));
29801
+ return hex;
29574
29802
  }
29575
29803
  }
29576
29804
  // ../common/src/telemetry/node-appinsights-telemetry-provider.ts
@@ -30273,152 +30501,25 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
30273
30501
  };
30274
30502
  }
30275
30503
 
30276
- // ../common/src/telemetry/pii-redactor.ts
30277
- var REDACTED = "[REDACTED]";
30278
- var MAX_VALUE_LENGTH = 200;
30279
- var SENSITIVE_NAME_TOKENS = new Set([
30280
- "token",
30281
- "tokens",
30282
- "secret",
30283
- "secrets",
30284
- "password",
30285
- "passwords",
30286
- "pwd",
30287
- "credential",
30288
- "credentials",
30289
- "auth",
30290
- "authentication",
30291
- "authorization",
30292
- "authority",
30293
- "cert",
30294
- "certificate",
30295
- "certificates"
30296
- ]);
30297
- var SENSITIVE_KEY_PREFIXES = new Set([
30298
- "api",
30299
- "access",
30300
- "client",
30301
- "private",
30302
- "public",
30303
- "signing",
30304
- "encryption",
30305
- "session",
30306
- "master",
30307
- "shared",
30308
- "root",
30309
- "ssh",
30310
- "rsa",
30311
- "aes",
30312
- "hmac",
30313
- "oauth"
30314
- ]);
30315
- 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;
30316
- var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
30317
- var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
30318
- var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
30319
- var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
30320
- var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
30321
- var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
30322
- function shortHash(input) {
30323
- let hash = 2166136261;
30324
- for (let i = 0;i < input.length; i++) {
30325
- hash ^= input.charCodeAt(i);
30326
- hash = Math.imul(hash, 16777619);
30327
- }
30328
- return (hash >>> 0).toString(16).padStart(8, "0");
30329
- }
30330
- function redactUrl(raw) {
30331
- try {
30332
- const url = new URL(raw);
30333
- return `${url.protocol}//${url.host}`;
30334
- } catch {
30335
- return `url#${shortHash(raw)}`;
30336
- }
30337
- }
30338
- function redactValueDetectors(value) {
30339
- let out = value;
30340
- out = out.replace(JWT_PATTERN, () => REDACTED);
30341
- out = out.replace(URL_PATTERN, (match) => {
30342
- const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
30343
- const core2 = trailing ? match.slice(0, -trailing.length) : match;
30344
- return `${redactUrl(core2)}${trailing}`;
30345
- });
30346
- out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
30347
- out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
30348
- out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
30349
- out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
30350
- if (out.length > MAX_VALUE_LENGTH) {
30351
- out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
30352
- }
30353
- return out;
30354
- }
30355
- function nameTokens(name) {
30356
- 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);
30357
- }
30358
- function isSensitiveName(name) {
30359
- const tokens = nameTokens(name);
30360
- for (let i = 0;i < tokens.length; i++) {
30361
- const token = tokens[i];
30362
- if (SENSITIVE_NAME_TOKENS.has(token)) {
30363
- return true;
30364
- }
30365
- if (token === "key" || token === "keys") {
30366
- const prev = tokens[i - 1];
30367
- if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
30368
- return true;
30369
- }
30370
- }
30371
- }
30372
- return false;
30373
- }
30374
- function redactProperty(name, value) {
30375
- if (value === undefined || value === null) {
30376
- return;
30377
- }
30378
- if (isSensitiveName(name)) {
30379
- return REDACTED;
30380
- }
30381
- if (typeof value === "boolean" || typeof value === "number") {
30382
- return value;
30383
- }
30384
- if (typeof value !== "string") {
30385
- return "[OBJECT]";
30386
- }
30387
- return redactValueDetectors(value);
30388
- }
30389
- function redactProperties(properties) {
30390
- const out = {};
30391
- for (const [name, value] of Object.entries(properties)) {
30392
- const redacted = redactProperty(name, value);
30393
- if (redacted !== undefined) {
30394
- out[name] = redacted;
30395
- }
30396
- }
30397
- return out;
30398
- }
30399
-
30400
30504
  // ../common/src/trackedAction.ts
30401
30505
  var pollSignalSlot = singleton("PollSignal");
30402
30506
  var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
30403
30507
  var retryHintValues = new Set(RETRY_HINTS);
30508
+ var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
30404
30509
  function extractCommandParams(cmd) {
30405
30510
  const params = {};
30511
+ const add2 = (name, value) => {
30512
+ if (name && value !== undefined) {
30513
+ params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = value;
30514
+ }
30515
+ };
30406
30516
  const registered = cmd.registeredArguments ?? [];
30407
30517
  const processed = cmd.processedArgs ?? [];
30408
30518
  for (let i = 0;i < registered.length; i++) {
30409
- const value = processed[i];
30410
- if (value === undefined) {
30411
- continue;
30412
- }
30413
- const name = registered[i].name();
30414
- if (name) {
30415
- params[name] = value;
30416
- }
30519
+ add2(registered[i].name(), processed[i]);
30417
30520
  }
30418
30521
  for (const [key, value] of Object.entries(cmd.opts())) {
30419
- if (value !== undefined) {
30420
- params[key] = value;
30421
- }
30522
+ add2(key, value);
30422
30523
  }
30423
30524
  return params;
30424
30525
  }
@@ -30461,11 +30562,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
30461
30562
  return this.action(async (...args) => {
30462
30563
  const telemetryName = deriveCommandPath(command);
30463
30564
  const props = typeof properties === "function" ? properties(...args) : properties;
30565
+ const requestContext = telemetry.createRequestContext();
30464
30566
  const startTime = performance.now();
30465
30567
  let errorMessage;
30466
30568
  let fallbackExitCode = EXIT_CODES.Success;
30467
30569
  clearRecordedCommandFailureTelemetry();
30468
- const [error] = await catchError(fn(...args));
30570
+ const [error] = await catchError(telemetry.runWithContext(requestContext, () => fn(...args)));
30469
30571
  if (error) {
30470
30572
  errorMessage = error instanceof Error ? error.message : String(error);
30471
30573
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
@@ -30501,16 +30603,21 @@ Command.prototype.trackedAction = function(context, fn, properties) {
30501
30603
  recordedFailure,
30502
30604
  pollSignal: context.pollSignal
30503
30605
  });
30504
- telemetry.trackEvent(telemetryName, redactProperties({
30505
- ...extractCommandParams(command),
30606
+ const commandParams = extractCommandParams(command);
30607
+ if (props) {
30608
+ for (const key of Object.keys(props)) {
30609
+ delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
30610
+ }
30611
+ }
30612
+ const baseProperties = redactProperties({
30613
+ ...commandParams,
30506
30614
  ...props,
30507
30615
  ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
30508
30616
  command: "true",
30509
- duration: String(durationMs),
30510
- success: String(success),
30511
30617
  ...terminalTelemetry,
30512
30618
  ...errorMessage ? { errorMessage } : {}
30513
- }));
30619
+ });
30620
+ telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
30514
30621
  });
30515
30622
  };
30516
30623
  // ../common/src/console-guard.ts
@@ -30881,7 +30988,7 @@ function querystringSingleKey(key, value, keyPrefix = "") {
30881
30988
  var package_default = {
30882
30989
  name: "@uipath/solution-sdk",
30883
30990
  license: "MIT",
30884
- version: "1.199.0-preview.92",
30991
+ version: "1.199.0-preview.99",
30885
30992
  repository: {
30886
30993
  type: "git",
30887
30994
  url: "https://github.com/UiPath/cli.git",
@@ -48706,4 +48813,4 @@ export {
48706
48813
  SolutionInitError
48707
48814
  };
48708
48815
 
48709
- //# debugId=F3F130FD16F5F5A164756E2164756E21
48816
+ //# debugId=3BE06FACEB40E0FD64756E2164756E21