@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/resource.js CHANGED
@@ -29728,11 +29728,36 @@ class NodeContextStorage {
29728
29728
  return this.storage.getStore();
29729
29729
  }
29730
29730
  }
29731
+ // ../common/src/telemetry/trace-context.ts
29732
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
29733
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
29734
+ function getProcessEnv() {
29735
+ return globalThis.process?.env;
29736
+ }
29737
+ function parseInboundTraceparent(value) {
29738
+ if (!value) {
29739
+ return;
29740
+ }
29741
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
29742
+ if (!match) {
29743
+ return;
29744
+ }
29745
+ const [, traceId, parentSpanId] = match;
29746
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
29747
+ return;
29748
+ }
29749
+ return { traceId, parentSpanId };
29750
+ }
29751
+ function getInboundTraceContext() {
29752
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
29753
+ }
29754
+
29731
29755
  // ../common/src/telemetry/session-id.ts
29732
29756
  var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
29733
29757
  var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
29734
29758
  var telemetrySessionIdSlot = singleton("TelemetrySessionId");
29735
- function getProcessEnv() {
29759
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
29760
+ function getProcessEnv2() {
29736
29761
  return globalThis.process?.env;
29737
29762
  }
29738
29763
  function normalizeSessionId(value) {
@@ -29743,18 +29768,165 @@ function normalizeSessionId(value) {
29743
29768
  return trimmed || undefined;
29744
29769
  }
29745
29770
  function getConfiguredTelemetrySessionId() {
29746
- return normalizeSessionId(getProcessEnv()?.[TELEMETRY_SESSION_ID_ENV]);
29771
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
29747
29772
  }
29748
29773
  function resolveTelemetrySessionId(existingSessionId) {
29749
29774
  return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
29750
29775
  }
29776
+ function getTelemetryOperationId() {
29777
+ const existing = telemetryOperationIdSlot.get();
29778
+ if (existing) {
29779
+ return existing;
29780
+ }
29781
+ const inboundTraceId = getInboundTraceContext()?.traceId;
29782
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
29783
+ telemetryOperationIdSlot.set(generated);
29784
+ return generated;
29785
+ }
29751
29786
  // ../common/src/telemetry/global-telemetry-properties.ts
29752
29787
  var telemetryPropsSlot = singleton("TelemetryDefaultProps");
29753
29788
  function getGlobalTelemetryProperties() {
29754
29789
  return telemetryPropsSlot.get();
29755
29790
  }
29756
29791
 
29792
+ // ../common/src/telemetry/pii-redactor.ts
29793
+ var REDACTED = "[REDACTED]";
29794
+ var MAX_VALUE_LENGTH = 200;
29795
+ var SENSITIVE_NAME_TOKENS = new Set([
29796
+ "token",
29797
+ "tokens",
29798
+ "secret",
29799
+ "secrets",
29800
+ "password",
29801
+ "passwords",
29802
+ "pwd",
29803
+ "credential",
29804
+ "credentials",
29805
+ "auth",
29806
+ "authentication",
29807
+ "authorization",
29808
+ "authority",
29809
+ "cert",
29810
+ "certificate",
29811
+ "certificates"
29812
+ ]);
29813
+ var SENSITIVE_KEY_PREFIXES = new Set([
29814
+ "api",
29815
+ "access",
29816
+ "client",
29817
+ "private",
29818
+ "public",
29819
+ "signing",
29820
+ "encryption",
29821
+ "session",
29822
+ "master",
29823
+ "shared",
29824
+ "root",
29825
+ "ssh",
29826
+ "rsa",
29827
+ "aes",
29828
+ "hmac",
29829
+ "oauth"
29830
+ ]);
29831
+ 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;
29832
+ var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
29833
+ var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
29834
+ var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
29835
+ var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
29836
+ var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
29837
+ var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
29838
+ function shortHash(input) {
29839
+ let hash = 2166136261;
29840
+ for (let i = 0;i < input.length; i++) {
29841
+ hash ^= input.charCodeAt(i);
29842
+ hash = Math.imul(hash, 16777619);
29843
+ }
29844
+ return (hash >>> 0).toString(16).padStart(8, "0");
29845
+ }
29846
+ function redactUrl(raw) {
29847
+ try {
29848
+ const url = new URL(raw);
29849
+ return `${url.protocol}//${url.host}`;
29850
+ } catch {
29851
+ return `url#${shortHash(raw)}`;
29852
+ }
29853
+ }
29854
+ function redactValueDetectors(value) {
29855
+ let out = value;
29856
+ out = out.replace(JWT_PATTERN, () => REDACTED);
29857
+ out = out.replace(URL_PATTERN, (match) => {
29858
+ const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
29859
+ const core2 = trailing ? match.slice(0, -trailing.length) : match;
29860
+ return `${redactUrl(core2)}${trailing}`;
29861
+ });
29862
+ out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
29863
+ out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
29864
+ out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
29865
+ out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
29866
+ if (out.length > MAX_VALUE_LENGTH) {
29867
+ out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
29868
+ }
29869
+ return out;
29870
+ }
29871
+ function redactValue(value) {
29872
+ return redactValueDetectors(value);
29873
+ }
29874
+ function redactError(error) {
29875
+ const safe = new Error(redactValueDetectors(error.message ?? ""));
29876
+ safe.name = error.name;
29877
+ safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
29878
+ return safe;
29879
+ }
29880
+ function nameTokens(name) {
29881
+ 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);
29882
+ }
29883
+ function isSensitiveName(name) {
29884
+ const tokens = nameTokens(name);
29885
+ for (let i = 0;i < tokens.length; i++) {
29886
+ const token = tokens[i];
29887
+ if (SENSITIVE_NAME_TOKENS.has(token)) {
29888
+ return true;
29889
+ }
29890
+ if (token === "key" || token === "keys") {
29891
+ const prev = tokens[i - 1];
29892
+ if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
29893
+ return true;
29894
+ }
29895
+ }
29896
+ }
29897
+ return false;
29898
+ }
29899
+ function redactProperty(name, value) {
29900
+ if (value === undefined || value === null) {
29901
+ return;
29902
+ }
29903
+ if (isSensitiveName(name)) {
29904
+ return REDACTED;
29905
+ }
29906
+ if (typeof value === "boolean" || typeof value === "number") {
29907
+ return value;
29908
+ }
29909
+ if (typeof value !== "string") {
29910
+ return "[OBJECT]";
29911
+ }
29912
+ return redactValueDetectors(value);
29913
+ }
29914
+ function redactProperties(properties) {
29915
+ const out = {};
29916
+ for (const [name, value] of Object.entries(properties)) {
29917
+ const redacted = redactProperty(name, value);
29918
+ if (redacted !== undefined) {
29919
+ out[name] = redacted;
29920
+ }
29921
+ }
29922
+ return out;
29923
+ }
29924
+
29757
29925
  // ../common/src/telemetry/telemetry-service.ts
