@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.
@@ -1,3 +1,4 @@
1
+ import { type CommandErrorClass, type TerminalOutcome } from "./telemetry/command-terminal.js";
1
2
  export type OutputFormat = "table" | "json" | "yaml" | "plain";
2
3
  export type ResultType = "Success" | "Failure" | "ConfigError" | "AuthenticationError" | "ValidationError" | "TimeoutError";
3
4
  export type FailureResultType = Exclude<ResultType, "Success">;
@@ -100,6 +101,12 @@ export declare class FailureOutput {
100
101
  * stuck auth-refresh loop). Stripped before the envelope is rendered.
101
102
  */
102
103
  SuppressTelemetry?: boolean;
104
+ /** Internal-only override for command-level telemetry. Stripped before rendering. */
105
+ TelemetryErrorClass?: CommandErrorClass;
106
+ /** Internal-only override for command-level telemetry. Stripped before rendering. */
107
+ TelemetryTerminalOutcome?: TerminalOutcome;
108
+ /** Internal-only override for command-level telemetry. Stripped before rendering. */
109
+ TelemetryTerminalSignal?: string;
103
110
  constructor(result: FailureResultType, message: string, instructions: string, context?: ErrorContext, errorCode?: CliErrorCode, retry?: RetryHint);
104
111
  }
105
112
  export type StructuredOutput = SuccessOutput | FailureOutput;
@@ -22,8 +22,11 @@ export * from "./screen-logger";
22
22
  export * from "./sdk-user-agent";
23
23
  export * from "./singleton";
24
24
  export { BrowserContextStorage } from "./telemetry/browser-context-storage.js";
25
+ export * from "./telemetry/command-attribution.js";
26
+ export * from "./telemetry/command-terminal.js";
25
27
  export { ConsoleTelemetryProvider } from "./telemetry/console-telemetry-provider.js";
26
28
  export type { IContextStorage } from "./telemetry/context-storage.js";
29
+ export { getConfiguredTelemetrySessionId, getTelemetrySessionId, resolveTelemetrySessionId, TELEMETRY_SESSION_ID_ENV, TELEMETRY_SESSION_ID_PROPERTY, } from "./telemetry/session-id.js";
27
30
  export * from "./telemetry/telemetry-events.js";
28
31
  export type { ITelemetryProvider } from "./telemetry/telemetry-provider.js";
29
32
  export type { ITelemetryService, TelemetryContext, TelemetryProperties, } from "./telemetry/telemetry-service.js";
@@ -22360,6 +22360,392 @@ class BrowserContextStorage {
22360
22360
  return this.contextStack.length > 0 ? this.contextStack[this.contextStack.length - 1] : undefined;
22361
22361
  }
22362
22362
  }
