@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/init.js CHANGED
@@ -8821,11 +8821,36 @@ class NodeContextStorage {
8821
8821
  return this.storage.getStore();
8822
8822
  }
8823
8823
  }
8824
+ // ../common/src/telemetry/trace-context.ts
8825
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
8826
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
8827
+ function getProcessEnv() {
8828
+ return globalThis.process?.env;
8829
+ }
8830
+ function parseInboundTraceparent(value) {
8831
+ if (!value) {
8832
+ return;
8833
+ }
8834
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
8835
+ if (!match) {
8836
+ return;
8837
+ }
8838
+ const [, traceId, parentSpanId] = match;
8839
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
8840
+ return;
8841
+ }
8842
+ return { traceId, parentSpanId };
8843
+ }
8844
+ function getInboundTraceContext() {
8845
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
8846
+ }
8847
+
8824
8848
  // ../common/src/telemetry/session-id.ts
8825
8849
  var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
8826
8850
  var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
8827
8851
  var telemetrySessionIdSlot = singleton("TelemetrySessionId");
8828
- function getProcessEnv() {
8852
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
8853
+ function getProcessEnv2() {
8829
8854
  return globalThis.process?.env;
8830
8855
  }
8831
8856
  function normalizeSessionId(value) {
@@ -8836,18 +8861,165 @@ function normalizeSessionId(value) {
8836
8861
  return trimmed || undefined;
8837
8862
  }
8838
8863
  function getConfiguredTelemetrySessionId() {
8839
- return normalizeSessionId(getProcessEnv()?.[TELEMETRY_SESSION_ID_ENV]);
8864
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
8840
8865
  }
8841
8866
  function resolveTelemetrySessionId(existingSessionId) {
8842
8867
  return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
8843
8868
  }
8869
+ function getTelemetryOperationId() {
8870
+ const existing = telemetryOperationIdSlot.get();
8871
+ if (existing) {
8872
+ return existing;
8873
+ }
8874
+ const inboundTraceId = getInboundTraceContext()?.traceId;
8875
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
8876
+ telemetryOperationIdSlot.set(generated);
8877
+ return generated;
8878
+ }
8844
8879
  // ../common/src/telemetry/global-telemetry-properties.ts
8845
8880
  var telemetryPropsSlot = singleton("TelemetryDefaultProps");
8846
8881
  function getGlobalTelemetryProperties() {
8847
8882
  return telemetryPropsSlot.get();
8848
8883
  }
8849
8884
 
8885
+ // ../common/src/telemetry/pii-redactor.ts
8886
+ var REDACTED = "[REDACTED]";
8887
+ var MAX_VALUE_LENGTH = 200;
8888
+ var SENSITIVE_NAME_TOKENS = new Set([
8889
+ "token",
8890
+ "tokens",
8891
+ "secret",
8892
+ "secrets",
8893
+ "password",
8894
+ "passwords",
8895
+ "pwd",
8896
+ "credential",
8897
+ "credentials",
8898
+ "auth",
8899
+ "authentication",
8900
+ "authorization",
8901
+ "authority",
8902
+ "cert",
8903
+ "certificate",
8904
+ "certificates"
8905
+ ]);
8906
+ var SENSITIVE_KEY_PREFIXES = new Set([
8907
+ "api",
8908
+ "access",
8909
+ "client",
8910
+ "private",
8911
+ "public",
8912
+ "signing",
8913
+ "encryption",
8914
+ "session",
8915
+ "master",
8916
+ "shared",
8917
+ "root",
8918
+ "ssh",
8919
+ "rsa",
8920
+ "aes",
8921
+ "hmac",
8922
+ "oauth"
8923
+ ]);
8924
+ 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;
8925
+ var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
8926
+ var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
8927
+ var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
8928
+ var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
8929
+ var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
8930
+ var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
8931
+ function shortHash(input) {
8932
+ let hash = 2166136261;
8933
+ for (let i = 0;i < input.length; i++) {
8934
+ hash ^= input.charCodeAt(i);
8935
+ hash = Math.imul(hash, 16777619);
8936
+ }
8937
+ return (hash >>> 0).toString(16).padStart(8, "0");
8938
+ }
8939
+ function redactUrl(raw) {
8940
+ try {
8941
+ const url = new URL(raw);
8942
+ return `${url.protocol}//${url.host}`;
8943
+ } catch {
8944
+ return `url#${shortHash(raw)}`;
8945
+ }
8946
+ }
8947
+ function redactValueDetectors(value) {
8948
+ let out = value;
8949
+ out = out.replace(JWT_PATTERN, () => REDACTED);
8950
+ out = out.replace(URL_PATTERN, (match) => {
8951
+ const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
8952
+ const core2 = trailing ? match.slice(0, -trailing.length) : match;
8953
+ return `${redactUrl(core2)}${trailing}`;
8954
+ });
8955
+ out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
8956
+ out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
8957
+ out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
8958
+ out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
8959
+ if (out.length > MAX_VALUE_LENGTH) {
8960
+ out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
8961
+ }
8962
+ return out;
8963
+ }
8964
+ function redactValue(value) {
8965
+ return redactValueDetectors(value);
8966
+ }
8967
+ function redactError(error) {
8968
+ const safe = new Error(redactValueDetectors(error.message ?? ""));
8969
+ safe.name = error.name;
8970
+ safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
8971
+ return safe;
8972
+ }
8973
+ function nameTokens(name) {
8974
+ 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);
8975
+ }
8976
+ function isSensitiveName(name) {
8977
+ const tokens = nameTokens(name);
8978
+ for (let i = 0;i < tokens.length; i++) {
8979
+ const token = tokens[i];
8980
+ if (SENSITIVE_NAME_TOKENS.has(token)) {
8981
+ return true;
8982
+ }
8983
+ if (token === "key" || token === "keys") {
8984
+ const prev = tokens[i - 1];
8985
+ if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
8986
+ return true;
8987
+ }
8988
+ }
8989
+ }
8990
+ return false;
8991
+ }
8992
+ function redactProperty(name, value) {
8993
+ if (value === undefined || value === null) {
8994
+ return;
8995
+ }
8996
+ if (isSensitiveName(name)) {
8997
+ return REDACTED;
8998
+ }
8999
+ if (typeof value === "boolean" || typeof value === "number") {
9000
+ return value;
9001
+ }
9002
+ if (typeof value !== "string") {
9003
+ return "[OBJECT]";
9004
+ }
9005
+ return redactValueDetectors(value);
9006
+ }
9007
+ function redactProperties(properties) {
9008
+ const out = {};
9009
+ for (const [name, value] of Object.entries(properties)) {
9010
+ const redacted = redactProperty(name, value);
9011
+ if (redacted !== undefined) {
9012
+ out[name] = redacted;
9013
+ }
9014
+ }
9015
+ return out;
9016
+ }
9017
+
8850
9018
  // ../common/src/telemetry/telemetry-service.ts
