@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/deploy.js CHANGED
@@ -34303,11 +34303,36 @@ class NodeContextStorage {
34303
34303
  return this.storage.getStore();
34304
34304
  }
34305
34305
  }
34306
+ // ../common/src/telemetry/trace-context.ts
34307
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
34308
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
34309
+ function getProcessEnv() {
34310
+ return globalThis.process?.env;
34311
+ }
34312
+ function parseInboundTraceparent(value) {
34313
+ if (!value) {
34314
+ return;
34315
+ }
34316
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
34317
+ if (!match) {
34318
+ return;
34319
+ }
34320
+ const [, traceId, parentSpanId] = match;
34321
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
34322
+ return;
34323
+ }
34324
+ return { traceId, parentSpanId };
34325
+ }
34326
+ function getInboundTraceContext() {
34327
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
34328
+ }
34329
+
34306
34330
  // ../common/src/telemetry/session-id.ts
34307
34331
  var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
34308
34332
  var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
34309
34333
  var telemetrySessionIdSlot = singleton("TelemetrySessionId");
34310
- function getProcessEnv() {
34334
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
34335
+ function getProcessEnv2() {
34311
34336
  return globalThis.process?.env;
34312
34337
  }
34313
34338
  function normalizeSessionId(value) {
@@ -34318,18 +34343,165 @@ function normalizeSessionId(value) {
34318
34343
  return trimmed || undefined;
34319
34344
  }
34320
34345
  function getConfiguredTelemetrySessionId() {
34321
- return normalizeSessionId(getProcessEnv()?.[TELEMETRY_SESSION_ID_ENV]);
34346
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
34322
34347
  }
34323
34348
  function resolveTelemetrySessionId(existingSessionId) {
34324
34349
  return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
34325
34350
  }
34351
+ function getTelemetryOperationId() {
34352
+ const existing = telemetryOperationIdSlot.get();
34353
+ if (existing) {
34354
+ return existing;
34355
+ }
34356
+ const inboundTraceId = getInboundTraceContext()?.traceId;
34357
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
34358
+ telemetryOperationIdSlot.set(generated);
34359
+ return generated;
34360
+ }
34326
34361
  // ../common/src/telemetry/global-telemetry-properties.ts
34327
34362
  var telemetryPropsSlot = singleton("TelemetryDefaultProps");
34328
34363
  function getGlobalTelemetryProperties() {
34329
34364
  return telemetryPropsSlot.get();
34330
34365
  }
34331
34366
 
34367
+ // ../common/src/telemetry/pii-redactor.ts
34368
+ var REDACTED = "[REDACTED]";
34369
+ var MAX_VALUE_LENGTH = 200;
34370
+ var SENSITIVE_NAME_TOKENS = new Set([
34371
+ "token",
34372
+ "tokens",
34373
+ "secret",
34374
+ "secrets",
34375
+ "password",
34376
+ "passwords",
34377
+ "pwd",
34378
+ "credential",
34379
+ "credentials",
34380
+ "auth",
34381
+ "authentication",
34382
+ "authorization",
34383
+ "authority",
34384
+ "cert",
34385
+ "certificate",
34386
+ "certificates"
34387
+ ]);
34388
+ var SENSITIVE_KEY_PREFIXES = new Set([
34389
+ "api",
34390
+ "access",
34391
+ "client",
34392
+ "private",
34393
+ "public",
34394
+ "signing",
34395
+ "encryption",
34396
+ "session",
34397
+ "master",
34398
+ "shared",
34399
+ "root",
34400
+ "ssh",
34401
+ "rsa",
34402
+ "aes",
34403
+ "hmac",
34404
+ "oauth"
34405
+ ]);
34406
+ 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;
34407
+ var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
34408
+ var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
34409
+ var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
34410
+ var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
34411
+ var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
34412
+ var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
34413
+ function shortHash(input) {
34414
+ let hash = 2166136261;
34415
+ for (let i = 0;i < input.length; i++) {
34416
+ hash ^= input.charCodeAt(i);
34417
+ hash = Math.imul(hash, 16777619);
34418
+ }
34419
+ return (hash >>> 0).toString(16).padStart(8, "0");
34420
+ }
34421
+ function redactUrl(raw) {
34422
+ try {
34423
+ const url = new URL(raw);
34424
+ return `${url.protocol}//${url.host}`;
34425
+ } catch {
34426
+ return `url#${shortHash(raw)}`;
34427
+ }
34428
+ }
34429
+ function redactValueDetectors(value) {
34430
+ let out = value;
34431
+ out = out.replace(JWT_PATTERN, () => REDACTED);
34432
+ out = out.replace(URL_PATTERN, (match) => {
34433
+ const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
34434
+ const core2 = trailing ? match.slice(0, -trailing.length) : match;
34435
+ return `${redactUrl(core2)}${trailing}`;
34436
+ });
34437
+ out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
34438
+ out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
34439
+ out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
34440
+ out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
34441
+ if (out.length > MAX_VALUE_LENGTH) {
34442
+ out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
34443
+ }
34444
+ return out;
34445
+ }
34446
+ function redactValue(value) {
34447
+ return redactValueDetectors(value);
34448
+ }
34449
+ function redactError(error) {
34450
+ const safe = new Error(redactValueDetectors(error.message ?? ""));
34451
+ safe.name = error.name;
34452
+ safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
34453
+ return safe;
34454
+ }
34455
+ function nameTokens(name) {
34456
+ 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);
34457
+ }
34458
+ function isSensitiveName(name) {
34459
+ const tokens = nameTokens(name);
34460
+ for (let i = 0;i < tokens.length; i++) {
34461
+ const token = tokens[i];
34462
+ if (SENSITIVE_NAME_TOKENS.has(token)) {
34463
+ return true;
34464
+ }
34465
+ if (token === "key" || token === "keys") {
34466
+ const prev = tokens[i - 1];
34467
+ if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
34468
+ return true;
34469
+ }
34470
+ }
34471
+ }
34472
+ return false;
34473
+ }
34474
+ function redactProperty(name, value) {
34475
+ if (value === undefined || value === null) {
34476
+ return;
34477
+ }
34478
+ if (isSensitiveName(name)) {
34479
+ return REDACTED;
34480
+ }
34481
+ if (typeof value === "boolean" || typeof value === "number") {
34482
+ return value;
34483
+ }
34484
+ if (typeof value !== "string") {
34485
+ return "[OBJECT]";
34486
+ }
34487
+ return redactValueDetectors(value);
34488
+ }
34489
+ function redactProperties(properties) {
34490
+ const out = {};
34491
+ for (const [name, value] of Object.entries(properties)) {
34492
+ const redacted = redactProperty(name, value);
34493
+ if (redacted !== undefined) {
34494
+ out[name] = redacted;
34495
+ }
34496
+ }
34497
+ return out;
34498
+ }
34499
+
34332
34500
  // ../common/src/telemetry/telemetry-service.ts
