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