22363
+ // src/telemetry/command-attribution.ts
22364
+ var LEGACY_SKILL_NAMESPACE = "uipath:";
22365
+ var MAX_SKILL_NAME_LENGTH = 80;
22366
+ var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
22367
+ function productMode(productArea, mode) {
22368
+ return { product_area: productArea, mode };
22369
+ }
22370
+ function attributionRecord(groups) {
22371
+ const record = {};
22372
+ for (const [productArea, mode, names] of groups) {
22373
+ const attribution = productMode(productArea, mode);
22374
+ for (const name of names) {
22375
+ record[name] = attribution;
22376
+ }
22377
+ }
22378
+ return record;
22379
+ }
22380
+ function commandAttribution(groups) {
22381
+ const entries = [];
22382
+ for (const [productArea, mode, prefixes] of groups) {
22383
+ const attribution = productMode(productArea, mode);
22384
+ for (const prefix of prefixes) {
22385
+ entries.push({ prefix, attribution });
22386
+ }
22387
+ }
22388
+ return entries;
22389
+ }
22390
+ var SKILL_ATTRIBUTION = attributionRecord([
22391
+ ["admin", "operate", ["uipath-admin"]],
22392
+ ["agents", "build", ["uipath-agents"]],
22393
+ ["api-workflow", "build", ["uipath-api-workflow"]],
22394
+ ["automation-discovery", "build", ["uipath-automation-discovery"]],
22395
+ ["coded-apps", "build", ["uipath-coded-apps"]],
22396
+ ["data-fabric", "operate", ["uipath-data-fabric"]],
22397
+ ["cli", "troubleshoot", ["uipath-feedback"]],
22398
+ ["governance", "operate", ["uipath-governance"]],
22399
+ ["action-center", "build", ["uipath-human-in-the-loop"]],
22400
+ ["document-understanding", "build", ["uipath-ixp"]],
22401
+ [
22402
+ "maestro",
22403
+ "build",
22404
+ ["uipath-maestro-bpmn", "uipath-maestro-case", "uipath-maestro-flow"]
22405
+ ],
22406
+ ["agenthub", "build", ["uipath-mcp-servers"]],
22407
+ ["solution", "build", ["uipath-planner", "uipath-solution"]],
22408
+ ["platform", "operate", ["uipath-platform"]],
22409
+ ["quality", "troubleshoot", ["uipath-review"]],
22410
+ ["rpa", "build", ["uipath-rpa"]],
22411
+ ["cli", "operate", ["uipath-skill-catalog"]],
22412
+ ["action-center", "operate", ["uipath-tasks"]],
22413
+ ["test-manager", "operate", ["uipath-test"]],
22414
+ ["platform", "troubleshoot", ["uipath-troubleshoot"]]
22415
+ ]);
22416
+ var KNOWN_SKILL_NAMES = new Set(Object.keys(SKILL_ATTRIBUTION));
22417
+ var COMMAND_ATTRIBUTION = commandAttribution([
22418
+ ["cli", "troubleshoot", ["uip.feedback"]],
22419
+ ["llm-gateway", "operate", ["uip.llm-configuration", "uip.model-hub"]],
22420
+ ["context-grounding", "build", ["uip.context-grounding"]],
22421
+ ["api-workflow", "build", ["uip.api-workflow"]],
22422
+ ["rpa", "build", ["uip.rpa-legacy"]],
22423
+ ["conversational", "operate", ["uip.conversational"]],
22424
+ ["agents", "build", ["uip.codedagent", "uip.agent"]],
22425
+ ["agenthub", "build", ["uip.agenthub"]],
22426
+ ["coded-apps", "build", ["uip.codedapp"]],
22427
+ ["functions", "build", ["uip.functions"]],
22428
+ ["solution", "build", ["uip.solution"]],
22429
+ ["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
22430
+ ["llm-observability", "troubleshoot", ["uip.traces"]],
22431
+ ["platform", "operate", ["uip.platform"]],
22432
+ ["admin", "operate", ["uip.admin"]],
22433
+ ["automation-ops", "operate", ["uip.aops"]],
22434
+ ["documentation", "troubleshoot", ["uip.docsai"]],
22435
+ ["governance", "operate", ["uip.gov"]],
22436
+ ["insights", "operate", ["uip.insights"]],
22437
+ ["document-understanding", "build", ["uip.ixp"]],
22438
+ ["process-mining", "operate", ["uip.pm"]],
22439
+ ["action-center", "operate", ["uip.tasks"]],
22440
+ ["test-manager", "operate", ["uip.tm"]],
22441
+ ["vertical-solutions", "build", ["uip.vss"]],
22442
+ ["data-fabric", "operate", ["uip.df"]],
22443
+ ["integration-service", "build", ["uip.is"]],
22444
+ ["orchestrator", "operate", ["uip.or"]],
22445
+ [
22446
+ "cli",
22447
+ "operate",
22448
+ [
22449
+ "uip.login",
22450
+ "uip.logout",
22451
+ "uip.user",
22452
+ "uip.config",
22453
+ "uip.tools",
22454
+ "uip.skills",
22455
+ "uip.completion",
22456
+ "uip.update",
22457
+ "uip.mcp",
22458
+ "uip.track"
22459
+ ]
22460
+ ]
22461
+ ]).sort((a, b) => b.prefix.length - a.prefix.length);
22462
+ function normalizeCommandPath(value) {
22463
+ if (typeof value !== "string") {
22464
+ return;
22465
+ }
22466
+ const trimmed = value.trim().toLowerCase();
22467
+ if (!trimmed) {
22468
+ return;
22469
+ }
22470
+ const tokens = trimmed.includes(" ") ? trimmed.split(/\s+/).filter((token) => token.length > 0).filter((token) => !token.startsWith("-")) : trimmed.split(".").filter((token) => token.length > 0);
22471
+ if (tokens.length === 0) {
22472
+ return;
22473
+ }
22474
+ const commandTokens = tokens[0] === "uip" ? tokens : ["uip", ...tokens];
22475
+ return commandTokens.join(".");
22476
+ }
22477
+ function getCommandProductModeAttribution(commandPath) {
22478
+ const normalized = normalizeCommandPath(commandPath);
22479
+ if (!normalized) {
22480
+ return;
22481
+ }
22482
+ return COMMAND_ATTRIBUTION.find(({ prefix }) => normalized === prefix || normalized.startsWith(`${prefix}.`))?.attribution;
22483
+ }
22484
+ function normalizeSkillNameWithOptions(value, options) {
22485
+ if (typeof value !== "string") {
22486
+ return;
22487
+ }
22488
+ const normalized = value.trim().toLowerCase();
22489
+ if (!normalized) {
22490
+ return;
22491
+ }
22492
+ const hasLegacyNamespace = normalized.startsWith(LEGACY_SKILL_NAMESPACE);
22493
+ if (hasLegacyNamespace && !options.allowLegacyNamespace) {
22494
+ return;
22495
+ }
22496
+ const skillName = hasLegacyNamespace ? normalized.slice(LEGACY_SKILL_NAMESPACE.length) : normalized;
22497
+ if (skillName.length > MAX_SKILL_NAME_LENGTH || !SKILL_NAME_PATTERN.test(skillName) || !KNOWN_SKILL_NAMES.has(skillName)) {
22498
+ return;
22499
+ }
22500
+ return skillName;
22501
+ }
22502
+ function normalizeSkillName(value) {
22503
+ return normalizeSkillNameWithOptions(value, {
22504
+ allowLegacyNamespace: false
22505
+ });
22506
+ }
22507
+ function normalizeLegacySkillName(value) {
22508
+ return normalizeSkillNameWithOptions(value, {
22509
+ allowLegacyNamespace: true
22510
+ });
22511
+ }
22512
+ function buildCommandTelemetryAttribution(commandPath, skillSource) {
22513
+ const skillName = normalizeSkillName(skillSource);
22514
+ return {
22515
+ ...skillName ? { skill_name: skillName } : {},
22516
+ ...getCommandProductModeAttribution(commandPath)
22517
+ };
22518
+ }
22519
+ function buildSkillEventTelemetryAttribution(skillSource, uipSubcommand) {
22520
+ const skillName = normalizeLegacySkillName(skillSource);
22521
+ const skillAttribution = skillName ? SKILL_ATTRIBUTION[skillName] : {};
22522
+ const commandAttribution2 = getCommandProductModeAttribution(uipSubcommand);
22523
+ return {
22524
+ ...skillAttribution,
22525
+ ...commandAttribution2,
22526
+ ...skillName ? { skill_name: skillName } : {}
22527
+ };
22528
+ }
22529
+ // src/telemetry/command-terminal.ts
22530
+ var recordedFailureSlot = singleton("CommandTelemetryFailure");
22531
+ var AUTH_ERROR_CODES = new Set([
22532
+ "authentication_required",
22533
+ "permission_denied"
22534
+ ]);
22535
+ var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
22536
+ var NETWORK_HTTP_ERROR_CODES = new Set([
22537
+ "network_error",
22538
+ "rate_limited",
22539
+ "server_error",
22540
+ "not_found",
22541
+ "method_not_allowed"
22542
+ ]);
22543
+ var TIMEOUT_ERROR_CODES = new Set(["timeout"]);
22544
+ var NETWORK_OS_ERROR_CODES = new Set([
22545
+ "ECONNREFUSED",
22546
+ "ECONNRESET",
22547
+ "ENOTFOUND",
22548
+ "EAI_AGAIN",
22549
+ "EPIPE",
22550
+ "EHOSTUNREACH",
22551
+ "ENETUNREACH",
22552
+ "EAI_FAIL"
22553
+ ]);
22554
+ var TIMEOUT_OS_ERROR_CODES = new Set(["ETIMEDOUT", "ESOCKETTIMEDOUT"]);
22555
+ var TLS_ERROR_CODES2 = new Set([
22556
+ "SELF_SIGNED_CERT_IN_CHAIN",
22557
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
22558
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
22559
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
22560
+ "UNABLE_TO_GET_ISSUER_CERT",
22561
+ "CERT_HAS_EXPIRED",
22562
+ "CERT_UNTRUSTED",
22563
+ "ERR_TLS_CERT_ALTNAME_INVALID"
22564
+ ]);
22565
+ var MISSING_DEPENDENCY_CODES = new Set([
22566
+ "MODULE_NOT_FOUND",
22567
+ "ERR_MODULE_NOT_FOUND"
22568
+ ]);
22569
+ var INTERNAL_ERROR_NAMES = new Set([
22570
+ "TypeError",
22571
+ "ReferenceError",
22572
+ "SyntaxError",
22573
+ "RangeError"
22574
+ ]);
22575
+ function isRecord(value) {
22576
+ return value !== null && typeof value === "object";
22577
+ }
22578
+ function stringField(value, field) {
22579
+ if (!isRecord(value)) {
22580
+ return;
22581
+ }
22582
+ const raw = value[field];
22583
+ return typeof raw === "string" ? raw : undefined;
22584
+ }
22585
+ function numberField(value, field) {
22586
+ if (!isRecord(value)) {
22587
+ return;
22588
+ }
22589
+ const raw = value[field];
22590
+ return typeof raw === "number" ? raw : undefined;
22591
+ }
22592
+ function findStringInCauseChain(error, field) {
22593
+ let current = error;
22594
+ for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
22595
+ const value = stringField(current, field);
22596
+ if (value) {
22597
+ return value;
22598
+ }
22599
+ current = current.cause;
22600
+ }
22601
+ return;
22602
+ }
22603
+ function findCodeInCauseChain(error) {
22604
+ return findStringInCauseChain(error, "code");
22605
+ }
22606
+ function isSpawnEnoent(error) {
22607
+ const code2 = findCodeInCauseChain(error);
22608
+ if (code2 !== "ENOENT") {
22609
+ return false;
22610
+ }
22611
+ const syscall = findStringInCauseChain(error, "syscall");
22612
+ return syscall?.startsWith("spawn") === true;
22613
+ }
22614
+ function isCancellationError(error, exitCode, pollSignal) {
22615
+ if (exitCode === 130) {
22616
+ return true;
22617
+ }
22618
+ if (!isRecord(error)) {
22619
+ return false;
22620
+ }
22621
+ if (numberField(error, "exitCode") === 130) {
22622
+ return true;
22623
+ }
22624
+ const name = stringField(error, "name");
22625
+ if (name === "ExitPromptError") {
22626
+ return true;
22627
+ }
22628
+ if (name === "AbortError" && pollSignal?.aborted) {
22629
+ return true;
22630
+ }
22631
+ const message = stringField(error, "message");
22632
+ return message?.includes("SIGINT") === true;
22633
+ }
22634
+ function terminalSignalFor(input, outcome) {
22635
+ if (input.recordedFailure?.terminalSignal) {
22636
+ return input.recordedFailure.terminalSignal;
22637
+ }
22638
+ const explicit = findStringInCauseChain(input.error, "terminalSignal") ?? findStringInCauseChain(input.error, "signal");
22639
+ if (explicit) {
22640
+ return explicit;
22641
+ }
22642
+ return outcome === "cancelled" ? "SIGINT" : undefined;
22643
+ }
22644
+ function classifyHttpStatus(status) {
22645
+ if (status === 401 || status === 403) {
22646
+ return "auth";
22647
+ }
22648
+ if (status === 400 || status === 409 || status === 422) {
22649
+ return "validation";
22650
+ }
22651
+ if (status === 408) {
22652
+ return "timeout";
22653
+ }
22654
+ return "network_http";
22655
+ }
22656
+ function classifyFromResult(result) {
22657
+ switch (result) {
22658
+ case "AuthenticationError":
22659
+ return "auth";
22660
+ case "ValidationError":
22661
+ return "validation";
22662
+ case "TimeoutError":
22663
+ return "timeout";
22664
+ default:
22665
+ return;
22666
+ }
22667
+ }
22668
+ function classifyFromErrorCode(errorCode) {
22669
+ if (!errorCode) {
22670
+ return;
22671
+ }
22672
+ if (AUTH_ERROR_CODES.has(errorCode)) {
22673
+ return "auth";
22674
+ }
22675
+ if (VALIDATION_ERROR_CODES.has(errorCode)) {
22676
+ return "validation";
22677
+ }
22678
+ if (TIMEOUT_ERROR_CODES.has(errorCode)) {
22679
+ return "timeout";
22680
+ }
22681
+ if (NETWORK_HTTP_ERROR_CODES.has(errorCode)) {
22682
+ return "network_http";
22683
+ }
22684
+ return;
22685
+ }
22686
+ function classifyFromError(error) {
22687
+ const code2 = findCodeInCauseChain(error);
22688
+ if (code2) {
22689
+ if (code2.startsWith("commander.")) {
22690
+ return "validation";
22691
+ }
22692
+ if (NETWORK_OS_ERROR_CODES.has(code2) || TLS_ERROR_CODES2.has(code2)) {
22693
+ return "network_http";
22694
+ }
22695
+ if (TIMEOUT_OS_ERROR_CODES.has(code2)) {
22696
+ return "timeout";
22697
+ }
22698
+ if (MISSING_DEPENDENCY_CODES.has(code2) || isSpawnEnoent(error)) {
22699
+ return "missing_dependency";
22700
+ }
22701
+ }
22702
+ const message = stringField(error, "message");
22703
+ if (message?.includes("fetch failed") === true) {
22704
+ return "network_http";
22705
+ }
22706
+ const name = stringField(error, "name");
22707
+ if (name && INTERNAL_ERROR_NAMES.has(name)) {
22708
+ return "internal";
22709
+ }
22710
+ return;
22711
+ }
22712
+ function classifyError2(input) {
22713
+ const recorded = input.recordedFailure;
22714
+ if (recorded?.errorClass) {
22715
+ return recorded.errorClass;
22716
+ }
22717
+ const status = recorded?.context?.httpStatus;
22718
+ if (status !== undefined) {
22719
+ return classifyHttpStatus(status);
22720
+ }
22721
+ return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
22722
+ }
22723
+ function recordCommandFailureTelemetry(failure) {
22724
+ recordedFailureSlot.set(failure);
22725
+ }
22726
+ function getRecordedCommandFailureTelemetry() {
22727
+ return recordedFailureSlot.get();
22728
+ }
22729
+ function clearRecordedCommandFailureTelemetry() {
22730
+ recordedFailureSlot.clear();
22731
+ }
22732
+ function takeRecordedCommandFailureTelemetry() {
22733
+ const failure = recordedFailureSlot.get();
22734
+ recordedFailureSlot.clear();
22735
+ return failure;
22736
+ }
22737
+ function buildCommandTerminalTelemetryProperties(input) {
22738
+ const cancelled = isCancellationError(input.error, input.exitCode, input.pollSignal);
22739
+ const outcome = input.recordedFailure?.terminalOutcome ?? (input.exitCode === 0 ? "success" : cancelled ? "cancelled" : "failure");
22740
+ const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError2(input);
22741
+ const terminalSignal = terminalSignalFor(input, outcome);
22742
+ return {
22743
+ exit_code: input.exitCode,
22744
+ terminal_outcome: outcome,
22745
+ ...errorClass ? { error_class: errorClass } : {},
22746
+ ...terminalSignal ? { terminal_signal: terminalSignal } : {}
22747
+ };
22748
+ }
22363
22749
  // src/telemetry/console-telemetry-provider.ts
