@uipath/apms-tool 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.
Files changed (3) hide show
  1. package/dist/index.js +578 -9
  2. package/dist/tool.js +578 -9
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -21247,7 +21247,7 @@ var {
21247
21247
  var package_default = {
21248
21248
  name: "@uipath/apms-tool",
21249
21249
  license: "MIT",
21250
- version: "1.197.0-preview.65",
21250
+ version: "1.197.0-preview.67",
21251
21251
  description: "CLI plugin for the UiPath Access Policy Management Service.",
21252
21252
  private: false,
21253
21253
  repository: {
@@ -29184,9 +29184,228 @@ function getOutputFilter() {
29184
29184
  return filterSlot.get();
29185
29185
  }
29186
29186
 
29187
+ // ../../common/src/telemetry/command-terminal.ts
29188
+ var recordedFailureSlot = singleton("CommandTelemetryFailure");
29189
+ var AUTH_ERROR_CODES = new Set([
29190
+ "authentication_required",
29191
+ "permission_denied"
29192
+ ]);
29193
+ var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
29194
+ var NETWORK_HTTP_ERROR_CODES = new Set([
29195
+ "network_error",
29196
+ "rate_limited",
29197
+ "server_error",
29198
+ "not_found",
29199
+ "method_not_allowed"
29200
+ ]);
29201
+ var TIMEOUT_ERROR_CODES = new Set(["timeout"]);
29202
+ var NETWORK_OS_ERROR_CODES = new Set([
29203
+ "ECONNREFUSED",
29204
+ "ECONNRESET",
29205
+ "ENOTFOUND",
29206
+ "EAI_AGAIN",
29207
+ "EPIPE",
29208
+ "EHOSTUNREACH",
29209
+ "ENETUNREACH",
29210
+ "EAI_FAIL"
29211
+ ]);
29212
+ var TIMEOUT_OS_ERROR_CODES = new Set(["ETIMEDOUT", "ESOCKETTIMEDOUT"]);
29213
+ var TLS_ERROR_CODES2 = new Set([
29214
+ "SELF_SIGNED_CERT_IN_CHAIN",
29215
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
29216
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
29217
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
29218
+ "UNABLE_TO_GET_ISSUER_CERT",
29219
+ "CERT_HAS_EXPIRED",
29220
+ "CERT_UNTRUSTED",
29221
+ "ERR_TLS_CERT_ALTNAME_INVALID"
29222
+ ]);
29223
+ var MISSING_DEPENDENCY_CODES = new Set([
29224
+ "MODULE_NOT_FOUND",
29225
+ "ERR_MODULE_NOT_FOUND"
29226
+ ]);
29227
+ var INTERNAL_ERROR_NAMES = new Set([
29228
+ "TypeError",
29229
+ "ReferenceError",
29230
+ "SyntaxError",
29231
+ "RangeError"
29232
+ ]);
29233
+ function isRecord(value) {
29234
+ return value !== null && typeof value === "object";
29235
+ }
29236
+ function stringField(value, field) {
29237
+ if (!isRecord(value)) {
29238
+ return;
29239
+ }
29240
+ const raw = value[field];
29241
+ return typeof raw === "string" ? raw : undefined;
29242
+ }
29243
+ function numberField(value, field) {
29244
+ if (!isRecord(value)) {
29245
+ return;
29246
+ }
29247
+ const raw = value[field];
29248
+ return typeof raw === "number" ? raw : undefined;
29249
+ }
29250
+ function findStringInCauseChain(error, field) {
29251
+ let current = error;
29252
+ for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
29253
+ const value = stringField(current, field);
29254
+ if (value) {
29255
+ return value;
29256
+ }
29257
+ current = current.cause;
29258
+ }
29259
+ return;
29260
+ }
29261
+ function findCodeInCauseChain(error) {
29262
+ return findStringInCauseChain(error, "code");
29263
+ }
29264
+ function isSpawnEnoent(error) {
29265
+ const code = findCodeInCauseChain(error);
29266
+ if (code !== "ENOENT") {
29267
+ return false;
29268
+ }
29269
+ const syscall = findStringInCauseChain(error, "syscall");
29270
+ return syscall?.startsWith("spawn") === true;
29271
+ }
29272
+ function isCancellationError(error, exitCode, pollSignal) {
29273
+ if (exitCode === 130) {
29274
+ return true;
29275
+ }
29276
+ if (!isRecord(error)) {
29277
+ return false;
29278
+ }
29279
+ if (numberField(error, "exitCode") === 130) {
29280
+ return true;
29281
+ }
29282
+ const name = stringField(error, "name");
29283
+ if (name === "ExitPromptError") {
29284
+ return true;
29285
+ }
29286
+ if (name === "AbortError" && pollSignal?.aborted) {
29287
+ return true;
29288
+ }
29289
+ const message = stringField(error, "message");
29290
+ return message?.includes("SIGINT") === true;
29291
+ }
29292
+ function terminalSignalFor(input, outcome) {
29293
+ if (input.recordedFailure?.terminalSignal) {
29294
+ return input.recordedFailure.terminalSignal;
29295
+ }
29296
+ const explicit = findStringInCauseChain(input.error, "terminalSignal") ?? findStringInCauseChain(input.error, "signal");
29297
+ if (explicit) {
29298
+ return explicit;
29299
+ }
29300
+ return outcome === "cancelled" ? "SIGINT" : undefined;
29301
+ }
29302
+ function classifyHttpStatus(status) {
29303
+ if (status === 401 || status === 403) {
29304
+ return "auth";
29305
+ }
29306
+ if (status === 400 || status === 409 || status === 422) {
29307
+ return "validation";
29308
+ }
29309
+ if (status === 408) {
29310
+ return "timeout";
29311
+ }
29312
+ return "network_http";
29313
+ }
29314
+ function classifyFromResult(result) {
29315
+ switch (result) {
29316
+ case "AuthenticationError":
29317
+ return "auth";
29318
+ case "ValidationError":
29319
+ return "validation";
29320
+ case "TimeoutError":
29321
+ return "timeout";
29322
+ default:
29323
+ return;
29324
+ }
29325
+ }
29326
+ function classifyFromErrorCode(errorCode2) {
29327
+ if (!errorCode2) {
29328
+ return;
29329
+ }
29330
+ if (AUTH_ERROR_CODES.has(errorCode2)) {
29331
+ return "auth";
29332
+ }
29333
+ if (VALIDATION_ERROR_CODES.has(errorCode2)) {
29334
+ return "validation";
29335
+ }
29336
+ if (TIMEOUT_ERROR_CODES.has(errorCode2)) {
29337
+ return "timeout";
29338
+ }
29339
+ if (NETWORK_HTTP_ERROR_CODES.has(errorCode2)) {
29340
+ return "network_http";
29341
+ }
29342
+ return;
29343
+ }
29344
+ function classifyFromError(error) {
29345
+ const code = findCodeInCauseChain(error);
29346
+ if (code) {
29347
+ if (code.startsWith("commander.")) {
29348
+ return "validation";
29349
+ }
29350
+ if (NETWORK_OS_ERROR_CODES.has(code) || TLS_ERROR_CODES2.has(code)) {
29351
+ return "network_http";
29352
+ }
29353
+ if (TIMEOUT_OS_ERROR_CODES.has(code)) {
29354
+ return "timeout";
29355
+ }
29356
+ if (MISSING_DEPENDENCY_CODES.has(code) || isSpawnEnoent(error)) {
29357
+ return "missing_dependency";
29358
+ }
29359
+ }
29360
+ const message = stringField(error, "message");
29361
+ if (message?.includes("fetch failed") === true) {
29362
+ return "network_http";
29363
+ }
29364
+ const name = stringField(error, "name");
29365
+ if (name && INTERNAL_ERROR_NAMES.has(name)) {
29366
+ return "internal";
29367
+ }
29368
+ return;
29369
+ }
29370
+ function classifyError2(input) {
29371
+ const recorded = input.recordedFailure;
29372
+ if (recorded?.errorClass) {
29373
+ return recorded.errorClass;
29374
+ }
29375
+ const status = recorded?.context?.httpStatus;
29376
+ if (status !== undefined) {
29377
+ return classifyHttpStatus(status);
29378
+ }
29379
+ return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
29380
+ }
29381
+ function recordCommandFailureTelemetry(failure) {
29382
+ recordedFailureSlot.set(failure);
29383
+ }
29384
+ function clearRecordedCommandFailureTelemetry() {
29385
+ recordedFailureSlot.clear();
29386
+ }
29387
+ function takeRecordedCommandFailureTelemetry() {
29388
+ const failure = recordedFailureSlot.get();
29389
+ recordedFailureSlot.clear();
29390
+ return failure;
29391
+ }
29392
+ function buildCommandTerminalTelemetryProperties(input) {
29393
+ const cancelled = isCancellationError(input.error, input.exitCode, input.pollSignal);
29394
+ const outcome = input.recordedFailure?.terminalOutcome ?? (input.exitCode === 0 ? "success" : cancelled ? "cancelled" : "failure");
29395
+ const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError2(input);
29396
+ const terminalSignal = terminalSignalFor(input, outcome);
29397
+ return {
29398
+ exit_code: input.exitCode,
29399
+ terminal_outcome: outcome,
29400
+ ...errorClass ? { error_class: errorClass } : {},
29401
+ ...terminalSignal ? { terminal_signal: terminalSignal } : {}
29402
+ };
29403
+ }
29404
+
29187
29405
  // ../../common/src/telemetry/telemetry-events.ts
29188
29406
  var CommonTelemetryEvents = {
29189
- Error: "uip.error"
29407
+ Error: "uip.error",
29408
+ ShipSucceeded: "ship_succeeded"
29190
29409
  };
29191
29410
 
29192
29411
  // ../../common/src/registry.ts
@@ -29253,6 +29472,136 @@ function formatMessage(category, name, properties) {
29253
29472
  }
29254
29473
  return message;
29255
29474
  }
29475
+ // ../../common/src/telemetry/detect-agent.ts
29476
+ var KNOWN_AGENTS = [
29477
+ { envVar: "CLAUDECODE", value: "1", id: "claude-code" },
29478
+ { envVar: "CURSOR_AGENT", value: "1", id: "cursor" },
29479
+ { envVar: "GEMINI_CLI", value: "1", id: "gemini-cli" },
29480
+ { envVar: "CODEX_THREAD_ID", id: "codex" },
29481
+ { envVar: "CODEX_SANDBOX", id: "codex" },
29482
+ { envVar: "AUGMENT_AGENT", value: "1", id: "augment" },
29483
+ { envVar: "CLINE_ACTIVE", value: "true", id: "cline" }
29484
+ ];
29485
+ function detectAgentFromEnv(env) {
29486
+ for (const agent of KNOWN_AGENTS) {
29487
+ const envValue = env[agent.envVar];
29488
+ if (agent.value !== undefined) {
29489
+ if (envValue === agent.value)
29490
+ return agent.id;
29491
+ } else {
29492
+ if (envValue)
29493
+ return agent.id;
29494
+ }
29495
+ }
29496
+ const agentEnv = env.AGENT;
29497
+ if (agentEnv) {
29498
+ if (agentEnv === "1" || agentEnv === "true")
29499
+ return "unknown";
29500
+ if (agentEnv.length <= 32)
29501
+ return agentEnv.toLowerCase();
29502
+ }
29503
+ return;
29504
+ }
29505
+ // ../../common/src/telemetry/environment-info.ts
29506
+ var LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
29507
+ // ../../common/src/telemetry/execution-context.ts
29508
+ var authSignalSlot = singleton("TelemetryExecutionContextAuthSignal");
29509
+ var isTruthy = (value) => value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
29510
+ var isEqual = (value, expected) => value?.toLowerCase() === expected;
29511
+ var CI_SIGNATURES = [
29512
+ {
29513
+ provider: "github_actions",
29514
+ matches: (env) => isTruthy(env.GITHUB_ACTIONS),
29515
+ isScheduler: (env) => env.GITHUB_EVENT_NAME === "schedule"
29516
+ },
29517
+ {
29518
+ provider: "azure_devops",
29519
+ matches: (env) => isTruthy(env.TF_BUILD),
29520
+ isScheduler: (env) => isEqual(env.BUILD_REASON, "schedule")
29521
+ },
29522
+ {
29523
+ provider: "gitlab",
29524
+ matches: (env) => isTruthy(env.GITLAB_CI),
29525
+ isScheduler: (env) => env.CI_PIPELINE_SOURCE === "schedule"
29526
+ },
29527
+ {
29528
+ provider: "circleci",
29529
+ matches: (env) => isTruthy(env.CIRCLECI),
29530
+ isScheduler: (env) => env.CIRCLE_PIPELINE_TRIGGER_SOURCE === "scheduled_pipeline"
29531
+ },
29532
+ {
29533
+ provider: "jenkins",
29534
+ matches: (env) => isTruthy(env.JENKINS_URL) || isTruthy(env.JENKINS_HOME)
29535
+ },
29536
+ {
29537
+ provider: "teamcity",
29538
+ matches: (env) => isTruthy(env.TEAMCITY_VERSION)
29539
+ },
29540
+ {
29541
+ provider: "buildkite",
29542
+ matches: (env) => isTruthy(env.BUILDKITE),
29543
+ isScheduler: (env) => env.BUILDKITE_SOURCE === "schedule"
29544
+ },
29545
+ {
29546
+ provider: "bitbucket",
29547
+ matches: (env) => isTruthy(env.BITBUCKET_BUILD_NUMBER)
29548
+ },
29549
+ {
29550
+ provider: "travis",
29551
+ matches: (env) => isTruthy(env.TRAVIS)
29552
+ },
29553
+ {
29554
+ provider: "appveyor",
29555
+ matches: (env) => isTruthy(env.APPVEYOR)
29556
+ },
29557
+ {
29558
+ provider: "generic",
29559
+ matches: (env) => isTruthy(env.CI)
29560
+ }
29561
+ ];
29562
+ function currentEnv() {
29563
+ return typeof process === "undefined" ? {} : process.env;
29564
+ }
29565
+ function currentTtyState() {
29566
+ if (typeof process === "undefined")
29567
+ return false;
29568
+ return Boolean(process.stdout?.isTTY || process.stdin?.isTTY || process.stderr?.isTTY);
29569
+ }
29570
+ function detectCi(env) {
29571
+ const signature = CI_SIGNATURES.find((candidate) => candidate.matches(env));
29572
+ if (!signature)
29573
+ return;
29574
+ return {
29575
+ executionContext: signature.isScheduler?.(env) ? "scheduler" : "ci",
29576
+ ciProvider: signature.provider
29577
+ };
29578
+ }
29579
+ function detectExecutionContext(options = {}) {
29580
+ const env = options.env ?? currentEnv();
29581
+ const ci = detectCi(env);
29582
+ if (ci)
29583
+ return ci;
29584
+ const agent = options.agent ?? detectAgentFromEnv(env);
29585
+ if (agent) {
29586
+ return { executionContext: "agent" };
29587
+ }
29588
+ const authSignal = options.authSignal ?? authSignalSlot.get();
29589
+ if (authSignal === "service_account") {
29590
+ return { executionContext: "service_account" };
29591
+ }
29592
+ const isTty = options.isTty ?? currentTtyState();
29593
+ if (isTty) {
29594
+ return { executionContext: "manual" };
29595
+ }
29596
+ return { executionContext: "unknown" };
29597
+ }
29598
+ function getExecutionContextTelemetryProperties() {
29599
+ const detected = detectExecutionContext();
29600
+ return {
29601
+ execution_context: detected.executionContext,
29602
+ ...detected.ciProvider ? { ci_provider: detected.ciProvider } : {}
29603
+ };
29604
+ }
29256
29605
  // ../../common/src/telemetry/node-context-storage.ts
29257
29606
  import { AsyncLocalStorage } from "node:async_hooks";
29258
29607
 
@@ -29265,6 +29614,26 @@ class NodeContextStorage {
29265
29614
  return this.storage.getStore();
29266
29615
  }
29267
29616
  }
