@uipath/common 1.197.0-preview.65 → 1.197.0-preview.67

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/index.js CHANGED
@@ -8476,9 +8476,231 @@ function getOutputFilter() {
8476
8476
  return filterSlot.get();
8477
8477
  }
8478
8478
 
8479
+ // src/telemetry/command-terminal.ts
8480
+ var recordedFailureSlot = singleton("CommandTelemetryFailure");
8481
+ var AUTH_ERROR_CODES = new Set([
8482
+ "authentication_required",
8483
+ "permission_denied"
8484
+ ]);
8485
+ var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
8486
+ var NETWORK_HTTP_ERROR_CODES = new Set([
8487
+ "network_error",
8488
+ "rate_limited",
8489
+ "server_error",
8490
+ "not_found",
8491
+ "method_not_allowed"
8492
+ ]);
8493
+ var TIMEOUT_ERROR_CODES = new Set(["timeout"]);
8494
+ var NETWORK_OS_ERROR_CODES = new Set([
8495
+ "ECONNREFUSED",
8496
+ "ECONNRESET",
8497
+ "ENOTFOUND",
8498
+ "EAI_AGAIN",
8499
+ "EPIPE",
8500
+ "EHOSTUNREACH",
8501
+ "ENETUNREACH",
8502
+ "EAI_FAIL"
8503
+ ]);
8504
+ var TIMEOUT_OS_ERROR_CODES = new Set(["ETIMEDOUT", "ESOCKETTIMEDOUT"]);
8505
+ var TLS_ERROR_CODES2 = new Set([
8506
+ "SELF_SIGNED_CERT_IN_CHAIN",
8507
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
8508
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
8509
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
8510
+ "UNABLE_TO_GET_ISSUER_CERT",
8511
+ "CERT_HAS_EXPIRED",
8512
+ "CERT_UNTRUSTED",
8513
+ "ERR_TLS_CERT_ALTNAME_INVALID"
8514
+ ]);
8515
+ var MISSING_DEPENDENCY_CODES = new Set([
8516
+ "MODULE_NOT_FOUND",
8517
+ "ERR_MODULE_NOT_FOUND"
8518
+ ]);
8519
+ var INTERNAL_ERROR_NAMES = new Set([
8520
+ "TypeError",
8521
+ "ReferenceError",
8522
+ "SyntaxError",
8523
+ "RangeError"
8524
+ ]);
8525
+ function isRecord(value) {
8526
+ return value !== null && typeof value === "object";
8527
+ }
8528
+ function stringField(value, field) {
8529
+ if (!isRecord(value)) {
8530
+ return;
8531
+ }
8532
+ const raw = value[field];
8533
+ return typeof raw === "string" ? raw : undefined;
8534
+ }
8535
+ function numberField(value, field) {
8536
+ if (!isRecord(value)) {
8537
+ return;
8538
+ }
8539
+ const raw = value[field];
8540
+ return typeof raw === "number" ? raw : undefined;
8541
+ }
8542
+ function findStringInCauseChain(error, field) {
8543
+ let current = error;
8544
+ for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
8545
+ const value = stringField(current, field);
8546
+ if (value) {
8547
+ return value;
8548
+ }
8549
+ current = current.cause;
8550
+ }
8551
+ return;
8552
+ }
8553
+ function findCodeInCauseChain(error) {
8554
+ return findStringInCauseChain(error, "code");
8555
+ }
8556
+ function isSpawnEnoent(error) {
8557
+ const code = findCodeInCauseChain(error);
8558
+ if (code !== "ENOENT") {
8559
+ return false;
8560
+ }
8561
+ const syscall = findStringInCauseChain(error, "syscall");
8562
+ return syscall?.startsWith("spawn") === true;
8563
+ }
8564
+ function isCancellationError(error, exitCode, pollSignal) {
8565
+ if (exitCode === 130) {
8566
+ return true;
8567
+ }
8568
+ if (!isRecord(error)) {
8569
+ return false;
8570
+ }
8571
+ if (numberField(error, "exitCode") === 130) {
8572
+ return true;
8573
+ }
8574
+ const name = stringField(error, "name");
8575
+ if (name === "ExitPromptError") {
8576
+ return true;
8577
+ }
8578
+ if (name === "AbortError" && pollSignal?.aborted) {
8579
+ return true;
8580
+ }
8581
+ const message = stringField(error, "message");
8582
+ return message?.includes("SIGINT") === true;
8583
+ }
8584
+ function terminalSignalFor(input, outcome) {
8585
+ if (input.recordedFailure?.terminalSignal) {
8586
+ return input.recordedFailure.terminalSignal;
8587
+ }
8588
+ const explicit = findStringInCauseChain(input.error, "terminalSignal") ?? findStringInCauseChain(input.error, "signal");
8589
+ if (explicit) {
8590
+ return explicit;
8591
+ }
8592
+ return outcome === "cancelled" ? "SIGINT" : undefined;
8593
+ }
8594
+ function classifyHttpStatus(status) {
8595
+ if (status === 401 || status === 403) {
8596
+ return "auth";
8597
+ }
8598
+ if (status === 400 || status === 409 || status === 422) {
8599
+ return "validation";
8600
+ }
8601
+ if (status === 408) {
8602
+ return "timeout";
8603
+ }
8604
+ return "network_http";
8605
+ }
8606
+ function classifyFromResult(result) {
8607
+ switch (result) {
8608
+ case "AuthenticationError":
8609
+ return "auth";
8610
+ case "ValidationError":
8611
+ return "validation";
8612
+ case "TimeoutError":
8613
+ return "timeout";
8614
+ default:
8615
+ return;
8616
+ }
8617
+ }
8618
+ function classifyFromErrorCode(errorCode) {
8619
+ if (!errorCode) {
8620
+ return;
8621
+ }
8622
+ if (AUTH_ERROR_CODES.has(errorCode)) {
8623
+ return "auth";
8624
+ }
8625
+ if (VALIDATION_ERROR_CODES.has(errorCode)) {
8626
+ return "validation";
8627
+ }
8628
+ if (TIMEOUT_ERROR_CODES.has(errorCode)) {
8629
+ return "timeout";
8630
+ }
8631
+ if (NETWORK_HTTP_ERROR_CODES.has(errorCode)) {
8632
+ return "network_http";
8633
+ }
8634
+ return;
8635
+ }
8636
+ function classifyFromError(error) {
8637
+ const code = findCodeInCauseChain(error);
8638
+ if (code) {
8639
+ if (code.startsWith("commander.")) {
8640
+ return "validation";
8641
+ }
8642
+ if (NETWORK_OS_ERROR_CODES.has(code) || TLS_ERROR_CODES2.has(code)) {
8643
+ return "network_http";
8644
+ }
8645
+ if (TIMEOUT_OS_ERROR_CODES.has(code)) {
8646
+ return "timeout";
8647
+ }
8648
+ if (MISSING_DEPENDENCY_CODES.has(code) || isSpawnEnoent(error)) {
8649
+ return "missing_dependency";
8650
+ }
8651
+ }
8652
+ const message = stringField(error, "message");
8653
+ if (message?.includes("fetch failed") === true) {
8654
+ return "network_http";
8655
+ }
8656
+ const name = stringField(error, "name");
8657
+ if (name && INTERNAL_ERROR_NAMES.has(name)) {
8658
+ return "internal";
8659
+ }
8660
+ return;
8661
+ }
8662
+ function classifyError2(input) {
8663
+ const recorded = input.recordedFailure;
8664
+ if (recorded?.errorClass) {
8665
+ return recorded.errorClass;
8666
+ }
8667
+ const status = recorded?.context?.httpStatus;
8668
+ if (status !== undefined) {
8669
+ return classifyHttpStatus(status);
8670
+ }
8671
+ return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
8672
+ }
8673
+ function recordCommandFailureTelemetry(failure) {
8674
+ recordedFailureSlot.set(failure);
8675
+ }
8676
+ function getRecordedCommandFailureTelemetry() {
8677
+ return recordedFailureSlot.get();
8678
+ }
8679
+ function clearRecordedCommandFailureTelemetry() {
8680
+ recordedFailureSlot.clear();
8681
+ }
8682
+ function takeRecordedCommandFailureTelemetry() {
8683
+ const failure = recordedFailureSlot.get();
8684
+ recordedFailureSlot.clear();
8685
+ return failure;
8686
+ }
8687
+ function buildCommandTerminalTelemetryProperties(input) {
8688
+ const cancelled = isCancellationError(input.error, input.exitCode, input.pollSignal);
8689
+ const outcome = input.recordedFailure?.terminalOutcome ?? (input.exitCode === 0 ? "success" : cancelled ? "cancelled" : "failure");
8690
+ const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError2(input);
8691
+ const terminalSignal = terminalSignalFor(input, outcome);
8692
+ return {
8693
+ exit_code: input.exitCode,
8694
+ terminal_outcome: outcome,
8695
+ ...errorClass ? { error_class: errorClass } : {},
8696
+ ...terminalSignal ? { terminal_signal: terminalSignal } : {}
8697
+ };
8698
+ }
8699
+
8479
8700
  // src/telemetry/telemetry-events.ts