29926
+ var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
29927
+ var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
29928
+ var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
29929
+
29758
29930
  class TelemetryService {
29759
29931
  telemetryProvider;
29760
29932
  contextStorage;
@@ -29781,11 +29953,15 @@ class TelemetryService {
29781
29953
  trackException(error, properties) {
29782
29954
  const context = this.getCurrentContext();
29783
29955
  const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
29784
- this.telemetryProvider.trackException(error, enrichedProperties);
29956
+ this.telemetryProvider.trackException(redactError(error), enrichedProperties);
29785
29957
  }
29786
29958
  async trackRequest(name, fn, properties) {
29959
+ const parentContext = this.getCurrentContext();
29960
+ const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
29961
+ const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
29787
29962
  const context = {
29788
- operationId: this.operationId ?? this.generateId(),
29963
+ operationId,
29964
+ ...parentId !== undefined ? { parentId } : {},
29789
29965
  id: this.generateId()
29790
29966
  };
29791
29967
  const startTime = performance.now();
@@ -29803,6 +29979,45 @@ class TelemetryService {
29803
29979
  throw error;
29804
29980
  }
29805
29981
  }
29982
+ trackRequestResult(name, durationMs, success, properties, context) {
29983
+ const requestContext = context ?? {
29984
+ operationId: this.operationId ?? getTelemetryOperationId(),
29985
+ id: this.generateId()
29986
+ };
29987
+ const enrichedProperties = this.enrichPropertiesWithContext(properties, requestContext);
29988
+ this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
29989
+ }
29990
+ createRequestContext() {
29991
+ const operationId = this.operationId ?? getTelemetryOperationId();
29992
+ const parentId = this.inboundParentIdFor(operationId);
29993
+ return {
29994
+ operationId,
29995
+ ...parentId !== undefined ? { parentId } : {},
29996
+ id: this.generateId()
29997
+ };
29998
+ }
29999
+ inboundParentIdFor(operationId) {
30000
+ const inbound = getInboundTraceContext();
30001
+ return inbound && inbound.traceId === operationId ? inbound.parentSpanId : undefined;
30002
+ }
30003
+ runWithContext(context, fn) {
30004
+ return this.contextStorage.run(context, fn);
30005
+ }
30006
+ createDependencyContext() {
30007
+ const parentContext = this.getCurrentContext();
30008
+ if (!parentContext) {
30009
+ return;
30010
+ }
30011
+ return {
30012
+ operationId: parentContext.operationId,
30013
+ parentId: parentContext.id,
30014
+ id: this.generateId()
30015
+ };
30016
+ }
30017
+ trackDependencyResult(name, type2, durationMs, success, properties, context, resultCode) {
30018
+ const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
30019
+ this.telemetryProvider.trackDependency(redactValue(name), type2, durationMs, success, enrichedProperties, resultCode);
30020
+ }
29806
30021
  async trackDependencyOperation(name, type2, fn, properties) {
29807
30022
  const parentContext = this.getCurrentContext();
29808
30023
  if (!parentContext) {
@@ -29839,8 +30054,12 @@ class TelemetryService {
29839
30054
  ...getExecutionContextTelemetryProperties(),
29840
30055
  ...globalProperties,
29841
30056
  ...this.defaultProperties,
29842
- ...properties,
29843
- ...context
30057
+ ...redactProperties(properties ?? {}),
30058
+ ...context ? {
30059
+ [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
30060
+ ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
30061
+ [TELEMETRY_SPAN_ID_PROPERTY]: context.id
30062
+ } : {}
29844
30063
  };
29845
30064
  if (sessionId === undefined) {
29846
30065
  delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
@@ -29850,7 +30069,16 @@ class TelemetryService {
29850
30069
  return enriched;
29851
30070
  }
29852
30071
  generateId() {
29853
- return crypto.randomUUID().replaceAll("-", "");
30072
+ const bytes = new Uint8Array(8);
30073
+ let hex = "";
30074
+ do {
30075
+ crypto.getRandomValues(bytes);
30076
+ hex = "";
30077
+ for (const byte of bytes) {
30078
+ hex += byte.toString(16).padStart(2, "0");
30079
+ }
30080
+ } while (/^0+$/.test(hex));
30081
+ return hex;
29854
30082
  }
29855
30083
  }
29856
30084
  // ../common/src/telemetry/node-appinsights-telemetry-provider.ts
@@ -30552,152 +30780,25 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
30552
30780
  };
30553
30781
  }
30554
30782
 
30555
- // ../common/src/telemetry/pii-redactor.ts
30556
- var REDACTED = "[REDACTED]";
30557
- var MAX_VALUE_LENGTH = 200;
30558
- var SENSITIVE_NAME_TOKENS = new Set([
30559
- "token",
30560
- "tokens",
30561
- "secret",
30562
- "secrets",
30563
- "password",
30564
- "passwords",
30565
- "pwd",
30566
- "credential",
30567
- "credentials",
30568
- "auth",
30569
- "authentication",
30570
- "authorization",
30571
- "authority",
30572
- "cert",
30573
- "certificate",
30574
- "certificates"
30575
- ]);
30576
- var SENSITIVE_KEY_PREFIXES = new Set([
30577
- "api",
30578
- "access",
30579
- "client",
30580
- "private",
30581
- "public",
30582
- "signing",
30583
- "encryption",
30584
- "session",
30585
- "master",
30586
- "shared",
30587
- "root",
30588
- "ssh",
30589
- "rsa",
30590
- "aes",
30591
- "hmac",
30592
- "oauth"
30593
- ]);
30594
- 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;
30595
- var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
30596
- var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
30597
- var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
30598
- var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
30599
- var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
30600
- var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
30601
- function shortHash(input) {
30602
- let hash = 2166136261;
30603
- for (let i = 0;i < input.length; i++) {
30604
- hash ^= input.charCodeAt(i);
30605
- hash = Math.imul(hash, 16777619);
30606
- }
30607
- return (hash >>> 0).toString(16).padStart(8, "0");
30608
- }
30609
- function redactUrl(raw) {
30610
- try {
30611
- const url = new URL(raw);
30612
- return `${url.protocol}//${url.host}`;
30613
- } catch {
30614
- return `url#${shortHash(raw)}`;
30615
- }
30616
- }
30617
- function redactValueDetectors(value) {
30618
- let out = value;
30619
- out = out.replace(JWT_PATTERN, () => REDACTED);
30620
- out = out.replace(URL_PATTERN, (match) => {
30621
- const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
30622
- const core2 = trailing ? match.slice(0, -trailing.length) : match;
30623
- return `${redactUrl(core2)}${trailing}`;
30624
- });
30625
- out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
30626
- out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
30627
- out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
30628
- out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
30629
- if (out.length > MAX_VALUE_LENGTH) {
30630
- out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
30631
- }
30632
- return out;
30633
- }
30634
- function nameTokens(name) {
30635
- 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);
30636
- }
30637
- function isSensitiveName(name) {
30638
- const tokens = nameTokens(name);
30639
- for (let i = 0;i < tokens.length; i++) {
30640
- const token = tokens[i];
30641
- if (SENSITIVE_NAME_TOKENS.has(token)) {
30642
- return true;
30643
- }
30644
- if (token === "key" || token === "keys") {
30645
- const prev = tokens[i - 1];
30646
- if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
30647
- return true;
30648
- }
30649
- }
30650
- }
30651
- return false;
30652
- }
30653
- function redactProperty(name, value) {
30654
- if (value === undefined || value === null) {
30655
- return;
30656
- }
30657
- if (isSensitiveName(name)) {
30658
- return REDACTED;
30659
- }
30660
- if (typeof value === "boolean" || typeof value === "number") {
30661
- return value;
30662
- }
30663
- if (typeof value !== "string") {
30664
- return "[OBJECT]";
30665
- }
30666
- return redactValueDetectors(value);
30667
- }
30668
- function redactProperties(properties) {
30669
- const out = {};
30670
- for (const [name, value] of Object.entries(properties)) {
30671
- const redacted = redactProperty(name, value);
30672
- if (redacted !== undefined) {
30673
- out[name] = redacted;
30674
- }
30675
- }
30676
- return out;
30677
- }
30678
-
30679
30783
  // ../common/src/trackedAction.ts
30680
30784
  var pollSignalSlot = singleton("PollSignal");
30681
30785
  var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
30682
30786
  var retryHintValues = new Set(RETRY_HINTS);
30787
+ var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
30683
30788
  function extractCommandParams(cmd) {
30684
30789
  const params = {};
30790
+ const add2 = (name, value) => {
30791
+ if (name && value !== undefined) {
30792
+ params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = value;
30793
+ }
30794
+ };
30685
30795
  const registered = cmd.registeredArguments ?? [];
30686
30796
  const processed = cmd.processedArgs ?? [];
30687
30797
  for (let i = 0;i < registered.length; i++) {
30688
- const value = processed[i];
30689
- if (value === undefined) {
30690
- continue;
30691
- }
30692
- const name = registered[i].name();
30693
- if (name) {
30694
- params[name] = value;
30695
- }
30798
+ add2(registered[i].name(), processed[i]);
30696
30799
  }
30697
30800
  for (const [key, value] of Object.entries(cmd.opts())) {
30698
- if (value !== undefined) {
30699
- params[key] = value;
30700
- }
30801
+ add2(key, value);
30701
30802
  }
30702
30803
  return params;
30703
30804
  }
@@ -30740,11 +30841,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
30740
30841
  return this.action(async (...args) => {
30741
30842
  const telemetryName = deriveCommandPath(command);
30742
30843
  const props = typeof properties === "function" ? properties(...args) : properties;
30844
+ const requestContext = telemetry.createRequestContext();
30743
30845
  const startTime = performance.now();
30744
30846
  let errorMessage;
30745
30847
  let fallbackExitCode = EXIT_CODES.Success;
30746
30848
  clearRecordedCommandFailureTelemetry();
30747
- const [error] = await catchError(fn(...args));
30849
+ const [error] = await catchError(telemetry.runWithContext(requestContext, () => fn(...args)));
30748
30850
  if (error) {
30749
30851
  errorMessage = error instanceof Error ? error.message : String(error);
30750
30852
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
@@ -30780,16 +30882,21 @@ Command.prototype.trackedAction = function(context, fn, properties) {
30780
30882
  recordedFailure,
30781
30883
  pollSignal: context.pollSignal
30782
30884
  });
30783
- telemetry.trackEvent(telemetryName, redactProperties({
30784
- ...extractCommandParams(command),
30885
+ const commandParams = extractCommandParams(command);
30886
+ if (props) {
30887
+ for (const key of Object.keys(props)) {
30888
+ delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
30889
+ }
30890
+ }
30891
+ const baseProperties = redactProperties({
30892
+ ...commandParams,
30785
30893
  ...props,
30786
30894
  ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
30787
30895
  command: "true",
30788
- duration: String(durationMs),
30789
- success: String(success),
30790
30896
  ...terminalTelemetry,
30791
30897
  ...errorMessage ? { errorMessage } : {}
30792
- }));
30898
+ });
30899
+ telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
30793
30900
  });
30794
30901
  };
30795
30902
  // ../common/src/console-guard.ts
@@ -47400,4 +47507,4 @@ export {
47400
47507
  resourceRefreshAsync
47401
47508
  };
47402
47509
 
47403
- //# debugId=D0D2A9C677D4594664756E2164756E21
47510
+ //# debugId=1E88FA462C6871EA64756E2164756E21