34501
+ var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
34502
+ var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
34503
+ var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
34504
+
34333
34505
  class TelemetryService {
34334
34506
  telemetryProvider;
34335
34507
  contextStorage;
@@ -34356,11 +34528,15 @@ class TelemetryService {
34356
34528
  trackException(error, properties) {
34357
34529
  const context = this.getCurrentContext();
34358
34530
  const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
34359
- this.telemetryProvider.trackException(error, enrichedProperties);
34531
+ this.telemetryProvider.trackException(redactError(error), enrichedProperties);
34360
34532
  }
34361
34533
  async trackRequest(name, fn, properties) {
34534
+ const parentContext = this.getCurrentContext();
34535
+ const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
34536
+ const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
34362
34537
  const context = {
34363
- operationId: this.operationId ?? this.generateId(),
34538
+ operationId,
34539
+ ...parentId !== undefined ? { parentId } : {},
34364
34540
  id: this.generateId()
34365
34541
  };
34366
34542
  const startTime = performance.now();
@@ -34378,6 +34554,45 @@ class TelemetryService {
34378
34554
  throw error;
34379
34555
  }
34380
34556
  }
34557
+ trackRequestResult(name, durationMs, success, properties, context) {
34558
+ const requestContext = context ?? {
34559
+ operationId: this.operationId ?? getTelemetryOperationId(),
34560
+ id: this.generateId()
34561
+ };
34562
+ const enrichedProperties = this.enrichPropertiesWithContext(properties, requestContext);
34563
+ this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
34564
+ }
34565
+ createRequestContext() {
34566
+ const operationId = this.operationId ?? getTelemetryOperationId();
34567
+ const parentId = this.inboundParentIdFor(operationId);
34568
+ return {
34569
+ operationId,
34570
+ ...parentId !== undefined ? { parentId } : {},
34571
+ id: this.generateId()
34572
+ };
34573
+ }
34574
+ inboundParentIdFor(operationId) {
34575
+ const inbound = getInboundTraceContext();
34576
+ return inbound && inbound.traceId === operationId ? inbound.parentSpanId : undefined;
34577
+ }
34578
+ runWithContext(context, fn) {
34579
+ return this.contextStorage.run(context, fn);
34580
+ }
34581
+ createDependencyContext() {
34582
+ const parentContext = this.getCurrentContext();
34583
+ if (!parentContext) {
34584
+ return;
34585
+ }
34586
+ return {
34587
+ operationId: parentContext.operationId,
34588
+ parentId: parentContext.id,
34589
+ id: this.generateId()
34590
+ };
34591
+ }
34592
+ trackDependencyResult(name, type2, durationMs, success, properties, context, resultCode) {
34593
+ const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
34594
+ this.telemetryProvider.trackDependency(redactValue(name), type2, durationMs, success, enrichedProperties, resultCode);
34595
+ }
34381
34596
  async trackDependencyOperation(name, type2, fn, properties) {
34382
34597
  const parentContext = this.getCurrentContext();
34383
34598
  if (!parentContext) {
@@ -34414,8 +34629,12 @@ class TelemetryService {
34414
34629
  ...getExecutionContextTelemetryProperties(),
34415
34630
  ...globalProperties,
34416
34631
  ...this.defaultProperties,
34417
- ...properties,
34418
- ...context
34632
+ ...redactProperties(properties ?? {}),
34633
+ ...context ? {
34634
+ [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
34635
+ ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
34636
+ [TELEMETRY_SPAN_ID_PROPERTY]: context.id
34637
+ } : {}
34419
34638
  };
34420
34639
  if (sessionId === undefined) {
34421
34640
  delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
@@ -34425,7 +34644,16 @@ class TelemetryService {
34425
34644
  return enriched;
34426
34645
  }
34427
34646
  generateId() {
34428
- return crypto.randomUUID().replaceAll("-", "");
34647
+ const bytes = new Uint8Array(8);
34648
+ let hex = "";
34649
+ do {
34650
+ crypto.getRandomValues(bytes);
34651
+ hex = "";
34652
+ for (const byte of bytes) {
34653
+ hex += byte.toString(16).padStart(2, "0");
34654
+ }
34655
+ } while (/^0+$/.test(hex));
34656
+ return hex;
34429
34657
  }
34430
34658
  }
34431
34659
  // ../common/src/telemetry/node-appinsights-telemetry-provider.ts
@@ -35127,134 +35355,11 @@ function buildCommandTelemetryAttribution(commandPath, skillSource) {
35127
35355
  };
35128
35356
  }
35129
35357
 
35130
- // ../common/src/telemetry/pii-redactor.ts
35131
- var REDACTED = "[REDACTED]";
35132
- var MAX_VALUE_LENGTH = 200;
35133
- var SENSITIVE_NAME_TOKENS = new Set([
35134
- "token",
35135
- "tokens",
35136
- "secret",
35137
- "secrets",
35138
- "password",
35139
- "passwords",
35140
- "pwd",
35141
- "credential",
35142
- "credentials",
35143
- "auth",
35144
- "authentication",
35145
- "authorization",
35146
- "authority",
35147
- "cert",
35148
- "certificate",
35149
- "certificates"
35150
- ]);
35151
- var SENSITIVE_KEY_PREFIXES = new Set([
35152
- "api",
35153
- "access",
35154
- "client",
35155
- "private",
35156
- "public",
35157
- "signing",
35158
- "encryption",
35159
- "session",
35160
- "master",
35161
- "shared",
35162
- "root",
35163
- "ssh",
35164
- "rsa",
35165
- "aes",
35166
- "hmac",
35167
- "oauth"
35168
- ]);
35169
- 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;
35170
- var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
35171
- var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
35172
- var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
35173
- var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
35174
- var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
35175
- var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
35176
- function shortHash(input) {
35177
- let hash = 2166136261;
35178
- for (let i = 0;i < input.length; i++) {
35179
- hash ^= input.charCodeAt(i);
35180
- hash = Math.imul(hash, 16777619);
35181
- }
35182
- return (hash >>> 0).toString(16).padStart(8, "0");
35183
- }
35184
- function redactUrl(raw) {
35185
- try {
35186
- const url = new URL(raw);
35187
- return `${url.protocol}//${url.host}`;
35188
- } catch {
35189
- return `url#${shortHash(raw)}`;
35190
- }
35191
- }
35192
- function redactValueDetectors(value) {
35193
- let out = value;
35194
- out = out.replace(JWT_PATTERN, () => REDACTED);
35195
- out = out.replace(URL_PATTERN, (match) => {
35196
- const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
35197
- const core2 = trailing ? match.slice(0, -trailing.length) : match;
35198
- return `${redactUrl(core2)}${trailing}`;
35199
- });
35200
- out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
35201
- out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
35202
- out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
35203
- out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
35204
- if (out.length > MAX_VALUE_LENGTH) {
35205
- out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
35206
- }
35207
- return out;
35208
- }
35209
- function nameTokens(name) {
35210
- 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);
35211
- }
35212
- function isSensitiveName(name) {
35213
- const tokens = nameTokens(name);
35214
- for (let i = 0;i < tokens.length; i++) {
35215
- const token = tokens[i];
35216
- if (SENSITIVE_NAME_TOKENS.has(token)) {
35217
- return true;
35218
- }
35219
- if (token === "key" || token === "keys") {
35220
- const prev = tokens[i - 1];
35221
- if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
35222
- return true;
35223
- }
35224
- }
35225
- }
35226
- return false;
35227
- }
35228
- function redactProperty(name, value) {
35229
- if (value === undefined || value === null) {
35230
- return;
35231
- }
35232
- if (isSensitiveName(name)) {
35233
- return REDACTED;
35234
- }
35235
- if (typeof value === "boolean" || typeof value === "number") {
35236
- return value;
35237
- }
35238
- if (typeof value !== "string") {
35239
- return "[OBJECT]";
35240
- }
35241
- return redactValueDetectors(value);
35242
- }
35243
- function redactProperties(properties) {
35244
- const out = {};
35245
- for (const [name, value] of Object.entries(properties)) {
35246
- const redacted = redactProperty(name, value);
35247
- if (redacted !== undefined) {
35248
- out[name] = redacted;
35249
- }
35250
- }
35251
- return out;
35252
- }
35253
-
35254
35358
  // ../common/src/trackedAction.ts
35255
35359
  var pollSignalSlot = singleton("PollSignal");
35256
35360
  var cliErrorCodeValues = new Set(CLI_ERROR_CODES);
35257
35361
  var retryHintValues = new Set(RETRY_HINTS);
35362
+ var TELEMETRY_COMMAND_ARG_PREFIX = "uip.cmd.arg.";
35258
35363
  var processContext = {
35259
35364
  exit: (code) => {
35260
35365
  process.exitCode = code;
@@ -35265,22 +35370,18 @@ var processContext = {
35265
35370
  };
35266
35371
  function extractCommandParams(cmd) {
35267
35372
  const params = {};
35373
+ const add2 = (name, value) => {
35374
+ if (name && value !== undefined) {
35375
+ params[`${TELEMETRY_COMMAND_ARG_PREFIX}${name}`] = value;
35376
+ }
35377
+ };
35268
35378
  const registered = cmd.registeredArguments ?? [];
35269
35379
  const processed = cmd.processedArgs ?? [];
35270
35380
  for (let i = 0;i < registered.length; i++) {
35271
- const value = processed[i];
35272
- if (value === undefined) {
35273
- continue;
35274
- }
35275
- const name = registered[i].name();
35276
- if (name) {
35277
- params[name] = value;
35278
- }
35381
+ add2(registered[i].name(), processed[i]);
35279
35382
  }
35280
35383
  for (const [key, value] of Object.entries(cmd.opts())) {
35281
- if (value !== undefined) {
35282
- params[key] = value;
35283
- }
35384
+ add2(key, value);
35284
35385
  }
35285
35386
  return params;
35286
35387
  }
@@ -35323,11 +35424,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
35323
35424
  return this.action(async (...args) => {
35324
35425
  const telemetryName = deriveCommandPath(command);
35325
35426
  const props = typeof properties === "function" ? properties(...args) : properties;
35427
+ const requestContext = telemetry.createRequestContext();
35326
35428
  const startTime = performance.now();
35327
35429
  let errorMessage;
35328
35430
  let fallbackExitCode = EXIT_CODES.Success;
35329
35431
  clearRecordedCommandFailureTelemetry();
35330
- const [error] = await catchError(fn(...args));
35432
+ const [error] = await catchError(telemetry.runWithContext(requestContext, () => fn(...args)));
35331
35433
  if (error) {
35332
35434
  errorMessage = error instanceof Error ? error.message : String(error);
35333
35435
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
@@ -35363,16 +35465,21 @@ Command.prototype.trackedAction = function(context, fn, properties) {
35363
35465
  recordedFailure,
35364
35466
  pollSignal: context.pollSignal
35365
35467
  });
35366
- telemetry.trackEvent(telemetryName, redactProperties({
35367
- ...extractCommandParams(command),
35468
+ const commandParams = extractCommandParams(command);
35469
+ if (props) {
35470
+ for (const key of Object.keys(props)) {
35471
+ delete commandParams[`${TELEMETRY_COMMAND_ARG_PREFIX}${key}`];
35472
+ }
35473
+ }
35474
+ const baseProperties = redactProperties({
35475
+ ...commandParams,
35368
35476
  ...props,
35369
35477
  ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
35370
35478
  command: "true",
35371
- duration: String(durationMs),
35372
- success: String(success),
35373
35479
  ...terminalTelemetry,
35374
35480
  ...errorMessage ? { errorMessage } : {}
35375
- }));
35481
+ });
35482
+ telemetry.trackRequestResult(telemetryName, durationMs, success, baseProperties, requestContext);
35376
35483
  });
35377
35484
  };
35378
35485
  // ../common/src/console-guard.ts
@@ -37627,7 +37734,7 @@ class JSONApiResponse2 {
37627
37734
  var package_default2 = {
37628
37735
  name: "@uipath/solution-sdk",
37629
37736
  license: "MIT",
37630
- version: "1.198.0-preview.95",
37737
+ version: "1.198.0",
37631
37738
  repository: {
37632
37739
  type: "git",
37633
37740
  url: "https://github.com/UiPath/cli.git",
@@ -43225,4 +43332,4 @@ export {
43225
43332
  activateDeploymentAsync
43226
43333
  };
43227
43334
 
43228
- //# debugId=06EDE9613730C64864756E2164756E21
43335
+ //# debugId=656C3710CC9A83D264756E2164756E21