8480
8701
  var CommonTelemetryEvents = {
8481
- Error: "uip.error"
8702
+ Error: "uip.error",
8703
+ ShipSucceeded: "ship_succeeded"
8482
8704
  };
8483
8705
 
8484
8706
  // src/registry.ts
@@ -8572,8 +8794,22 @@ var KNOWN_AGENTS = [
8572
8794
  { envVar: "CLINE_ACTIVE", value: "true", id: "cline" }
8573
8795
  ];
8574
8796
  function detectAgent() {
8797
+ return detectAgentFromEnv(process.env);
8798
+ }
8799
+ var AI_AGENT_PATTERN = /^[a-z0-9-]+_([0-9]+(?:-[0-9]+)*)_agent$/;
8800
+ function detectAgentVersion() {
8801
+ return detectAgentVersionFromEnv(process.env);
8802
+ }
8803
+ function detectAgentVersionFromEnv(env) {
8804
+ const raw = env.AI_AGENT;
8805
+ if (!raw || raw.length > 64)
8806
+ return;
8807
+ const version = AI_AGENT_PATTERN.exec(raw)?.[1];
8808
+ return version?.replace(/-/g, ".");
8809
+ }
8810
+ function detectAgentFromEnv(env) {
8575
8811
  for (const agent of KNOWN_AGENTS) {
8576
- const envValue = process.env[agent.envVar];
8812
+ const envValue = env[agent.envVar];
8577
8813
  if (agent.value !== undefined) {
8578
8814
  if (envValue === agent.value)
8579
8815
  return agent.id;
@@ -8582,7 +8818,7 @@ function detectAgent() {
8582
8818
  return agent.id;
8583
8819
  }
8584
8820
  }
8585
- const agentEnv = process.env.AGENT;
8821
+ const agentEnv = env.AGENT;
8586
8822
  if (agentEnv) {
8587
8823
  if (agentEnv === "1" || agentEnv === "true")
8588
8824
  return "unknown";
@@ -8591,6 +8827,172 @@ function detectAgent() {
8591
8827
  }
8592
8828
  return;
8593
8829
  }
8830
+ // src/telemetry/environment-info.ts
8831
+ var LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
8832
+ function parseHost(baseUrl) {
8833
+ if (!baseUrl)
8834
+ return;
8835
+ try {
8836
+ return new URL(baseUrl).hostname.toLowerCase();
8837
+ } catch {
8838
+ return;
8839
+ }
8840
+ }
8841
+ function normalizeEnvironment(baseUrl) {
8842
+ const host = parseHost(baseUrl);
8843
+ if (!host)
8844
+ return "unknown";
8845
+ if (LOCAL_HOSTS.has(host) || host.endsWith(".local"))
8846
+ return "local";
8847
+ if (host.includes("alpha"))
8848
+ return "alpha";
8849
+ if (host.includes("staging") || host.includes("stage"))
8850
+ return "staging";
8851
+ if (host === "cloud.uipath.com" || host.endsWith(".uipath.us")) {
8852
+ return "prod";
8853
+ }
8854
+ return "unknown";
8855
+ }
8856
+ function normalizeBaseUrl(baseUrl) {
8857
+ if (!baseUrl)
8858
+ return;
8859
+ try {
8860
+ return new URL(baseUrl).origin;
8861
+ } catch {
8862
+ return;
8863
+ }
8864
+ }
8865
+ function deriveRegion(baseUrl) {
8866
+ const host = parseHost(baseUrl);
8867
+ if (host?.endsWith(".uipath.us"))
8868
+ return "gov";
8869
+ return;
8870
+ }
8871
+ function buildEnvironmentProperties(baseUrl) {
8872
+ const props = {
8873
+ environment: normalizeEnvironment(baseUrl)
8874
+ };
8875
+ const normalized = normalizeBaseUrl(baseUrl);
8876
+ if (normalized)
8877
+ props.base_url = normalized;
8878
+ const region = deriveRegion(baseUrl);
8879
+ if (region)
8880
+ props.region = region;
8881
+ return props;
8882
+ }
8883
+ // src/telemetry/execution-context.ts
8884
+ var EXECUTION_CONTEXT_VALUES = [
8885
+ "manual",
8886
+ "agent",
8887
+ "ci",
8888
+ "scheduler",
8889
+ "service_account",
8890
+ "unknown"
8891
+ ];
8892
+ var authSignalSlot = singleton("TelemetryExecutionContextAuthSignal");
8893
+ var isTruthy = (value) => value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
8894
+ var isEqual = (value, expected) => value?.toLowerCase() === expected;
8895
+ var CI_SIGNATURES = [
8896
+ {
8897
+ provider: "github_actions",
8898
+ matches: (env) => isTruthy(env.GITHUB_ACTIONS),
8899
+ isScheduler: (env) => env.GITHUB_EVENT_NAME === "schedule"
8900
+ },
8901
+ {
8902
+ provider: "azure_devops",
8903
+ matches: (env) => isTruthy(env.TF_BUILD),
8904
+ isScheduler: (env) => isEqual(env.BUILD_REASON, "schedule")
8905
+ },
8906
+ {
8907
+ provider: "gitlab",
8908
+ matches: (env) => isTruthy(env.GITLAB_CI),
8909
+ isScheduler: (env) => env.CI_PIPELINE_SOURCE === "schedule"
8910
+ },
8911
+ {
8912
+ provider: "circleci",
8913
+ matches: (env) => isTruthy(env.CIRCLECI),
8914
+ isScheduler: (env) => env.CIRCLE_PIPELINE_TRIGGER_SOURCE === "scheduled_pipeline"
8915
+ },
8916
+ {
8917
+ provider: "jenkins",
8918
+ matches: (env) => isTruthy(env.JENKINS_URL) || isTruthy(env.JENKINS_HOME)
8919
+ },
8920
+ {
8921
+ provider: "teamcity",
8922
+ matches: (env) => isTruthy(env.TEAMCITY_VERSION)
8923
+ },
8924
+ {
8925
+ provider: "buildkite",
8926
+ matches: (env) => isTruthy(env.BUILDKITE),
8927
+ isScheduler: (env) => env.BUILDKITE_SOURCE === "schedule"
8928
+ },
8929
+ {
8930
+ provider: "bitbucket",
8931
+ matches: (env) => isTruthy(env.BITBUCKET_BUILD_NUMBER)
8932
+ },
8933
+ {
8934
+ provider: "travis",
8935
+ matches: (env) => isTruthy(env.TRAVIS)
8936
+ },
8937
+ {
8938
+ provider: "appveyor",
8939
+ matches: (env) => isTruthy(env.APPVEYOR)
8940
+ },
8941
+ {
8942
+ provider: "generic",
8943
+ matches: (env) => isTruthy(env.CI)
8944
+ }
8945
+ ];
8946
+ function currentEnv() {
8947
+ return typeof process === "undefined" ? {} : process.env;
8948
+ }
8949
+ function currentTtyState() {
8950
+ if (typeof process === "undefined")
8951
+ return false;
8952
+ return Boolean(process.stdout?.isTTY || process.stdin?.isTTY || process.stderr?.isTTY);
8953
+ }
8954
+ function detectCi(env) {
8955
+ const signature = CI_SIGNATURES.find((candidate) => candidate.matches(env));
8956
+ if (!signature)
8957
+ return;
8958
+ return {
8959
+ executionContext: signature.isScheduler?.(env) ? "scheduler" : "ci",
8960
+ ciProvider: signature.provider
8961
+ };
8962
+ }
8963
+ function setExecutionContextAuthSignal(signal) {
8964
+ if (signal === undefined) {
8965
+ authSignalSlot.clear();
8966
+ return;
8967
+ }
8968
+ authSignalSlot.set(signal);
8969
+ }
8970
+ function detectExecutionContext(options = {}) {
8971
+ const env = options.env ?? currentEnv();
8972
+ const ci = detectCi(env);
8973
+ if (ci)
8974
+ return ci;
8975
+ const agent = options.agent ?? detectAgentFromEnv(env);
8976
+ if (agent) {
8977
+ return { executionContext: "agent" };
8978
+ }
8979
+ const authSignal = options.authSignal ?? authSignalSlot.get();
8980
+ if (authSignal === "service_account") {
8981
+ return { executionContext: "service_account" };
8982
+ }
8983
+ const isTty = options.isTty ?? currentTtyState();
8984
+ if (isTty) {
8985
+ return { executionContext: "manual" };
8986
+ }
8987
+ return { executionContext: "unknown" };
8988
+ }
8989
+ function getExecutionContextTelemetryProperties() {
8990
+ const detected = detectExecutionContext();
8991
+ return {
8992
+ execution_context: detected.executionContext,
8993
+ ...detected.ciProvider ? { ci_provider: detected.ciProvider } : {}
8994
+ };
8995
+ }
8594
8996
  // src/telemetry/node-context-storage.ts
8595
8997
  import { AsyncLocalStorage } from "node:async_hooks";
8596
8998
 
@@ -8603,6 +9005,39 @@ class NodeContextStorage {
8603
9005
  return this.storage.getStore();
8604
9006
  }
8605
9007
  }
9008
+ // src/telemetry/session-id.ts
9009
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
9010
+ var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
9011
+ var telemetrySessionIdSlot = singleton("TelemetrySessionId");
9012
+ function getProcessEnv() {
9013
+ return globalThis.process?.env;
9014
+ }
9015
+ function normalizeSessionId(value) {
9016
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
9017
+ return;
9018
+ }
9019
+ const trimmed = String(value).trim();
9020
+ return trimmed || undefined;
9021
+ }
9022
+ function getConfiguredTelemetrySessionId() {
9023
+ return normalizeSessionId(getProcessEnv()?.[TELEMETRY_SESSION_ID_ENV]);
9024
+ }
9025
+ function getTelemetrySessionId() {
9026
+ const envSessionId = getConfiguredTelemetrySessionId();
9027
+ if (envSessionId) {
9028
+ return envSessionId;
9029
+ }
9030
+ const existing = telemetrySessionIdSlot.get();
9031
+ if (existing) {
9032
+ return existing;
9033
+ }
9034
+ const generated = crypto.randomUUID();
9035
+ telemetrySessionIdSlot.set(generated);
9036
+ return generated;
9037
+ }
9038
+ function resolveTelemetrySessionId(existingSessionId) {
9039
+ return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
9040
+ }
8606
9041
  // src/telemetry/global-telemetry-properties.ts