9019
+ var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
9020
+ var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
9021
+ var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
9022
+
8851
9023
  class TelemetryService {
8852
9024
  telemetryProvider;
8853
9025
  contextStorage;
@@ -8874,11 +9046,15 @@ class TelemetryService {
8874
9046
  trackException(error, properties) {
8875
9047
  const context = this.getCurrentContext();
8876
9048
  const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
8877
- this.telemetryProvider.trackException(error, enrichedProperties);
9049
+ this.telemetryProvider.trackException(redactError(error), enrichedProperties);
8878
9050
  }
8879
9051
  async trackRequest(name, fn, properties) {
9052
+ const parentContext = this.getCurrentContext();
9053
+ const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
9054
+ const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
8880
9055
  const context = {
8881
- operationId: this.operationId ?? this.generateId(),
9056
+ operationId,
9057
+ ...parentId !== undefined ? { parentId } : {},
8882
9058
  id: this.generateId()
8883
9059
  };
8884
9060
  const startTime = performance.now();
@@ -8896,6 +9072,45 @@ class TelemetryService {
8896
9072
  throw error;
8897
9073
  }
8898
9074
  }
9075
+ trackRequestResult(name, durationMs, success, properties, context) {
9076
+ const requestContext = context ?? {
9077
+ operationId: this.operationId ?? getTelemetryOperationId(),
9078
+ id: this.generateId()
9079
+ };
9080
+ const enrichedProperties = this.enrichPropertiesWithContext(properties, requestContext);
9081
+ this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
9082
+ }
9083
+ createRequestContext() {
9084
+ const operationId = this.operationId ?? getTelemetryOperationId();
9085
+ const parentId = this.inboundParentIdFor(operationId);
9086
+ return {
9087
+ operationId,
9088
+ ...parentId !== undefined ? { parentId } : {},
9089
+ id: this.generateId()
9090
+ };
9091
+ }
9092
+ inboundParentIdFor(operationId) {
9093
+ const inbound = getInboundTraceContext();
9094
+ return inbound && inbound.traceId === operationId ? inbound.parentSpanId : undefined;
9095
+ }
9096
+ runWithContext(context, fn) {
9097
+ return this.contextStorage.run(context, fn);
9098
+ }
9099
+ createDependencyContext() {
9100
+ const parentContext = this.getCurrentContext();
9101
+ if (!parentContext) {
9102
+ return;
9103
+ }
9104
+ return {
9105
+ operationId: parentContext.operationId,
9106
+ parentId: parentContext.id,
9107
+ id: this.generateId()
9108
+ };
9109
+ }
9110
+ trackDependencyResult(name, type2, durationMs, success, properties, context, resultCode) {
9111
+ const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
9112
+ this.telemetryProvider.trackDependency(redactValue(name), type2, durationMs, success, enrichedProperties, resultCode);
9113
+ }
8899
9114
  async trackDependencyOperation(name, type2, fn, properties) {
8900
9115
  const parentContext = this.getCurrentContext();
8901
9116
  if (!parentContext) {
@@ -8932,8 +9147,12 @@ class TelemetryService {
8932
9147
  ...getExecutionContextTelemetryProperties(),
8933
9148
  ...globalProperties,
8934
9149
  ...this.defaultProperties,
8935
- ...properties,
8936
- ...context
9150
+ ...redactProperties(properties ?? {}),
9151
+ ...context ? {
9152
+ [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
9153
+ ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
9154
+ [TELEMETRY_SPAN_ID_PROPERTY]: context.id
9155
+ } : {}
8937
9156
  };
8938
9157
  if (sessionId === undefined) {
8939
9158
  delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
@@ -8943,7 +9162,16 @@ class TelemetryService {
8943
9162
  return enriched;
8944
9163
  }
8945
9164
  generateId() {
8946
- return crypto.randomUUID().replaceAll("-", "");
9165
+ const bytes = new Uint8Array(8);
9166
+ let hex = "";
9167
+ do {
9168
+ crypto.getRandomValues(bytes);
9169
+ hex = "";
9170
+ for (const byte of bytes) {
9171
+ hex += byte.toString(16).padStart(2, "0");
9172
+ }
9173
+ } while (/^0+$/.test(hex));
9174
+ return hex;
8947
9175
  }
8948
9176
  }
8949
9177
  // ../common/src/telemetry/node-appinsights-telemetry-provider.ts
@@ -9645,152 +9873,25 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
9645
9873
  };
9646
9874
  }
9647
9875
 
9648
- // ../common/src/telemetry/pii-redactor.ts
9649
- var REDACTED = "[REDACTED]";
9650
- var MAX_VALUE_LENGTH = 200;
9651
- var SENSITIVE_NAME_TOKENS = new Set([
9652
- "token",
9653
- "tokens",
9654
- "secret",
9655
- "secrets",
9656
- "password",
9657
- "passwords",
9658
- "pwd",
9659
- "credential",
9660
- "credentials",
9661
- "auth",
9662
- "authentication",
9663
- "authorization",
9664
- "authority",
9665
- "cert",
9666
- "certificate",
9667
- "certificates"
9668
- ]);
9669
- var SENSITIVE_KEY_PREFIXES = new Set([
9670
- "api",
9671
- "access",
9672
- "client",
9673
- "private",
9674
- "public",
9675
- "signing",
9676
- "encryption",
9677
- "session",
9678
- "master",
9679
- "shared",
9680
- "root",
9681
- "ssh",
9682
- "rsa",
9683
- "aes",
9684
- "hmac",
9685
- "oauth"
9686
- ]);
9687
- 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;
9688
- var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
9689
- var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
9690
- var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
9691
- var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
9692
- var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
9693
- var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
9694
- function shortHash(input) {
9695
- let hash = 2166136261;
9696
- for (let i = 0;i < input.length; i++) {
9697
- hash ^= input.charCodeAt(i);
9698
- hash = Math.imul(hash, 16777619);
9699
- }
9700
- return (hash >>> 0).toString(16).padStart(8, "0");
9701
- }
9702
- function redactUrl(raw) {
9703
- try {
9704
- const url = new URL(raw);
9705
- return `${url.protocol}//${url.host}`;
9706
- } catch {
9707
- return `url#${shortHash(raw)}`;
9708
- }
9709
- }
9710
- function redactValueDetectors(value) {
9711
- let out = value;
9712
- out = out.replace(JWT_PATTERN, () => REDACTED);
9713
- out = out.replace(URL_PATTERN, (match) => {
9714
- const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
9715
- const core2 = trailing ? match.slice(0, -trailing.length) : match;
9716
- return `${redactUrl(core2)}${trailing}`;
9717
- });
9718
- out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
9719
- out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
9720
- out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
9721
- out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
9722
- if (out.length > MAX_VALUE_LENGTH) {
9723
- out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
9724
- }
9725
- return out;
9726
- }
9727
- function nameTokens(name) {
9728
- 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);
9729
- }
9730
- function isSensitiveName(name) {
9731
- const tokens = nameTokens(name);
9732
- for (let i = 0;i < tokens.length; i++) {
9733
- const token = tokens[i];
9734
- if (SENSITIVE_NAME_TOKENS.has(token)) {
9735
- return true;
9736
- }
9737
- if (token === "key" || token === "keys") {
9738
- const prev = tokens[i - 1];
9739
- if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
9740
- return true;
9741
- }
9742
- }
9743
- }
9744
- return false;
9745
- }
9746
- function redactProperty(name, value) {
9747
- if (value === undefined || value === null) {
9748
- return;
9749
- }
9750
- if (isSensitiveName(name)) {
9751
- return REDACTED;
9752
- }
9753
- if (typeof value === "boolean" || typeof value === "number") {
9754
- return value;
9755
- }
9756
- if (typeof value !== "string") {
9757
- return "[OBJECT]";
9758
- }
9759
- return redactValueDetectors(value);
9760
- }
9761
- function redactProperties(properties) {
9762
- const out = {};
9763
- for (const [name, value] of Object.entries(properties)) {
9764
- const redacted = redactProperty(name, value);
9765
- if (redacted !== undefined) {
9766
- out[name] = redacted;
9767
- }
9768
- }
9769
- return out;
9770
- }
9771
-
9772
9876
  // ../common/src/trackedAction.ts
9773
9877
  var pollSignalSlot = singleton("PollSignal");
9774
9878
  var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
9775
9879
  var retryHintValues = new Set(RETRY_HINTS);
9880
+ var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
9776
9881
  function extractCommandParams(cmd) {
9777
9882
  const params = {};
9883
+ const add2 = (name, value) => {
9884
+ if (name && value !== undefined) {
9885
+ params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = value;
9886
+ }
9887
+ };
9778
9888
  const registered = cmd.registeredArguments ?? [];
9779
9889
  const processed = cmd.processedArgs ?? [];
9780
9890
  for (let i = 0;i < registered.length; i++) {
9781
- const value = processed[i];
9782
- if (value === undefined) {
9783
- continue;
9784
- }
9785
- const name = registered[i].name();
9786
- if (name) {
9787
- params[name] = value;
9788
- }
9891
+ add2(registered[i].name(), processed[i]);
9789
9892
  }
9790
9893
  for (const [key, value] of Object.entries(cmd.opts())) {
9791
- if (value !== undefined) {
9792
- params[key] = value;
9793
- }
9894
+ add2(key, value);
9794
9895
  }
9795
9896
  return params;
9796
9897
  }
@@ -9833,11 +9934,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
9833
9934
  return this.action(async (...args) => {
9834
9935
  const telemetryName = deriveCommandPath(command);
9835
9936
  const props = typeof properties === "function" ? properties(...args) : properties;
9937
+ const requestContext = telemetry.createRequestContext();
9836
9938
  const startTime = performance.now();
9837
9939
  let errorMessage;
9838
9940
  let fallbackExitCode = EXIT_CODES.Success;
9839
9941
  clearRecordedCommandFailureTelemetry();
9840
- const [error] = await catchError(fn(...args));
9942
+ const [error] = await catchError(telemetry.runWithContext(requestContext, () => fn(...args)));
9841
9943
  if (error) {
9842
9944
  errorMessage = error instanceof Error ? error.message : String(error);
9843
9945
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
@@ -9873,16 +9975,21 @@ Command.prototype.trackedAction = function(context, fn, properties) {
9873
9975
  recordedFailure,
9874
9976
  pollSignal: context.pollSignal
9875
9977
  });
9876
- telemetry.trackEvent(telemetryName, redactProperties({
9877
- ...extractCommandParams(command),
9978
+ const commandParams = extractCommandParams(command);
9979
+ if (props) {
9980
+ for (const key of Object.keys(props)) {
9981
+ delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
9982
+ }
9983
+ }
9984
+ const baseProperties = redactProperties({
9985
+ ...commandParams,
9878
9986
  ...props,
9879
9987
  ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
9880
9988
  command: "true",
9881
- duration: String(durationMs),
9882
- success: String(success),
9883
9989
  ...terminalTelemetry,
9884
9990
  ...errorMessage ? { errorMessage } : {}
9885
- }));
9991
+ });
9992
+ telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
9886
9993
  });
9887
9994
  };
9888
9995
  // ../common/src/console-guard.ts
@@ -10017,4 +10124,4 @@ export {
10017
10124
  SolutionInitError
10018
10125
  };
10019
10126
 
10020
- //# debugId=7F86F31E38ADC50064756E2164756E21
10127
+ //# debugId=B4DE82653D2B978664756E2164756E21