29617
+ // ../../common/src/telemetry/session-id.ts
29618
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
29619
+ var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
29620
+ var telemetrySessionIdSlot = singleton("TelemetrySessionId");
29621
+ function getProcessEnv() {
29622
+ return globalThis.process?.env;
29623
+ }
29624
+ function normalizeSessionId(value) {
29625
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
29626
+ return;
29627
+ }
29628
+ const trimmed = String(value).trim();
29629
+ return trimmed || undefined;
29630
+ }
29631
+ function getConfiguredTelemetrySessionId() {
29632
+ return normalizeSessionId(getProcessEnv()?.[TELEMETRY_SESSION_ID_ENV]);
29633
+ }
29634
+ function resolveTelemetrySessionId(existingSessionId) {
29635
+ return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
29636
+ }
29268
29637
  // ../../common/src/telemetry/telemetry-service.ts
29269
29638
  class TelemetryService {
29270
29639
  telemetryProvider;
@@ -29343,12 +29712,22 @@ class TelemetryService {
29343
29712
  return this.contextStorage.getContext();
29344
29713
  }
29345
29714
  enrichPropertiesWithContext(properties, context) {
29346
- return {
29347
- ...getGlobalTelemetryProperties(),
29715
+ const globalProperties = getGlobalTelemetryProperties();
29716
+ const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
29717
+ const sessionId = resolveTelemetrySessionId(existingSessionId);
29718
+ const enriched = {
29719
+ ...getExecutionContextTelemetryProperties(),
29720
+ ...globalProperties,
29348
29721
  ...this.defaultProperties,
29349
29722
  ...properties,
29350
29723
  ...context
29351
29724
  };
29725
+ if (sessionId === undefined) {
29726
+ delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
29727
+ } else {
29728
+ enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
29729
+ }
29730
+ return enriched;
29352
29731
  }
29353
29732
  generateId() {
29354
29733
  return crypto.randomUUID().replaceAll("-", "");
@@ -29818,8 +30197,24 @@ var OutputFormatter;
29818
30197
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
29819
30198
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
29820
30199
  process.exitCode = EXIT_CODES[data.Result] ?? 1;
29821
- const { SuppressTelemetry, ...envelope } = data;
29822
- if (!SuppressTelemetry) {
30200
+ recordCommandFailureTelemetry({
30201
+ result: data.Result,
30202
+ errorCode: data.ErrorCode,
30203
+ retry: data.Retry,
30204
+ message: data.Message,
30205
+ context: data.Context,
30206
+ exitCode: process.exitCode,
30207
+ errorClass: data.TelemetryErrorClass,
30208
+ terminalOutcome: data.TelemetryTerminalOutcome,
30209
+ terminalSignal: data.TelemetryTerminalSignal
30210
+ });
30211
+ const suppressTelemetry = data.SuppressTelemetry === true;
30212
+ const envelope = { ...data };
30213
+ delete envelope.SuppressTelemetry;
30214
+ delete envelope.TelemetryErrorClass;
30215
+ delete envelope.TelemetryTerminalOutcome;
30216
+ delete envelope.TelemetryTerminalSignal;
30217
+ if (!suppressTelemetry) {
29823
30218
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
29824
30219
  result: data.Result,
29825
30220
  errorCode: data.ErrorCode,
@@ -29882,6 +30277,158 @@ var OutputFormatter;
29882
30277
  OutputFormatter.formatToString = formatToString;
29883
30278
  })(OutputFormatter ||= {});
29884
30279
 
30280
+ // ../../common/src/telemetry/command-attribution.ts
30281
+ var LEGACY_SKILL_NAMESPACE = "uipath:";
30282
+ var MAX_SKILL_NAME_LENGTH = 80;
30283
+ var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
30284
+ function productMode(productArea, mode) {
30285
+ return { product_area: productArea, mode };
30286
+ }
30287
+ function attributionRecord(groups) {
30288
+ const record = {};
30289
+ for (const [productArea, mode, names] of groups) {
30290
+ const attribution = productMode(productArea, mode);
30291
+ for (const name of names) {
30292
+ record[name] = attribution;
30293
+ }
30294
+ }
30295
+ return record;
30296
+ }
30297
+ function commandAttribution(groups) {
30298
+ const entries = [];
30299
+ for (const [productArea, mode, prefixes] of groups) {
30300
+ const attribution = productMode(productArea, mode);
30301
+ for (const prefix of prefixes) {
30302
+ entries.push({ prefix, attribution });
30303
+ }
30304
+ }
30305
+ return entries;
30306
+ }
30307
+ var SKILL_ATTRIBUTION = attributionRecord([
30308
+ ["admin", "operate", ["uipath-admin"]],
30309
+ ["agents", "build", ["uipath-agents"]],
30310
+ ["api-workflow", "build", ["uipath-api-workflow"]],
30311
+ ["automation-discovery", "build", ["uipath-automation-discovery"]],
30312
+ ["coded-apps", "build", ["uipath-coded-apps"]],
30313
+ ["data-fabric", "operate", ["uipath-data-fabric"]],
30314
+ ["cli", "troubleshoot", ["uipath-feedback"]],
30315
+ ["governance", "operate", ["uipath-governance"]],
30316
+ ["action-center", "build", ["uipath-human-in-the-loop"]],
30317
+ ["document-understanding", "build", ["uipath-ixp"]],
30318
+ [
30319
+ "maestro",
30320
+ "build",
30321
+ ["uipath-maestro-bpmn", "uipath-maestro-case", "uipath-maestro-flow"]
30322
+ ],
30323
+ ["agenthub", "build", ["uipath-mcp-servers"]],
30324
+ ["solution", "build", ["uipath-planner", "uipath-solution"]],
30325
+ ["platform", "operate", ["uipath-platform"]],
30326
+ ["quality", "troubleshoot", ["uipath-review"]],
30327
+ ["rpa", "build", ["uipath-rpa"]],
30328
+ ["cli", "operate", ["uipath-skill-catalog"]],
30329
+ ["action-center", "operate", ["uipath-tasks"]],
30330
+ ["test-manager", "operate", ["uipath-test"]],
30331
+ ["platform", "troubleshoot", ["uipath-troubleshoot"]]
30332
+ ]);
30333
+ var KNOWN_SKILL_NAMES = new Set(Object.keys(SKILL_ATTRIBUTION));
30334
+ var COMMAND_ATTRIBUTION = commandAttribution([
30335
+ ["cli", "troubleshoot", ["uip.feedback"]],
30336
+ ["llm-gateway", "operate", ["uip.llm-configuration", "uip.model-hub"]],
30337
+ ["context-grounding", "build", ["uip.context-grounding"]],
30338
+ ["api-workflow", "build", ["uip.api-workflow"]],
30339
+ ["rpa", "build", ["uip.rpa-legacy"]],
30340
+ ["conversational", "operate", ["uip.conversational"]],
30341
+ ["agents", "build", ["uip.codedagent", "uip.agent"]],
30342
+ ["agenthub", "build", ["uip.agenthub"]],
30343
+ ["coded-apps", "build", ["uip.codedapp"]],
30344
+ ["functions", "build", ["uip.functions"]],
30345
+ ["solution", "build", ["uip.solution"]],
30346
+ ["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
30347
+ ["llm-observability", "troubleshoot", ["uip.traces"]],
30348
+ ["platform", "operate", ["uip.platform"]],
30349
+ ["admin", "operate", ["uip.admin"]],
30350
+ ["automation-ops", "operate", ["uip.aops"]],
30351
+ ["documentation", "troubleshoot", ["uip.docsai"]],
30352
+ ["governance", "operate", ["uip.gov"]],
30353
+ ["insights", "operate", ["uip.insights"]],
30354
+ ["document-understanding", "build", ["uip.ixp"]],
30355
+ ["process-mining", "operate", ["uip.pm"]],
30356
+ ["action-center", "operate", ["uip.tasks"]],
30357
+ ["test-manager", "operate", ["uip.tm"]],
30358
+ ["vertical-solutions", "build", ["uip.vss"]],
30359
+ ["data-fabric", "operate", ["uip.df"]],
30360
+ ["integration-service", "build", ["uip.is"]],
30361
+ ["orchestrator", "operate", ["uip.or"]],
30362
+ [
30363
+ "cli",
30364
+ "operate",
30365
+ [
30366
+ "uip.login",
30367
+ "uip.logout",
30368
+ "uip.user",
30369
+ "uip.config",
30370
+ "uip.tools",
30371
+ "uip.skills",
30372
+ "uip.completion",
30373
+ "uip.update",
30374
+ "uip.mcp",
30375
+ "uip.track"
30376
+ ]
30377
+ ]
30378
+ ]).sort((a, b) => b.prefix.length - a.prefix.length);
30379
+ function normalizeCommandPath(value) {
30380
+ if (typeof value !== "string") {
30381
+ return;
30382
+ }
30383
+ const trimmed = value.trim().toLowerCase();
30384
+ if (!trimmed) {
30385
+ return;
30386
+ }
30387
+ const tokens = trimmed.includes(" ") ? trimmed.split(/\s+/).filter((token) => token.length > 0).filter((token) => !token.startsWith("-")) : trimmed.split(".").filter((token) => token.length > 0);
30388
+ if (tokens.length === 0) {
30389
+ return;
30390
+ }
30391
+ const commandTokens = tokens[0] === "uip" ? tokens : ["uip", ...tokens];
30392
+ return commandTokens.join(".");
30393
+ }
30394
+ function getCommandProductModeAttribution(commandPath) {
30395
+ const normalized = normalizeCommandPath(commandPath);
30396
+ if (!normalized) {
30397
+ return;
30398
+ }
30399
+ return COMMAND_ATTRIBUTION.find(({ prefix }) => normalized === prefix || normalized.startsWith(`${prefix}.`))?.attribution;
30400
+ }
30401
+ function normalizeSkillNameWithOptions(value, options) {
30402
+ if (typeof value !== "string") {
30403
+ return;
30404
+ }
30405
+ const normalized = value.trim().toLowerCase();
30406
+ if (!normalized) {
30407
+ return;
30408
+ }
30409
+ const hasLegacyNamespace = normalized.startsWith(LEGACY_SKILL_NAMESPACE);
30410
+ if (hasLegacyNamespace && !options.allowLegacyNamespace) {
30411
+ return;
30412
+ }
30413
+ const skillName = hasLegacyNamespace ? normalized.slice(LEGACY_SKILL_NAMESPACE.length) : normalized;
30414
+ if (skillName.length > MAX_SKILL_NAME_LENGTH || !SKILL_NAME_PATTERN.test(skillName) || !KNOWN_SKILL_NAMES.has(skillName)) {
30415
+ return;
30416
+ }
30417
+ return skillName;
30418
+ }
30419
+ function normalizeSkillName(value) {
30420
+ return normalizeSkillNameWithOptions(value, {
30421
+ allowLegacyNamespace: false
30422
+ });
30423
+ }
30424
+ function buildCommandTelemetryAttribution(commandPath, skillSource) {
30425
+ const skillName = normalizeSkillName(skillSource);
30426
+ return {
30427
+ ...skillName ? { skill_name: skillName } : {},
30428
+ ...getCommandProductModeAttribution(commandPath)
30429
+ };
30430
+ }
30431
+
29885
30432
  // ../../common/src/telemetry/pii-redactor.ts
29886
30433
  var REDACTED = "[REDACTED]";
29887
30434
  var MAX_VALUE_LENGTH = 200;
@@ -30067,6 +30614,12 @@ function commandHelpHint(commandPath) {
30067
30614
  const command = commandPath.replace(/\./g, " ");
30068
30615
  return `An unexpected error occurred. Run '${command} --help' to verify command syntax, or run with --log-level debug for details.`;
30069
30616
  }
30617
+ function isPromptCancellation(error) {
30618
+ return error instanceof Error && error.name === "ExitPromptError";
30619
+ }
30620
+ function exitCodeFromProcess(fallback) {
30621
+ return typeof process.exitCode === "number" ? process.exitCode : fallback;
30622
+ }
30070
30623
  Command.prototype.trackedAction = function(context, fn, properties) {
30071
30624
  const command = this;
30072
30625
  return this.action(async (...args) => {
@@ -30074,6 +30627,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
30074
30627
  const props = typeof properties === "function" ? properties(...args) : properties;
30075
30628
  const startTime = performance.now();
30076
30629
  let errorMessage2;
30630
+ let fallbackExitCode = EXIT_CODES.Success;
30631
+ clearRecordedCommandFailureTelemetry();
30077
30632
  const [error] = await catchError2(fn(...args));
30078
30633
  if (error) {
30079
30634
  errorMessage2 = error instanceof Error ? error.message : String(error);
@@ -30088,6 +30643,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
30088
30643
  const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
30089
30644
  const typedContext = typed.context ?? typed.Context;
30090
30645
  const customContext = isErrorContext(typedContext) ? typedContext : undefined;
30646
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
30647
+ fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
30091
30648
  OutputFormatter.error({
30092
30649
  Result: finalResult,
30093
30650
  ...customErrorCode ? { ErrorCode: customErrorCode } : {},
@@ -30096,16 +30653,26 @@ Command.prototype.trackedAction = function(context, fn, properties) {
30096
30653
  ...customRetry ? { Retry: customRetry } : {},
30097
30654
  ...customContext ? { Context: customContext } : {}
30098
30655
  });
30099
- context.exit(EXIT_CODES[finalResult]);
30656
+ context.exit(fallbackExitCode);
30100
30657
  }
30101
30658
  const durationMs = performance.now() - startTime;
30102
- const success = !error && (process.exitCode === undefined || process.exitCode === 0);
30659
+ const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
30660
+ const recordedFailure = takeRecordedCommandFailureTelemetry();
30661
+ const success = !error && exitCode === 0;
30662
+ const terminalTelemetry = buildCommandTerminalTelemetryProperties({
30663
+ error,
30664
+ exitCode,
30665
+ recordedFailure,
30666
+ pollSignal: context.pollSignal
30667
+ });
30103
30668
  telemetry.trackEvent(telemetryName, redactProperties({
30104
30669
  ...extractCommandParams(command),
30105
30670
  ...props,
30671
+ ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
30106
30672
  command: "true",
30107
30673
  duration: String(durationMs),
30108
30674
  success: String(success),
30675
+ ...terminalTelemetry,
30109
30676
  ...errorMessage2 ? { errorMessage: errorMessage2 } : {}
30110
30677
  }));
30111
30678
  });
@@ -30171,6 +30738,8 @@ var ScreenLogger;
30171
30738
  }
30172
30739
  ScreenLogger.progress = progress;
30173
30740
  })(ScreenLogger ||= {});
30741
+ // ../../common/src/telemetry/ship-succeeded.ts
30742
+ var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
30174
30743
  // ../../common/src/tool-provider.ts
30175
30744
  var factorySlot = singleton("PackagerFactoryProvider");
30176
30745
  // src/commands/_shared.ts
@@ -31315,4 +31884,4 @@ program2.name(metadata.commandPrefix).description(metadata.description).version(
31315
31884
  await registerCommands(program2);
31316
31885
  program2.parse(process.argv);
31317
31886
 
31318
- //# debugId=E3F6AAF9A3C2BA9C64756E2164756E21
31887
+ //# debugId=96F3E9B3FE35795E64756E2164756E21
package/dist/tool.js CHANGED
@@ -19137,7 +19137,7 @@ var init_server = __esm(() => {
19137
19137
  var package_default = {
19138
19138
  name: "@uipath/apms-tool",
19139
19139
  license: "MIT",
19140
- version: "1.197.0-preview.65",
19140
+ version: "1.197.0-preview.67",
19141
19141
  description: "CLI plugin for the UiPath Access Policy Management Service.",
19142
19142
  private: false,
19143
19143
  repository: {
@@ -27075,9 +27075,228 @@ function getOutputFilter() {
27075
27075
  return filterSlot.get();
27076
27076
  }
27077
27077
 
27078
+ // ../../common/src/telemetry/command-terminal.ts
27079
+ var recordedFailureSlot = singleton("CommandTelemetryFailure");
27080
+ var AUTH_ERROR_CODES = new Set([
27081
+ "authentication_required",
27082
+ "permission_denied"
27083
+ ]);
27084
+ var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
27085
+ var NETWORK_HTTP_ERROR_CODES = new Set([
27086
+ "network_error",
27087
+ "rate_limited",
27088
+ "server_error",
27089
+ "not_found",
27090
+ "method_not_allowed"
27091
+ ]);
27092
+ var TIMEOUT_ERROR_CODES = new Set(["timeout"]);
27093
+ var NETWORK_OS_ERROR_CODES = new Set([
27094
+ "ECONNREFUSED",
27095
+ "ECONNRESET",
27096
+ "ENOTFOUND",
27097
+ "EAI_AGAIN",
27098
+ "EPIPE",
27099
+ "EHOSTUNREACH",
27100
+ "ENETUNREACH",
27101
+ "EAI_FAIL"
27102
+ ]);
27103
+ var TIMEOUT_OS_ERROR_CODES = new Set(["ETIMEDOUT", "ESOCKETTIMEDOUT"]);
27104
+ var TLS_ERROR_CODES2 = new Set([
27105
+ "SELF_SIGNED_CERT_IN_CHAIN",
27106
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
27107
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
27108
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
27109
+ "UNABLE_TO_GET_ISSUER_CERT",
27110
+ "CERT_HAS_EXPIRED",
27111
+ "CERT_UNTRUSTED",
27112
+ "ERR_TLS_CERT_ALTNAME_INVALID"
27113
+ ]);
27114
+ var MISSING_DEPENDENCY_CODES = new Set([
27115
+ "MODULE_NOT_FOUND",
27116
+ "ERR_MODULE_NOT_FOUND"
27117
+ ]);
27118
+ var INTERNAL_ERROR_NAMES = new Set([
27119
+ "TypeError",
27120
+ "ReferenceError",
27121
+ "SyntaxError",
27122
+ "RangeError"
27123
+ ]);
27124
+ function isRecord(value) {
27125
+ return value !== null && typeof value === "object";
27126
+ }
27127
+ function stringField(value, field) {
27128
+ if (!isRecord(value)) {
27129
+ return;
27130
+ }
27131
+ const raw = value[field];
27132
+ return typeof raw === "string" ? raw : undefined;
27133
+ }
27134
+ function numberField(value, field) {
27135
+ if (!isRecord(value)) {
27136
+ return;
27137
+ }
27138
+ const raw = value[field];
27139
+ return typeof raw === "number" ? raw : undefined;
27140
+ }
27141
+ function findStringInCauseChain(error, field) {
27142
+ let current = error;
27143
+ for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
27144
+ const value = stringField(current, field);
27145
+ if (value) {
27146
+ return value;
27147
+ }
27148
+ current = current.cause;
27149
+ }
27150
+ return;
27151
+ }
27152
+ function findCodeInCauseChain(error) {
27153
+ return findStringInCauseChain(error, "code");
27154
+ }
27155
+ function isSpawnEnoent(error) {
27156
+ const code = findCodeInCauseChain(error);
27157
+ if (code !== "ENOENT") {
27158
+ return false;
27159
+ }
27160
+ const syscall = findStringInCauseChain(error, "syscall");
27161
+ return syscall?.startsWith("spawn") === true;
27162
+ }
27163
+ function isCancellationError(error, exitCode, pollSignal) {
27164
+ if (exitCode === 130) {
27165
+ return true;
27166
+ }
27167
+ if (!isRecord(error)) {
27168
+ return false;
27169
+ }
27170
+ if (numberField(error, "exitCode") === 130) {
27171
+ return true;
27172
+ }
27173
+ const name = stringField(error, "name");
27174
+ if (name === "ExitPromptError") {
27175
+ return true;
27176
+ }
27177
+ if (name === "AbortError" && pollSignal?.aborted) {
27178
+ return true;
27179
+ }
27180
+ const message = stringField(error, "message");
27181
+ return message?.includes("SIGINT") === true;
27182
+ }
27183
+ function terminalSignalFor(input, outcome) {
27184
+ if (input.recordedFailure?.terminalSignal) {
27185
+ return input.recordedFailure.terminalSignal;
27186
+ }
27187
+ const explicit = findStringInCauseChain(input.error, "terminalSignal") ?? findStringInCauseChain(input.error, "signal");
27188
+ if (explicit) {
27189
+ return explicit;
27190
+ }
27191
+ return outcome === "cancelled" ? "SIGINT" : undefined;
27192
+ }
27193
+ function classifyHttpStatus(status) {
27194
+ if (status === 401 || status === 403) {
27195
+ return "auth";
27196
+ }
27197
+ if (status === 400 || status === 409 || status === 422) {
27198
+ return "validation";
27199
+ }
27200
+ if (status === 408) {
27201
+ return "timeout";
27202
+ }
27203
+ return "network_http";
27204
+ }
27205
+ function classifyFromResult(result) {
27206
+ switch (result) {
27207
+ case "AuthenticationError":
27208
+ return "auth";
27209
+ case "ValidationError":
27210
+ return "validation";
27211
+ case "TimeoutError":
27212
+ return "timeout";
27213
+ default:
27214
+ return;
27215
+ }
27216
+ }
27217
+ function classifyFromErrorCode(errorCode2) {
27218
+ if (!errorCode2) {
27219
+ return;
27220
+ }
27221
+ if (AUTH_ERROR_CODES.has(errorCode2)) {
27222
+ return "auth";
27223
+ }
27224
+ if (VALIDATION_ERROR_CODES.has(errorCode2)) {
27225
+ return "validation";
27226
+ }
27227
+ if (TIMEOUT_ERROR_CODES.has(errorCode2)) {
27228
+ return "timeout";
27229
+ }
27230
+ if (NETWORK_HTTP_ERROR_CODES.has(errorCode2)) {
27231
+ return "network_http";
27232
+ }
27233
+ return;
27234
+ }
27235
+ function classifyFromError(error) {
27236
+ const code = findCodeInCauseChain(error);
27237
+ if (code) {
27238
+ if (code.startsWith("commander.")) {
27239
+ return "validation";
27240
+ }
27241
+ if (NETWORK_OS_ERROR_CODES.has(code) || TLS_ERROR_CODES2.has(code)) {
27242
+ return "network_http";
27243
+ }
27244
+ if (TIMEOUT_OS_ERROR_CODES.has(code)) {
27245
+ return "timeout";
27246
+ }
27247
+ if (MISSING_DEPENDENCY_CODES.has(code) || isSpawnEnoent(error)) {
27248
+ return "missing_dependency";
27249
+ }
27250
+ }
27251
+ const message = stringField(error, "message");
27252
+ if (message?.includes("fetch failed") === true) {
27253
+ return "network_http";
27254
+ }
27255
+ const name = stringField(error, "name");
27256
+ if (name && INTERNAL_ERROR_NAMES.has(name)) {
27257
+ return "internal";
27258
+ }
27259
+ return;
27260
+ }
27261
+ function classifyError2(input) {
27262
+ const recorded = input.recordedFailure;
27263
+ if (recorded?.errorClass) {
27264
+ return recorded.errorClass;
27265
+ }
27266
+ const status = recorded?.context?.httpStatus;
27267
+ if (status !== undefined) {
27268
+ return classifyHttpStatus(status);
27269
+ }
27270
+ return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
27271
+ }
27272
+ function recordCommandFailureTelemetry(failure) {
27273
+ recordedFailureSlot.set(failure);
27274
+ }
27275
+ function clearRecordedCommandFailureTelemetry() {
27276
+ recordedFailureSlot.clear();
27277
+ }
27278
+ function takeRecordedCommandFailureTelemetry() {
27279
+ const failure = recordedFailureSlot.get();
27280
+ recordedFailureSlot.clear();
27281
+ return failure;
27282
+ }
27283
+ function buildCommandTerminalTelemetryProperties(input) {
27284
+ const cancelled = isCancellationError(input.error, input.exitCode, input.pollSignal);
27285
+ const outcome = input.recordedFailure?.terminalOutcome ?? (input.exitCode === 0 ? "success" : cancelled ? "cancelled" : "failure");
27286
+ const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError2(input);
27287
+ const terminalSignal = terminalSignalFor(input, outcome);
27288
+ return {
27289
+ exit_code: input.exitCode,
27290
+ terminal_outcome: outcome,
27291
+ ...errorClass ? { error_class: errorClass } : {},
27292
+ ...terminalSignal ? { terminal_signal: terminalSignal } : {}
27293
+ };
27294
+ }
27295
+
27078
27296
  // ../../common/src/telemetry/telemetry-events.ts
27079
27297
  var CommonTelemetryEvents = {
27080
- Error: "uip.error"
27298
+ Error: "uip.error",
27299
+ ShipSucceeded: "ship_succeeded"
27081
27300
  };
27082
27301
 
27083
27302
  // ../../common/src/registry.ts
@@ -27144,6 +27363,136 @@ function formatMessage(category, name, properties) {
27144
27363
  }
27145
27364
  return message;
27146
27365
  }
27366
+ // ../../common/src/telemetry/detect-agent.ts
27367
+ var KNOWN_AGENTS = [
27368
+ { envVar: "CLAUDECODE", value: "1", id: "claude-code" },
27369
+ { envVar: "CURSOR_AGENT", value: "1", id: "cursor" },
27370
+ { envVar: "GEMINI_CLI", value: "1", id: "gemini-cli" },
27371
+ { envVar: "CODEX_THREAD_ID", id: "codex" },
27372
+ { envVar: "CODEX_SANDBOX", id: "codex" },
27373
+ { envVar: "AUGMENT_AGENT", value: "1", id: "augment" },
27374
+ { envVar: "CLINE_ACTIVE", value: "true", id: "cline" }
27375
+ ];
27376
+ function detectAgentFromEnv(env) {
27377
+ for (const agent of KNOWN_AGENTS) {
27378
+ const envValue = env[agent.envVar];
27379
+ if (agent.value !== undefined) {
27380
+ if (envValue === agent.value)
27381
+ return agent.id;
27382
+ } else {
27383
+ if (envValue)
27384
+ return agent.id;
27385
+ }
27386
+ }
27387
+ const agentEnv = env.AGENT;
27388
+ if (agentEnv) {
27389
+ if (agentEnv === "1" || agentEnv === "true")
27390
+ return "unknown";
27391
+ if (agentEnv.length <= 32)
27392
+ return agentEnv.toLowerCase();
27393
+ }
27394
+ return;
27395
+ }
27396
+ // ../../common/src/telemetry/environment-info.ts
27397
+ var LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
27398
+ // ../../common/src/telemetry/execution-context.ts
27399
+ var authSignalSlot = singleton("TelemetryExecutionContextAuthSignal");
27400
+ var isTruthy = (value) => value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
27401
+ var isEqual = (value, expected) => value?.toLowerCase() === expected;
27402
+ var CI_SIGNATURES = [
27403
+ {
27404
+ provider: "github_actions",
27405
+ matches: (env) => isTruthy(env.GITHUB_ACTIONS),
27406
+ isScheduler: (env) => env.GITHUB_EVENT_NAME === "schedule"
27407
+ },
27408
+ {
27409
+ provider: "azure_devops",
27410
+ matches: (env) => isTruthy(env.TF_BUILD),
27411
+ isScheduler: (env) => isEqual(env.BUILD_REASON, "schedule")
27412
+ },
27413
+ {
27414
+ provider: "gitlab",
27415
+ matches: (env) => isTruthy(env.GITLAB_CI),
27416
+ isScheduler: (env) => env.CI_PIPELINE_SOURCE === "schedule"
27417
+ },
27418
+ {
27419
+ provider: "circleci",
27420
+ matches: (env) => isTruthy(env.CIRCLECI),
27421
+ isScheduler: (env) => env.CIRCLE_PIPELINE_TRIGGER_SOURCE === "scheduled_pipeline"
27422
+ },
27423
+ {
27424
+ provider: "jenkins",
27425
+ matches: (env) => isTruthy(env.JENKINS_URL) || isTruthy(env.JENKINS_HOME)
27426
+ },
27427
+ {
27428
+ provider: "teamcity",
27429
+ matches: (env) => isTruthy(env.TEAMCITY_VERSION)
27430
+ },
27431
+ {
27432
+ provider: "buildkite",
27433
+ matches: (env) => isTruthy(env.BUILDKITE),
27434
+ isScheduler: (env) => env.BUILDKITE_SOURCE === "schedule"
27435
+ },
27436
+ {
27437
+ provider: "bitbucket",
27438
+ matches: (env) => isTruthy(env.BITBUCKET_BUILD_NUMBER)
27439
+ },
27440
+ {
27441
+ provider: "travis",
27442
+ matches: (env) => isTruthy(env.TRAVIS)
27443
+ },
27444
+ {
27445
+ provider: "appveyor",
27446
+ matches: (env) => isTruthy(env.APPVEYOR)
27447
+ },
27448
+ {
27449
+ provider: "generic",
27450
+ matches: (env) => isTruthy(env.CI)
27451
+ }
27452
+ ];
27453
+ function currentEnv() {
27454
+ return typeof process === "undefined" ? {} : process.env;
27455
+ }
27456
+ function currentTtyState() {
27457
+ if (typeof process === "undefined")
27458
+ return false;
27459
+ return Boolean(process.stdout?.isTTY || process.stdin?.isTTY || process.stderr?.isTTY);
27460
+ }
27461
+ function detectCi(env) {
27462
+ const signature = CI_SIGNATURES.find((candidate) => candidate.matches(env));
27463
+ if (!signature)
27464
+ return;
27465
+ return {
27466
+ executionContext: signature.isScheduler?.(env) ? "scheduler" : "ci",
27467
+ ciProvider: signature.provider
27468
+ };
27469
+ }
27470
+ function detectExecutionContext(options = {}) {
27471
+ const env = options.env ?? currentEnv();
27472
+ const ci = detectCi(env);
27473
+ if (ci)
27474
+ return ci;
27475
+ const agent = options.agent ?? detectAgentFromEnv(env);
27476
+ if (agent) {
27477
+ return { executionContext: "agent" };
27478
+ }
27479
+ const authSignal = options.authSignal ?? authSignalSlot.get();
27480
+ if (authSignal === "service_account") {
27481
+ return { executionContext: "service_account" };
27482
+ }
27483
+ const isTty = options.isTty ?? currentTtyState();
27484
+ if (isTty) {
27485
+ return { executionContext: "manual" };
27486
+ }
27487
+ return { executionContext: "unknown" };
27488
+ }
27489
+ function getExecutionContextTelemetryProperties() {
27490
+ const detected = detectExecutionContext();
27491
+ return {
27492
+ execution_context: detected.executionContext,
27493
+ ...detected.ciProvider ? { ci_provider: detected.ciProvider } : {}
27494
+ };
27495
+ }
27147
27496
  // ../../common/src/telemetry/node-context-storage.ts
27148
27497
  import { AsyncLocalStorage } from "node:async_hooks";
27149
27498
 
@@ -27156,6 +27505,26 @@ class NodeContextStorage {
27156
27505
  return this.storage.getStore();
27157
27506
  }
27158
27507
  }
27508
+ // ../../common/src/telemetry/session-id.ts
27509
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
27510
+ var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
27511
+ var telemetrySessionIdSlot = singleton("TelemetrySessionId");
27512
+ function getProcessEnv() {
27513
+ return globalThis.process?.env;
27514
+ }
27515
+ function normalizeSessionId(value) {
27516
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
27517
+ return;
27518
+ }
27519
+ const trimmed = String(value).trim();
27520
+ return trimmed || undefined;
27521
+ }
27522
+ function getConfiguredTelemetrySessionId() {
27523
+ return normalizeSessionId(getProcessEnv()?.[TELEMETRY_SESSION_ID_ENV]);
27524
+ }
27525
+ function resolveTelemetrySessionId(existingSessionId) {
27526
+ return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
27527
+ }
27159
27528
  // ../../common/src/telemetry/telemetry-service.ts
27160
27529
  class TelemetryService {
27161
27530
  telemetryProvider;
@@ -27234,12 +27603,22 @@ class TelemetryService {
27234
27603
  return this.contextStorage.getContext();
27235
27604
  }
27236
27605
  enrichPropertiesWithContext(properties, context) {
27237
- return {
27238
- ...getGlobalTelemetryProperties(),
27606
+ const globalProperties = getGlobalTelemetryProperties();
27607
+ const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
27608
+ const sessionId = resolveTelemetrySessionId(existingSessionId);
27609
+ const enriched = {
27610
+ ...getExecutionContextTelemetryProperties(),
27611
+ ...globalProperties,
27239
27612
  ...this.defaultProperties,
27240
27613
  ...properties,
27241
27614
  ...context
27242
27615
  };
27616
+ if (sessionId === undefined) {
27617
+ delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
27618
+ } else {
27619
+ enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
27620
+ }
27621
+ return enriched;
27243
27622
  }
27244
27623
  generateId() {
27245
27624
  return crypto.randomUUID().replaceAll("-", "");
@@ -27709,8 +28088,24 @@ var OutputFormatter;
27709
28088
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
27710
28089
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
27711
28090
  process.exitCode = EXIT_CODES[data.Result] ?? 1;
27712
- const { SuppressTelemetry, ...envelope } = data;
27713
- if (!SuppressTelemetry) {
28091
+ recordCommandFailureTelemetry({
28092
+ result: data.Result,
28093
+ errorCode: data.ErrorCode,
28094
+ retry: data.Retry,
28095
+ message: data.Message,
28096
+ context: data.Context,
28097
+ exitCode: process.exitCode,
28098
+ errorClass: data.TelemetryErrorClass,
28099
+ terminalOutcome: data.TelemetryTerminalOutcome,
28100
+ terminalSignal: data.TelemetryTerminalSignal
28101
+ });
28102
+ const suppressTelemetry = data.SuppressTelemetry === true;
28103
+ const envelope = { ...data };
28104
+ delete envelope.SuppressTelemetry;
28105
+ delete envelope.TelemetryErrorClass;
28106
+ delete envelope.TelemetryTerminalOutcome;
28107
+ delete envelope.TelemetryTerminalSignal;
28108
+ if (!suppressTelemetry) {
27714
28109
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
27715
28110
  result: data.Result,
27716
28111
  errorCode: data.ErrorCode,
@@ -27776,6 +28171,158 @@ var OutputFormatter;
27776
28171
  // ../../common/src/trackedAction.ts
27777
28172
  import { Command as Command2 } from "commander";
27778
28173
 
28174
+ // ../../common/src/telemetry/command-attribution.ts
28175
+ var LEGACY_SKILL_NAMESPACE = "uipath:";
28176
+ var MAX_SKILL_NAME_LENGTH = 80;
28177
+ var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
28178
+ function productMode(productArea, mode) {
28179
+ return { product_area: productArea, mode };
28180
+ }
28181
+ function attributionRecord(groups) {
28182
+ const record = {};
28183
+ for (const [productArea, mode, names] of groups) {
28184
+ const attribution = productMode(productArea, mode);
28185
+ for (const name of names) {
28186
+ record[name] = attribution;
28187
+ }
28188
+ }
28189
+ return record;
28190
+ }
28191
+ function commandAttribution(groups) {
28192
+ const entries = [];
28193
+ for (const [productArea, mode, prefixes] of groups) {
28194
+ const attribution = productMode(productArea, mode);
28195
+ for (const prefix of prefixes) {
28196
+ entries.push({ prefix, attribution });
28197
+ }
28198
+ }
28199
+ return entries;
28200
+ }
28201
+ var SKILL_ATTRIBUTION = attributionRecord([
28202
+ ["admin", "operate", ["uipath-admin"]],
28203
+ ["agents", "build", ["uipath-agents"]],
28204
+ ["api-workflow", "build", ["uipath-api-workflow"]],
28205
+ ["automation-discovery", "build", ["uipath-automation-discovery"]],
28206
+ ["coded-apps", "build", ["uipath-coded-apps"]],
28207
+ ["data-fabric", "operate", ["uipath-data-fabric"]],
28208
+ ["cli", "troubleshoot", ["uipath-feedback"]],
28209
+ ["governance", "operate", ["uipath-governance"]],
28210
+ ["action-center", "build", ["uipath-human-in-the-loop"]],
28211
+ ["document-understanding", "build", ["uipath-ixp"]],
28212
+ [
28213
+ "maestro",
28214
+ "build",
28215
+ ["uipath-maestro-bpmn", "uipath-maestro-case", "uipath-maestro-flow"]
28216
+ ],
28217
+ ["agenthub", "build", ["uipath-mcp-servers"]],
28218
+ ["solution", "build", ["uipath-planner", "uipath-solution"]],
28219
+ ["platform", "operate", ["uipath-platform"]],
28220
+ ["quality", "troubleshoot", ["uipath-review"]],
28221
+ ["rpa", "build", ["uipath-rpa"]],
28222
+ ["cli", "operate", ["uipath-skill-catalog"]],
28223
+ ["action-center", "operate", ["uipath-tasks"]],
28224
+ ["test-manager", "operate", ["uipath-test"]],
28225
+ ["platform", "troubleshoot", ["uipath-troubleshoot"]]
28226
+ ]);
28227
+ var KNOWN_SKILL_NAMES = new Set(Object.keys(SKILL_ATTRIBUTION));
28228
+ var COMMAND_ATTRIBUTION = commandAttribution([
28229
+ ["cli", "troubleshoot", ["uip.feedback"]],
28230
+ ["llm-gateway", "operate", ["uip.llm-configuration", "uip.model-hub"]],
28231
+ ["context-grounding", "build", ["uip.context-grounding"]],
28232
+ ["api-workflow", "build", ["uip.api-workflow"]],
28233
+ ["rpa", "build", ["uip.rpa-legacy"]],
28234
+ ["conversational", "operate", ["uip.conversational"]],
28235
+ ["agents", "build", ["uip.codedagent", "uip.agent"]],
28236
+ ["agenthub", "build", ["uip.agenthub"]],
28237
+ ["coded-apps", "build", ["uip.codedapp"]],
28238
+ ["functions", "build", ["uip.functions"]],
28239
+ ["solution", "build", ["uip.solution"]],
28240
+ ["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
28241
+ ["llm-observability", "troubleshoot", ["uip.traces"]],
28242
+ ["platform", "operate", ["uip.platform"]],
28243
+ ["admin", "operate", ["uip.admin"]],
28244
+ ["automation-ops", "operate", ["uip.aops"]],
28245
+ ["documentation", "troubleshoot", ["uip.docsai"]],
28246
+ ["governance", "operate", ["uip.gov"]],
28247
+ ["insights", "operate", ["uip.insights"]],
28248
+ ["document-understanding", "build", ["uip.ixp"]],
28249
+ ["process-mining", "operate", ["uip.pm"]],
28250
+ ["action-center", "operate", ["uip.tasks"]],
28251
+ ["test-manager", "operate", ["uip.tm"]],
28252
+ ["vertical-solutions", "build", ["uip.vss"]],
28253
+ ["data-fabric", "operate", ["uip.df"]],
28254
+ ["integration-service", "build", ["uip.is"]],
28255
+ ["orchestrator", "operate", ["uip.or"]],
28256
+ [
28257
+ "cli",
28258
+ "operate",
28259
+ [
28260
+ "uip.login",
28261
+ "uip.logout",
28262
+ "uip.user",
28263
+ "uip.config",
28264
+ "uip.tools",
28265
+ "uip.skills",
28266
+ "uip.completion",
28267
+ "uip.update",
28268
+ "uip.mcp",
28269
+ "uip.track"
28270
+ ]
28271
+ ]
28272
+ ]).sort((a, b) => b.prefix.length - a.prefix.length);
28273
+ function normalizeCommandPath(value) {
28274
+ if (typeof value !== "string") {
28275
+ return;
28276
+ }
28277
+ const trimmed = value.trim().toLowerCase();
28278
+ if (!trimmed) {
28279
+ return;
28280
+ }
28281
+ const tokens = trimmed.includes(" ") ? trimmed.split(/\s+/).filter((token) => token.length > 0).filter((token) => !token.startsWith("-")) : trimmed.split(".").filter((token) => token.length > 0);
28282
+ if (tokens.length === 0) {
28283
+ return;
28284
+ }
28285
+ const commandTokens = tokens[0] === "uip" ? tokens : ["uip", ...tokens];
28286
+ return commandTokens.join(".");
28287
+ }
28288
+ function getCommandProductModeAttribution(commandPath) {
28289
+ const normalized = normalizeCommandPath(commandPath);
28290
+ if (!normalized) {
28291
+ return;
28292
+ }
28293
+ return COMMAND_ATTRIBUTION.find(({ prefix }) => normalized === prefix || normalized.startsWith(`${prefix}.`))?.attribution;
28294
+ }
28295
+ function normalizeSkillNameWithOptions(value, options) {
28296
+ if (typeof value !== "string") {
28297
+ return;
28298
+ }
28299
+ const normalized = value.trim().toLowerCase();
28300
+ if (!normalized) {
28301
+ return;
28302
+ }
28303
+ const hasLegacyNamespace = normalized.startsWith(LEGACY_SKILL_NAMESPACE);
28304
+ if (hasLegacyNamespace && !options.allowLegacyNamespace) {
28305
+ return;
28306
+ }
28307
+ const skillName = hasLegacyNamespace ? normalized.slice(LEGACY_SKILL_NAMESPACE.length) : normalized;
28308
+ if (skillName.length > MAX_SKILL_NAME_LENGTH || !SKILL_NAME_PATTERN.test(skillName) || !KNOWN_SKILL_NAMES.has(skillName)) {
28309
+ return;
28310
+ }
28311
+ return skillName;
28312
+ }
28313
+ function normalizeSkillName(value) {
28314
+ return normalizeSkillNameWithOptions(value, {
28315
+ allowLegacyNamespace: false
28316
+ });
28317
+ }
28318
+ function buildCommandTelemetryAttribution(commandPath, skillSource) {
28319
+ const skillName = normalizeSkillName(skillSource);
28320
+ return {
28321
+ ...skillName ? { skill_name: skillName } : {},
28322
+ ...getCommandProductModeAttribution(commandPath)
28323
+ };
28324
+ }
28325
+
27779
28326
  // ../../common/src/telemetry/pii-redactor.ts
27780
28327
  var REDACTED = "[REDACTED]";
27781
28328
  var MAX_VALUE_LENGTH = 200;
@@ -27961,6 +28508,12 @@ function commandHelpHint(commandPath) {
27961
28508
  const command = commandPath.replace(/\./g, " ");
27962
28509
  return `An unexpected error occurred. Run '${command} --help' to verify command syntax, or run with --log-level debug for details.`;
27963
28510
  }
28511
+ function isPromptCancellation(error) {
28512
+ return error instanceof Error && error.name === "ExitPromptError";
28513
+ }
28514
+ function exitCodeFromProcess(fallback) {
28515
+ return typeof process.exitCode === "number" ? process.exitCode : fallback;
28516
+ }
27964
28517
  Command2.prototype.trackedAction = function(context, fn, properties) {
27965
28518
  const command = this;
27966
28519
  return this.action(async (...args) => {
@@ -27968,6 +28521,8 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
27968
28521
  const props = typeof properties === "function" ? properties(...args) : properties;
27969
28522
  const startTime = performance.now();
27970
28523
  let errorMessage2;
28524
+ let fallbackExitCode = EXIT_CODES.Success;
28525
+ clearRecordedCommandFailureTelemetry();
27971
28526
  const [error] = await catchError2(fn(...args));
27972
28527
  if (error) {
27973
28528
  errorMessage2 = error instanceof Error ? error.message : String(error);
@@ -27982,6 +28537,8 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
27982
28537
  const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
27983
28538
  const typedContext = typed.context ?? typed.Context;
27984
28539
  const customContext = isErrorContext(typedContext) ? typedContext : undefined;
28540
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
28541
+ fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
27985
28542
  OutputFormatter.error({
27986
28543
  Result: finalResult,
27987
28544
  ...customErrorCode ? { ErrorCode: customErrorCode } : {},
@@ -27990,16 +28547,26 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
27990
28547
  ...customRetry ? { Retry: customRetry } : {},
27991
28548
  ...customContext ? { Context: customContext } : {}
27992
28549
  });
27993
- context.exit(EXIT_CODES[finalResult]);
28550
+ context.exit(fallbackExitCode);
27994
28551
  }
27995
28552
  const durationMs = performance.now() - startTime;
27996
- const success = !error && (process.exitCode === undefined || process.exitCode === 0);
28553
+ const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
28554
+ const recordedFailure = takeRecordedCommandFailureTelemetry();
28555
+ const success = !error && exitCode === 0;
28556
+ const terminalTelemetry = buildCommandTerminalTelemetryProperties({
28557
+ error,
28558
+ exitCode,
28559
+ recordedFailure,
28560
+ pollSignal: context.pollSignal
28561
+ });
27997
28562
  telemetry.trackEvent(telemetryName, redactProperties({
27998
28563
  ...extractCommandParams(command),
27999
28564
  ...props,
28565
+ ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
28000
28566
  command: "true",
28001
28567
  duration: String(durationMs),
28002
28568
  success: String(success),
28569
+ ...terminalTelemetry,
28003
28570
  ...errorMessage2 ? { errorMessage: errorMessage2 } : {}
28004
28571
  }));
28005
28572
  });
@@ -28070,6 +28637,8 @@ var ScreenLogger;
28070
28637
  }
28071
28638
  ScreenLogger.progress = progress;
28072
28639
  })(ScreenLogger ||= {});
28640
+ // ../../common/src/telemetry/ship-succeeded.ts
28641
+ var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
28073
28642
  // ../../common/src/tool-provider.ts
28074
28643
  var factorySlot = singleton("PackagerFactoryProvider");
28075
28644
  // src/commands/_shared.ts
@@ -29212,4 +29781,4 @@ export {
29212
29781
  metadata
29213
29782
  };
29214
29783
 
29215
- //# debugId=E5DD255B6EE8159964756E2164756E21
29784
+ //# debugId=EAE3A384BB7BFAF264756E2164756E21
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/apms-tool",
3
3
  "license": "MIT",
4
- "version": "1.197.0-preview.65",
4
+ "version": "1.197.0-preview.67",
5
5
  "description": "CLI plugin for the UiPath Access Policy Management Service.",
6
6
  "private": false,
7
7
  "repository": {
@@ -26,5 +26,5 @@
26
26
  "files": [
27
27
  "dist"
28
28
  ],
29
- "gitHead": "9388ccbe5e739c9578bfd9b5395980fb63e11d9c"
29
+ "gitHead": "579e7d41cb100fcb8130eec8ed1c9b5b55feaf0b"
30
30
  }