8607
9042
  var telemetryPropsSlot = singleton("TelemetryDefaultProps");
8608
9043
  function setGlobalTelemetryProperties(properties) {
@@ -8691,12 +9126,22 @@ class TelemetryService {
8691
9126
  return this.contextStorage.getContext();
8692
9127
  }
8693
9128
  enrichPropertiesWithContext(properties, context) {
8694
- return {
8695
- ...getGlobalTelemetryProperties(),
9129
+ const globalProperties = getGlobalTelemetryProperties();
9130
+ const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
9131
+ const sessionId = resolveTelemetrySessionId(existingSessionId);
9132
+ const enriched = {
9133
+ ...getExecutionContextTelemetryProperties(),
9134
+ ...globalProperties,
8696
9135
  ...this.defaultProperties,
8697
9136
  ...properties,
8698
9137
  ...context
8699
9138
  };
9139
+ if (sessionId === undefined) {
9140
+ delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
9141
+ } else {
9142
+ enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
9143
+ }
9144
+ return enriched;
8700
9145
  }
8701
9146
  generateId() {
8702
9147
  return crypto.randomUUID().replaceAll("-", "");
@@ -8711,7 +9156,7 @@ function toOperationUrn(name) {
8711
9156
  const sanitized = encodeURIComponent(name).replace(/%2F/g, "/");
8712
9157
  return `urn:uip:${sanitized}`;
8713
9158
  }
8714
- function isRecord(value) {
9159
+ function isRecord2(value) {
8715
9160
  return value !== null && typeof value === "object";
8716
9161
  }
8717
9162
  function formatFlushJsonError(error) {
@@ -8719,7 +9164,7 @@ function formatFlushJsonError(error) {
8719
9164
  return error.message;
8720
9165
  if (typeof error === "string")
8721
9166
  return error;
8722
- if (!isRecord(error))
9167
+ if (!isRecord2(error))
8723
9168
  return String(error);
8724
9169
  const parts = [];
8725
9170
  if (error.index !== undefined) {
@@ -8761,7 +9206,7 @@ function normalizeFlushCallbackError(response) {
8761
9206
  return;
8762
9207
  const [parseError, parsed] = catchError(() => JSON.parse(text));
8763
9208
  if (!parseError) {
8764
- const errors = isRecord(parsed) ? parsed.errors : undefined;
9209
+ const errors = isRecord2(parsed) ? parsed.errors : undefined;
8765
9210
  if (Array.isArray(errors) && errors.length > 0) {
8766
9211
  return errors.map(formatFlushJsonError).join("; ");
8767
9212
  }
@@ -8813,7 +9258,7 @@ class NodeAppInsightsTelemetryProvider {
8813
9258
  initialized = false;
8814
9259
  constructor(connectionString) {
8815
9260
  this.connectionString = connectionString;
8816
- this._sessionId = crypto.randomUUID();
9261
+ this._sessionId = getTelemetrySessionId();
8817
9262
  }
8818
9263
  async initialize() {
8819
9264
  if (this.initialized)
@@ -9178,6 +9623,9 @@ class FailureOutput {
9178
9623
  Log;
9179
9624
  Data;
9180
9625
  SuppressTelemetry;
9626
+ TelemetryErrorClass;
9627
+ TelemetryTerminalOutcome;
9628
+ TelemetryTerminalSignal;
9181
9629
  constructor(result, message, instructions, context, errorCode, retry) {
9182
9630
  this.Result = result;
9183
9631
  this.Message = message;
@@ -9585,8 +10033,24 @@ var OutputFormatter;
9585
10033
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
9586
10034
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
9587
10035
  process.exitCode = EXIT_CODES[data.Result] ?? 1;
9588
- const { SuppressTelemetry, ...envelope } = data;
9589
- if (!SuppressTelemetry) {
10036
+ recordCommandFailureTelemetry({
10037
+ result: data.Result,
10038
+ errorCode: data.ErrorCode,
10039
+ retry: data.Retry,
10040
+ message: data.Message,
10041
+ context: data.Context,
10042
+ exitCode: process.exitCode,
10043
+ errorClass: data.TelemetryErrorClass,
10044
+ terminalOutcome: data.TelemetryTerminalOutcome,
10045
+ terminalSignal: data.TelemetryTerminalSignal
10046
+ });
10047
+ const suppressTelemetry = data.SuppressTelemetry === true;
10048
+ const envelope = { ...data };
10049
+ delete envelope.SuppressTelemetry;
10050
+ delete envelope.TelemetryErrorClass;
10051
+ delete envelope.TelemetryTerminalOutcome;
10052
+ delete envelope.TelemetryTerminalSignal;
10053
+ if (!suppressTelemetry) {
9590
10054
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
9591
10055
  result: data.Result,
9592
10056
  errorCode: data.ErrorCode,
@@ -9649,6 +10113,173 @@ var OutputFormatter;
9649
10113
  OutputFormatter.formatToString = formatToString;
9650
10114
  })(OutputFormatter ||= {});
9651
10115
 
10116
+ // src/telemetry/command-attribution.ts
10117
+ var LEGACY_SKILL_NAMESPACE = "uipath:";
10118
+ var MAX_SKILL_NAME_LENGTH = 80;
10119
+ var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
10120
+ function productMode(productArea, mode) {
10121
+ return { product_area: productArea, mode };
10122
+ }
10123
+ function attributionRecord(groups) {
10124
+ const record = {};
10125
+ for (const [productArea, mode, names] of groups) {
10126
+ const attribution = productMode(productArea, mode);
10127
+ for (const name of names) {
10128
+ record[name] = attribution;
10129
+ }
10130
+ }
10131
+ return record;
10132
+ }
10133
+ function commandAttribution(groups) {
10134
+ const entries = [];
10135
+ for (const [productArea, mode, prefixes] of groups) {
10136
+ const attribution = productMode(productArea, mode);
10137
+ for (const prefix of prefixes) {
10138
+ entries.push({ prefix, attribution });
10139
+ }
10140
+ }
10141
+ return entries;
10142
+ }
10143
+ var SKILL_ATTRIBUTION = attributionRecord([
10144
+ ["admin", "operate", ["uipath-admin"]],
10145
+ ["agents", "build", ["uipath-agents"]],
10146
+ ["api-workflow", "build", ["uipath-api-workflow"]],
10147
+ ["automation-discovery", "build", ["uipath-automation-discovery"]],
10148
+ ["coded-apps", "build", ["uipath-coded-apps"]],
10149
+ ["data-fabric", "operate", ["uipath-data-fabric"]],
10150
+ ["cli", "troubleshoot", ["uipath-feedback"]],
10151
+ ["governance", "operate", ["uipath-governance"]],
10152
+ ["action-center", "build", ["uipath-human-in-the-loop"]],
10153
+ ["document-understanding", "build", ["uipath-ixp"]],
10154
+ [
10155
+ "maestro",
10156
+ "build",
10157
+ ["uipath-maestro-bpmn", "uipath-maestro-case", "uipath-maestro-flow"]
10158
+ ],
10159
+ ["agenthub", "build", ["uipath-mcp-servers"]],
10160
+ ["solution", "build", ["uipath-planner", "uipath-solution"]],
10161
+ ["platform", "operate", ["uipath-platform"]],
10162
+ ["quality", "troubleshoot", ["uipath-review"]],
10163
+ ["rpa", "build", ["uipath-rpa"]],
10164
+ ["cli", "operate", ["uipath-skill-catalog"]],
10165
+ ["action-center", "operate", ["uipath-tasks"]],
10166
+ ["test-manager", "operate", ["uipath-test"]],
10167
+ ["platform", "troubleshoot", ["uipath-troubleshoot"]]
10168
+ ]);
10169
+ var KNOWN_SKILL_NAMES = new Set(Object.keys(SKILL_ATTRIBUTION));
10170
+ var COMMAND_ATTRIBUTION = commandAttribution([
10171
+ ["cli", "troubleshoot", ["uip.feedback"]],
10172
+ ["llm-gateway", "operate", ["uip.llm-configuration", "uip.model-hub"]],
10173
+ ["context-grounding", "build", ["uip.context-grounding"]],
10174
+ ["api-workflow", "build", ["uip.api-workflow"]],
10175
+ ["rpa", "build", ["uip.rpa-legacy"]],
10176
+ ["conversational", "operate", ["uip.conversational"]],
10177
+ ["agents", "build", ["uip.codedagent", "uip.agent"]],
10178
+ ["agenthub", "build", ["uip.agenthub"]],
10179
+ ["coded-apps", "build", ["uip.codedapp"]],
10180
+ ["functions", "build", ["uip.functions"]],
10181
+ ["solution", "build", ["uip.solution"]],
10182
+ ["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
10183
+ ["llm-observability", "troubleshoot", ["uip.traces"]],
10184
+ ["platform", "operate", ["uip.platform"]],
10185
+ ["admin", "operate", ["uip.admin"]],
10186
+ ["automation-ops", "operate", ["uip.aops"]],
10187
+ ["documentation", "troubleshoot", ["uip.docsai"]],
10188
+ ["governance", "operate", ["uip.gov"]],
10189
+ ["insights", "operate", ["uip.insights"]],
10190
+ ["document-understanding", "build", ["uip.ixp"]],
10191
+ ["process-mining", "operate", ["uip.pm"]],
10192
+ ["action-center", "operate", ["uip.tasks"]],
10193
+ ["test-manager", "operate", ["uip.tm"]],
10194
+ ["vertical-solutions", "build", ["uip.vss"]],
10195
+ ["data-fabric", "operate", ["uip.df"]],
10196
+ ["integration-service", "build", ["uip.is"]],
10197
+ ["orchestrator", "operate", ["uip.or"]],
10198
+ [
10199
+ "cli",
10200
+ "operate",
10201
+ [
10202
+ "uip.login",
10203
+ "uip.logout",
10204
+ "uip.user",
10205
+ "uip.config",
10206
+ "uip.tools",
10207
+ "uip.skills",
10208
+ "uip.completion",
10209
+ "uip.update",
10210
+ "uip.mcp",
10211
+ "uip.track"
10212
+ ]
10213
+ ]
10214
+ ]).sort((a, b) => b.prefix.length - a.prefix.length);
10215
+ function normalizeCommandPath(value) {
10216
+ if (typeof value !== "string") {
10217
+ return;
10218
+ }
10219
+ const trimmed = value.trim().toLowerCase();
10220
+ if (!trimmed) {
10221
+ return;
10222
+ }
10223
+ const tokens = trimmed.includes(" ") ? trimmed.split(/\s+/).filter((token) => token.length > 0).filter((token) => !token.startsWith("-")) : trimmed.split(".").filter((token) => token.length > 0);
10224
+ if (tokens.length === 0) {
10225
+ return;
10226
+ }
10227
+ const commandTokens = tokens[0] === "uip" ? tokens : ["uip", ...tokens];
10228
+ return commandTokens.join(".");
10229
+ }
10230
+ function getCommandProductModeAttribution(commandPath) {
10231
+ const normalized = normalizeCommandPath(commandPath);
10232
+ if (!normalized) {
10233
+ return;
10234
+ }
10235
+ return COMMAND_ATTRIBUTION.find(({ prefix }) => normalized === prefix || normalized.startsWith(`${prefix}.`))?.attribution;
10236
+ }
10237
+ function normalizeSkillNameWithOptions(value, options) {
10238
+ if (typeof value !== "string") {
10239
+ return;
10240
+ }
10241
+ const normalized = value.trim().toLowerCase();
10242
+ if (!normalized) {
10243
+ return;
10244
+ }
10245
+ const hasLegacyNamespace = normalized.startsWith(LEGACY_SKILL_NAMESPACE);
10246
+ if (hasLegacyNamespace && !options.allowLegacyNamespace) {
10247
+ return;
10248
+ }
10249
+ const skillName = hasLegacyNamespace ? normalized.slice(LEGACY_SKILL_NAMESPACE.length) : normalized;
10250
+ if (skillName.length > MAX_SKILL_NAME_LENGTH || !SKILL_NAME_PATTERN.test(skillName) || !KNOWN_SKILL_NAMES.has(skillName)) {
10251
+ return;
10252
+ }
10253
+ return skillName;
10254
+ }
10255
+ function normalizeSkillName(value) {
10256
+ return normalizeSkillNameWithOptions(value, {
10257
+ allowLegacyNamespace: false
10258
+ });
10259
+ }
10260
+ function normalizeLegacySkillName(value) {
10261
+ return normalizeSkillNameWithOptions(value, {
10262
+ allowLegacyNamespace: true
10263
+ });
10264
+ }
10265
+ function buildCommandTelemetryAttribution(commandPath, skillSource) {
10266
+ const skillName = normalizeSkillName(skillSource);
10267
+ return {
10268
+ ...skillName ? { skill_name: skillName } : {},
10269
+ ...getCommandProductModeAttribution(commandPath)
10270
+ };
10271
+ }
10272
+ function buildSkillEventTelemetryAttribution(skillSource, uipSubcommand) {
10273
+ const skillName = normalizeLegacySkillName(skillSource);
10274
+ const skillAttribution = skillName ? SKILL_ATTRIBUTION[skillName] : {};
10275
+ const commandAttribution2 = getCommandProductModeAttribution(uipSubcommand);
10276
+ return {
10277
+ ...skillAttribution,
10278
+ ...commandAttribution2,
10279
+ ...skillName ? { skill_name: skillName } : {}
10280
+ };
10281
+ }
10282
+
9652
10283
  // src/telemetry/pii-redactor.ts
9653
10284
  var REDACTED = "[REDACTED]";
9654
10285
  var MAX_VALUE_LENGTH = 200;
@@ -9837,6 +10468,12 @@ function commandHelpHint(commandPath) {
9837
10468
  const command = commandPath.replace(/\./g, " ");
9838
10469
  return `An unexpected error occurred. Run '${command} --help' to verify command syntax, or run with --log-level debug for details.`;
9839
10470
  }
10471
+ function isPromptCancellation(error) {
10472
+ return error instanceof Error && error.name === "ExitPromptError";
10473
+ }
10474
+ function exitCodeFromProcess(fallback) {
10475
+ return typeof process.exitCode === "number" ? process.exitCode : fallback;
10476
+ }
9840
10477
  Command.prototype.trackedAction = function(context, fn, properties) {
9841
10478
  const command = this;
9842
10479
  return this.action(async (...args) => {
@@ -9844,6 +10481,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
9844
10481
  const props = typeof properties === "function" ? properties(...args) : properties;
9845
10482
  const startTime = performance.now();
9846
10483
  let errorMessage;
10484
+ let fallbackExitCode = EXIT_CODES.Success;
10485
+ clearRecordedCommandFailureTelemetry();
9847
10486
  const [error] = await catchError(fn(...args));
9848
10487
  if (error) {
9849
10488
  errorMessage = error instanceof Error ? error.message : String(error);
@@ -9858,6 +10497,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
9858
10497
  const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
9859
10498
  const typedContext = typed.context ?? typed.Context;
9860
10499
  const customContext = isErrorContext(typedContext) ? typedContext : undefined;
10500
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
10501
+ fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
9861
10502
  OutputFormatter.error({
9862
10503
  Result: finalResult,
9863
10504
  ...customErrorCode ? { ErrorCode: customErrorCode } : {},
@@ -9866,16 +10507,26 @@ Command.prototype.trackedAction = function(context, fn, properties) {
9866
10507
  ...customRetry ? { Retry: customRetry } : {},
9867
10508
  ...customContext ? { Context: customContext } : {}
9868
10509
  });
9869
- context.exit(EXIT_CODES[finalResult]);
10510
+ context.exit(fallbackExitCode);
9870
10511
  }
9871
10512
  const durationMs = performance.now() - startTime;
9872
- const success = !error && (process.exitCode === undefined || process.exitCode === 0);
10513
+ const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
10514
+ const recordedFailure = takeRecordedCommandFailureTelemetry();
10515
+ const success = !error && exitCode === 0;
10516
+ const terminalTelemetry = buildCommandTerminalTelemetryProperties({
10517
+ error,
10518
+ exitCode,
10519
+ recordedFailure,
10520
+ pollSignal: context.pollSignal
10521
+ });
9873
10522
  telemetry.trackEvent(telemetryName, redactProperties({
9874
10523
  ...extractCommandParams(command),
9875
10524
  ...props,
10525
+ ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
9876
10526
  command: "true",
9877
10527
  duration: String(durationMs),
9878
10528
  success: String(success),
10529
+ ...terminalTelemetry,
9879
10530
  ...errorMessage ? { errorMessage } : {}
9880
10531
  }));
9881
10532
  });
@@ -10916,6 +11567,36 @@ class ConsoleTelemetryProvider {
10916
11567
  console.debug(`[Telemetry] Dependency: ${name} [${type}] (${duration}ms, ${success ? "ok" : "fail"})`);
10917
11568
  }
10918
11569
  }
11570
+ // src/telemetry/ship-succeeded.ts
11571
+ var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
11572
+ function getShippedKeys() {
11573
+ const existing = shippedKeysSlot.get();
11574
+ if (existing) {
11575
+ return existing;
11576
+ }
11577
+ const keys = new Set;
11578
+ shippedKeysSlot.set(keys);
11579
+ return keys;
11580
+ }
11581
+ function dedupeKey(payload) {
11582
+ return [
11583
+ payload.command_name,
11584
+ payload.ship_kind,
11585
+ payload.target,
11586
+ payload.project_type,
11587
+ payload.artifact_correlation_key ?? payload.package_version_key ?? payload.deployment_key ?? payload.solution_id ?? payload.package_name ?? ""
11588
+ ].join("|");
11589
+ }
11590
+ function trackShipSucceeded(payload) {
11591
+ const keys = getShippedKeys();
11592
+ const key = dedupeKey(payload);
11593
+ if (keys.has(key)) {
11594
+ return false;
11595
+ }
11596
+ keys.add(key);
11597
+ telemetry.trackEvent(CommonTelemetryEvents.ShipSucceeded, redactProperties({ ...payload }));
11598
+ return true;
11599
+ }
10919
11600
  // src/tool-provider.ts
10920
11601
  var factorySlot = singleton("PackagerFactoryProvider");
10921
11602
  function setPackagerFactoryProvider(provider) {
@@ -10933,9 +11614,11 @@ export {
10933
11614
  warnDeprecatedTenantOption,
10934
11615
  warnDeprecatedOptionAlias,
10935
11616
  validateOutputFilter,
11617
+ trackShipSucceeded,
10936
11618
  telemetryInit,
10937
11619
  telemetryFlushAndShutdown,
10938
11620
  telemetry,
11621
+ takeRecordedCommandFailureTelemetry,
10939
11622
  singleton,
10940
11623
  setSdkUserAgentHostToken,
10941
11624
  setProcessContextPollSignal,
@@ -10948,14 +11631,19 @@ export {
10948
11631
  setGlobalTelemetryProperties,
10949
11632
  setGlobalSink,
10950
11633
  setGlobalLogFilePath,
11634
+ setExecutionContextAuthSignal,
10951
11635
  runWithSink,
10952
11636
  restoreConsole,
11637
+ resolveTelemetrySessionId,
10953
11638
  resolveEnvReference,
10954
11639
  resolveDeprecatedOptionAlias,
10955
11640
  resolveAttachmentInputs,
10956
11641
  resetLoggerInstance,
10957
11642
  requireConfirmation,
10958
11643
  registerPackageMetadataOptions,
11644
+ redactProperty,
11645
+ redactProperties,
11646
+ recordCommandFailureTelemetry,
10959
11647
  readStdin,
10960
11648
  readRegistryValue,
10961
11649
  processContext,
@@ -10967,6 +11655,9 @@ export {
10967
11655
  parseLimit,
10968
11656
  parseBoundedInt,
10969
11657
  parseAttachmentSpec,
11658
+ normalizeSkillName,
11659
+ normalizeEnvironment,
11660
+ normalizeBaseUrl,
10970
11661
  msToDuration,
10971
11662
  mapPollFailure,
10972
11663
  mapPackageMetadataOptions,
@@ -10983,7 +11674,9 @@ export {
10983
11674
  installSdkCodingAgentHeader,
10984
11675
  installConsoleGuard,
10985
11676
  hashContent,
11677
+ getTelemetrySessionId,
10986
11678
  getSdkUserAgentToken,
11679
+ getRecordedCommandFailureTelemetry,
10987
11680
  getOutputSink,
10988
11681
  getOutputFormatExplicit,
10989
11682
  getOutputFormat,
@@ -10991,6 +11684,8 @@ export {
10991
11684
  getLogFilePath,
10992
11685
  getInteractivityMode,
10993
11686
  getGlobalLogFilePath,
11687
+ getExecutionContextTelemetryProperties,
11688
+ getConfiguredTelemetrySessionId,
10994
11689
  getCompleter,
10995
11690
  getCommandExamples,
10996
11691
  extractFormatFromArgs,
@@ -10999,6 +11694,8 @@ export {
10999
11694
  extractErrorDetails,
11000
11695
  extractCommandHelp,
11001
11696
  ensurePackagerFactory,
11697
+ detectExecutionContext,
11698
+ detectAgentVersion,
11002
11699
  detectAgent,
11003
11700
  describeConnectivityError,
11004
11701
  deriveCommandPath,
@@ -11008,9 +11705,14 @@ export {
11008
11705
  createAppInsightsProvider,
11009
11706
  configureLogger,
11010
11707
  collectCommands,
11708
+ clearRecordedCommandFailureTelemetry,
11011
11709
  catchError,
11012
11710
  canPrompt,
11711
+ buildSkillEventTelemetryAttribution,
11013
11712
  buildOrchestratorUrl,
11713
+ buildEnvironmentProperties,
11714
+ buildCommandTerminalTelemetryProperties,
11715
+ buildCommandTelemetryAttribution,
11014
11716
  buildActionCenterTaskUrl,
11015
11717
  buildActionCenterInboxUrl,
11016
11718
  appendOption,
@@ -11019,6 +11721,8 @@ export {
11019
11721
  addHiddenDeprecatedTenantOption,
11020
11722
  UIPATH_HOME_DIR,
11021
11723
  TelemetryService,
11724
+ TELEMETRY_SESSION_ID_PROPERTY,
11725
+ TELEMETRY_SESSION_ID_ENV,
11022
11726
  SuccessOutput,
11023
11727
  ScreenLogger,
11024
11728
  RETRY_HINTS,
@@ -11034,6 +11738,7 @@ export {
11034
11738
  FailureOutput,
11035
11739
  ErrorDecision,
11036
11740
  EXIT_CODES,
11741
+ EXECUTION_CONTEXT_VALUES,
11037
11742
  DebugTelemetryProvider,
11038
11743
  DEFAULT_REDIRECT_URI,
11039
11744
  DEFAULT_PAGE_SIZE,
@@ -11052,4 +11757,4 @@ export {
11052
11757
  ATTACHMENT_INSTRUCTIONS
11053
11758
  };
11054
11759
 
11055
- //# debugId=B95D3D4986F65A8364756E2164756E21
11760
+ //# debugId=619EF92A7A37ECCD64756E2164756E21