22364
22750
  class ConsoleTelemetryProvider {
22365
22751
  async trackEvent(eventName, _properties) {
@@ -22375,10 +22761,174 @@ class ConsoleTelemetryProvider {
22375
22761
  console.debug(`[Telemetry] Dependency: ${name} [${type}] (${duration}ms, ${success ? "ok" : "fail"})`);
22376
22762
  }
22377
22763
  }
22764
+ // src/telemetry/session-id.ts
22765
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
22766
+ var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
22767
+ var telemetrySessionIdSlot = singleton("TelemetrySessionId");
22768
+ function getProcessEnv() {
22769
+ return globalThis.process?.env;
22770
+ }
22771
+ function normalizeSessionId(value) {
22772
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
22773
+ return;
22774
+ }
22775
+ const trimmed = String(value).trim();
22776
+ return trimmed || undefined;
22777
+ }
22778
+ function getConfiguredTelemetrySessionId() {
22779
+ return normalizeSessionId(getProcessEnv()?.[TELEMETRY_SESSION_ID_ENV]);
22780
+ }
22781
+ function getTelemetrySessionId() {
22782
+ const envSessionId = getConfiguredTelemetrySessionId();
22783
+ if (envSessionId) {
22784
+ return envSessionId;
22785
+ }
22786
+ const existing = telemetrySessionIdSlot.get();
22787
+ if (existing) {
22788
+ return existing;
22789
+ }
22790
+ const generated = crypto.randomUUID();
22791
+ telemetrySessionIdSlot.set(generated);
22792
+ return generated;
22793
+ }
22794
+ function resolveTelemetrySessionId(existingSessionId) {
22795
+ return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
22796
+ }
22378
22797
  // src/telemetry/telemetry-events.ts
22379
22798
  var CommonTelemetryEvents = {
22380
- Error: "uip.error"
22799
+ Error: "uip.error",
22800
+ ShipSucceeded: "ship_succeeded"
22381
22801
  };
22802
+ // src/telemetry/detect-agent.ts
22803
+ var KNOWN_AGENTS = [
22804
+ { envVar: "CLAUDECODE", value: "1", id: "claude-code" },
22805
+ { envVar: "CURSOR_AGENT", value: "1", id: "cursor" },
22806
+ { envVar: "GEMINI_CLI", value: "1", id: "gemini-cli" },
22807
+ { envVar: "CODEX_THREAD_ID", id: "codex" },
22808
+ { envVar: "CODEX_SANDBOX", id: "codex" },
22809
+ { envVar: "AUGMENT_AGENT", value: "1", id: "augment" },
22810
+ { envVar: "CLINE_ACTIVE", value: "true", id: "cline" }
22811
+ ];
22812
+ function detectAgentFromEnv(env2) {
22813
+ for (const agent of KNOWN_AGENTS) {
22814
+ const envValue = env2[agent.envVar];
22815
+ if (agent.value !== undefined) {
22816
+ if (envValue === agent.value)
22817
+ return agent.id;
22818
+ } else {
22819
+ if (envValue)
22820
+ return agent.id;
22821
+ }
22822
+ }
22823
+ const agentEnv = env2.AGENT;
22824
+ if (agentEnv) {
22825
+ if (agentEnv === "1" || agentEnv === "true")
22826
+ return "unknown";
22827
+ if (agentEnv.length <= 32)
22828
+ return agentEnv.toLowerCase();
22829
+ }
22830
+ return;
22831
+ }
22832
+
22833
+ // src/telemetry/execution-context.ts
22834
+ var authSignalSlot = singleton("TelemetryExecutionContextAuthSignal");
22835
+ var isTruthy = (value) => value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
22836
+ var isEqual = (value, expected) => value?.toLowerCase() === expected;
22837
+ var CI_SIGNATURES = [
22838
+ {
22839
+ provider: "github_actions",
22840
+ matches: (env2) => isTruthy(env2.GITHUB_ACTIONS),
22841
+ isScheduler: (env2) => env2.GITHUB_EVENT_NAME === "schedule"
22842
+ },
22843
+ {
22844
+ provider: "azure_devops",
22845
+ matches: (env2) => isTruthy(env2.TF_BUILD),
22846
+ isScheduler: (env2) => isEqual(env2.BUILD_REASON, "schedule")
22847
+ },
22848
+ {
22849
+ provider: "gitlab",
22850
+ matches: (env2) => isTruthy(env2.GITLAB_CI),
22851
+ isScheduler: (env2) => env2.CI_PIPELINE_SOURCE === "schedule"
22852
+ },
22853
+ {
22854
+ provider: "circleci",
22855
+ matches: (env2) => isTruthy(env2.CIRCLECI),
22856
+ isScheduler: (env2) => env2.CIRCLE_PIPELINE_TRIGGER_SOURCE === "scheduled_pipeline"
22857
+ },
22858
+ {
22859
+ provider: "jenkins",
22860
+ matches: (env2) => isTruthy(env2.JENKINS_URL) || isTruthy(env2.JENKINS_HOME)
22861
+ },
22862
+ {
22863
+ provider: "teamcity",
22864
+ matches: (env2) => isTruthy(env2.TEAMCITY_VERSION)
22865
+ },
22866
+ {
22867
+ provider: "buildkite",
22868
+ matches: (env2) => isTruthy(env2.BUILDKITE),
22869
+ isScheduler: (env2) => env2.BUILDKITE_SOURCE === "schedule"
22870
+ },
22871
+ {
22872
+ provider: "bitbucket",
22873
+ matches: (env2) => isTruthy(env2.BITBUCKET_BUILD_NUMBER)
22874
+ },
22875
+ {
22876
+ provider: "travis",
22877
+ matches: (env2) => isTruthy(env2.TRAVIS)
22878
+ },
22879
+ {
22880
+ provider: "appveyor",
22881
+ matches: (env2) => isTruthy(env2.APPVEYOR)
22882
+ },
22883
+ {
22884
+ provider: "generic",
22885
+ matches: (env2) => isTruthy(env2.CI)
22886
+ }
22887
+ ];
22888
+ function currentEnv() {
22889
+ return typeof process === "undefined" ? {} : process.env;
22890
+ }
22891
+ function currentTtyState() {
22892
+ if (typeof process === "undefined")
22893
+ return false;
22894
+ return Boolean(process.stdout?.isTTY || process.stdin?.isTTY || process.stderr?.isTTY);
22895
+ }
22896
+ function detectCi(env2) {
22897
+ const signature = CI_SIGNATURES.find((candidate) => candidate.matches(env2));
22898
+ if (!signature)
22899
+ return;
22900
+ return {
22901
+ executionContext: signature.isScheduler?.(env2) ? "scheduler" : "ci",
22902
+ ciProvider: signature.provider
22903
+ };
22904
+ }
22905
+ function detectExecutionContext(options = {}) {
22906
+ const env2 = options.env ?? currentEnv();
22907
+ const ci = detectCi(env2);
22908
+ if (ci)
22909
+ return ci;
22910
+ const agent = options.agent ?? detectAgentFromEnv(env2);
22911
+ if (agent) {
22912
+ return { executionContext: "agent" };
22913
+ }
22914
+ const authSignal = options.authSignal ?? authSignalSlot.get();
22915
+ if (authSignal === "service_account") {
22916
+ return { executionContext: "service_account" };
22917
+ }
22918
+ const isTty = options.isTty ?? currentTtyState();
22919
+ if (isTty) {
22920
+ return { executionContext: "manual" };
22921
+ }
22922
+ return { executionContext: "unknown" };
22923
+ }
22924
+ function getExecutionContextTelemetryProperties() {
22925
+ const detected = detectExecutionContext();
22926
+ return {
22927
+ execution_context: detected.executionContext,
22928
+ ...detected.ciProvider ? { ci_provider: detected.ciProvider } : {}
22929
+ };
22930
+ }
22931
+
22382
22932
  // src/telemetry/telemetry-service.ts
22383
22933
  class TelemetryService {
22384
22934
  telemetryProvider;
@@ -22457,12 +23007,22 @@ class TelemetryService {
22457
23007
  return this.contextStorage.getContext();
22458
23008
  }
22459
23009
  enrichPropertiesWithContext(properties, context) {
22460
- return {
22461
- ...getGlobalTelemetryProperties(),
23010
+ const globalProperties = getGlobalTelemetryProperties();
23011
+ const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
23012
+ const sessionId = resolveTelemetrySessionId(existingSessionId);
23013
+ const enriched = {
23014
+ ...getExecutionContextTelemetryProperties(),
23015
+ ...globalProperties,
22462
23016
  ...this.defaultProperties,
22463
23017
  ...properties,
22464
23018
  ...context
22465
23019
  };
23020
+ if (sessionId === undefined) {
23021
+ delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
23022
+ } else {
23023
+ enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
23024
+ }
23025
+ return enriched;
22466
23026
  }
22467
23027
  generateId() {
22468
23028
  return crypto.randomUUID().replaceAll("-", "");
@@ -22482,6 +23042,7 @@ async function ensurePackagerFactory(verb) {
22482
23042
  }
22483
23043
  export {
22484
23044
  withCompleter,
23045
+ takeRecordedCommandFailureTelemetry,
22485
23046
  singleton,
22486
23047
  setSdkUserAgentHostToken,
22487
23048
  setPackagerFactoryProvider,
@@ -22492,15 +23053,18 @@ export {
22492
23053
  setGlobalLogFilePath,
22493
23054
  runWithSink,
22494
23055
  restoreConsole,
23056
+ resolveTelemetrySessionId,
22495
23057
  resolveEnvReference,
22496
23058
  resetLoggerInstance,
22497
23059
  registerPackageMetadataOptions,
23060
+ recordCommandFailureTelemetry,
22498
23061
  pollUntil,
22499
23062
  parsePositiveInteger,
22500
23063
  parseOffset,
22501
23064
  parseNonNegativeInteger,
22502
23065
  parseLimit,
22503
23066
  parseBoundedInt,
23067
+ normalizeSkillName,
22504
23068
  msToDuration,
22505
23069
  mapPollFailure,
22506
23070
  mapPackageMetadataOptions,
@@ -22515,13 +23079,16 @@ export {
22515
23079
  installSdkCodingAgentHeader,
22516
23080
  installConsoleGuard,
22517
23081
  hashContent,
23082
+ getTelemetrySessionId,
22518
23083
  getSdkUserAgentToken,
23084
+ getRecordedCommandFailureTelemetry,
22519
23085
  getOutputSink,
22520
23086
  getOutputFormatExplicit,
22521
23087
  getOutputFormat,
22522
23088
  getOutputFilter,
22523
23089
  getLogFilePath,
22524
23090
  getGlobalLogFilePath,
23091
+ getConfiguredTelemetrySessionId,
22525
23092
  getCompleter,
22526
23093
  getCommandExamples,
22527
23094
  extractFormatFromArgs,
@@ -22534,14 +23101,20 @@ export {
22534
23101
  createPollAbortController,
22535
23102
  configureLogger,
22536
23103
  collectCommands,
23104
+ clearRecordedCommandFailureTelemetry,
22537
23105
  catchError,
23106
+ buildSkillEventTelemetryAttribution,
22538
23107
  buildOrchestratorUrl,
23108
+ buildCommandTerminalTelemetryProperties,
23109
+ buildCommandTelemetryAttribution,
22539
23110
  buildActionCenterTaskUrl,
22540
23111
  buildActionCenterInboxUrl,
22541
23112
  addSdkUserAgentHeader,
22542
23113
  addSdkCodingAgentHeader,
22543
23114
  UIPATH_HOME_DIR,
22544
23115
  TelemetryService,
23116
+ TELEMETRY_SESSION_ID_PROPERTY,
23117
+ TELEMETRY_SESSION_ID_ENV,
22545
23118
  ScreenLogger,
22546
23119
  PollOutcome,
22547
23120
  POLL_DEFAULTS,
@@ -22562,4 +23135,4 @@ export {
22562
23135
  AUTH_FILENAME
22563
23136
  };
22564
23137
 
22565
- //# debugId=D3F1D2DAD96E966264756E2164756E21
23138
+ //# debugId=ACC353BBF445886C64756E2164756E21