@uipath/agent-tool 1.197.0-preview.65 → 1.197.0-preview.66

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 (2) hide show
  1. package/dist/tool.js +800 -105
  2. package/package.json +2 -2
package/dist/tool.js CHANGED
@@ -8080,11 +8080,234 @@ var init_output_format_context = __esm(() => {
8080
8080
  filterSlot = singleton("OutputFilter");
8081
8081
  });
8082
8082
 
8083
+ // ../common/src/telemetry/command-terminal.ts
8084
+ function isRecord(value) {
8085
+ return value !== null && typeof value === "object";
8086
+ }
8087
+ function stringField(value, field) {
8088
+ if (!isRecord(value)) {
8089
+ return;
8090
+ }
8091
+ const raw = value[field];
8092
+ return typeof raw === "string" ? raw : undefined;
8093
+ }
8094
+ function numberField(value, field) {
8095
+ if (!isRecord(value)) {
8096
+ return;
8097
+ }
8098
+ const raw = value[field];
8099
+ return typeof raw === "number" ? raw : undefined;
8100
+ }
8101
+ function findStringInCauseChain(error, field) {
8102
+ let current = error;
8103
+ for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
8104
+ const value = stringField(current, field);
8105
+ if (value) {
8106
+ return value;
8107
+ }
8108
+ current = current.cause;
8109
+ }
8110
+ return;
8111
+ }
8112
+ function findCodeInCauseChain(error) {
8113
+ return findStringInCauseChain(error, "code");
8114
+ }
8115
+ function isSpawnEnoent(error) {
8116
+ const code = findCodeInCauseChain(error);
8117
+ if (code !== "ENOENT") {
8118
+ return false;
8119
+ }
8120
+ const syscall = findStringInCauseChain(error, "syscall");
8121
+ return syscall?.startsWith("spawn") === true;
8122
+ }
8123
+ function isCancellationError(error, exitCode, pollSignal) {
8124
+ if (exitCode === 130) {
8125
+ return true;
8126
+ }
8127
+ if (!isRecord(error)) {
8128
+ return false;
8129
+ }
8130
+ if (numberField(error, "exitCode") === 130) {
8131
+ return true;
8132
+ }
8133
+ const name = stringField(error, "name");
8134
+ if (name === "ExitPromptError") {
8135
+ return true;
8136
+ }
8137
+ if (name === "AbortError" && pollSignal?.aborted) {
8138
+ return true;
8139
+ }
8140
+ const message = stringField(error, "message");
8141
+ return message?.includes("SIGINT") === true;
8142
+ }
8143
+ function terminalSignalFor(input, outcome) {
8144
+ if (input.recordedFailure?.terminalSignal) {
8145
+ return input.recordedFailure.terminalSignal;
8146
+ }
8147
+ const explicit = findStringInCauseChain(input.error, "terminalSignal") ?? findStringInCauseChain(input.error, "signal");
8148
+ if (explicit) {
8149
+ return explicit;
8150
+ }
8151
+ return outcome === "cancelled" ? "SIGINT" : undefined;
8152
+ }
8153
+ function classifyHttpStatus(status) {
8154
+ if (status === 401 || status === 403) {
8155
+ return "auth";
8156
+ }
8157
+ if (status === 400 || status === 409 || status === 422) {
8158
+ return "validation";
8159
+ }
8160
+ if (status === 408) {
8161
+ return "timeout";
8162
+ }
8163
+ return "network_http";
8164
+ }
8165
+ function classifyFromResult(result) {
8166
+ switch (result) {
8167
+ case "AuthenticationError":
8168
+ return "auth";
8169
+ case "ValidationError":
8170
+ return "validation";
8171
+ case "TimeoutError":
8172
+ return "timeout";
8173
+ default:
8174
+ return;
8175
+ }
8176
+ }
8177
+ function classifyFromErrorCode(errorCode) {
8178
+ if (!errorCode) {
8179
+ return;
8180
+ }
8181
+ if (AUTH_ERROR_CODES.has(errorCode)) {
8182
+ return "auth";
8183
+ }
8184
+ if (VALIDATION_ERROR_CODES.has(errorCode)) {
8185
+ return "validation";
8186
+ }
8187
+ if (TIMEOUT_ERROR_CODES.has(errorCode)) {
8188
+ return "timeout";
8189
+ }
8190
+ if (NETWORK_HTTP_ERROR_CODES.has(errorCode)) {
8191
+ return "network_http";
8192
+ }
8193
+ return;
8194
+ }
8195
+ function classifyFromError(error) {
8196
+ const code = findCodeInCauseChain(error);
8197
+ if (code) {
8198
+ if (code.startsWith("commander.")) {
8199
+ return "validation";
8200
+ }
8201
+ if (NETWORK_OS_ERROR_CODES.has(code) || TLS_ERROR_CODES2.has(code)) {
8202
+ return "network_http";
8203
+ }
8204
+ if (TIMEOUT_OS_ERROR_CODES.has(code)) {
8205
+ return "timeout";
8206
+ }
8207
+ if (MISSING_DEPENDENCY_CODES.has(code) || isSpawnEnoent(error)) {
8208
+ return "missing_dependency";
8209
+ }
8210
+ }
8211
+ const message = stringField(error, "message");
8212
+ if (message?.includes("fetch failed") === true) {
8213
+ return "network_http";
8214
+ }
8215
+ const name = stringField(error, "name");
8216
+ if (name && INTERNAL_ERROR_NAMES.has(name)) {
8217
+ return "internal";
8218
+ }
8219
+ return;
8220
+ }
8221
+ function classifyError(input) {
8222
+ const recorded = input.recordedFailure;
8223
+ if (recorded?.errorClass) {
8224
+ return recorded.errorClass;
8225
+ }
8226
+ const status = recorded?.context?.httpStatus;
8227
+ if (status !== undefined) {
8228
+ return classifyHttpStatus(status);
8229
+ }
8230
+ return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
8231
+ }
8232
+ function recordCommandFailureTelemetry(failure) {
8233
+ recordedFailureSlot.set(failure);
8234
+ }
8235
+ function clearRecordedCommandFailureTelemetry() {
8236
+ recordedFailureSlot.clear();
8237
+ }
8238
+ function takeRecordedCommandFailureTelemetry() {
8239
+ const failure = recordedFailureSlot.get();
8240
+ recordedFailureSlot.clear();
8241
+ return failure;
8242
+ }
8243
+ function buildCommandTerminalTelemetryProperties(input) {
8244
+ const cancelled = isCancellationError(input.error, input.exitCode, input.pollSignal);
8245
+ const outcome = input.recordedFailure?.terminalOutcome ?? (input.exitCode === 0 ? "success" : cancelled ? "cancelled" : "failure");
8246
+ const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError(input);
8247
+ const terminalSignal = terminalSignalFor(input, outcome);
8248
+ return {
8249
+ exit_code: input.exitCode,
8250
+ terminal_outcome: outcome,
8251
+ ...errorClass ? { error_class: errorClass } : {},
8252
+ ...terminalSignal ? { terminal_signal: terminalSignal } : {}
8253
+ };
8254
+ }
8255
+ var recordedFailureSlot, AUTH_ERROR_CODES, VALIDATION_ERROR_CODES, NETWORK_HTTP_ERROR_CODES, TIMEOUT_ERROR_CODES, NETWORK_OS_ERROR_CODES, TIMEOUT_OS_ERROR_CODES, TLS_ERROR_CODES2, MISSING_DEPENDENCY_CODES, INTERNAL_ERROR_NAMES;
8256
+ var init_command_terminal = __esm(() => {
8257
+ init_singleton();
8258
+ recordedFailureSlot = singleton("CommandTelemetryFailure");
8259
+ AUTH_ERROR_CODES = new Set([
8260
+ "authentication_required",
8261
+ "permission_denied"
8262
+ ]);
8263
+ VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
8264
+ NETWORK_HTTP_ERROR_CODES = new Set([
8265
+ "network_error",
8266
+ "rate_limited",
8267
+ "server_error",
8268
+ "not_found",
8269
+ "method_not_allowed"
8270
+ ]);
8271
+ TIMEOUT_ERROR_CODES = new Set(["timeout"]);
8272
+ NETWORK_OS_ERROR_CODES = new Set([
8273
+ "ECONNREFUSED",
8274
+ "ECONNRESET",
8275
+ "ENOTFOUND",
8276
+ "EAI_AGAIN",
8277
+ "EPIPE",
8278
+ "EHOSTUNREACH",
8279
+ "ENETUNREACH",
8280
+ "EAI_FAIL"
8281
+ ]);
8282
+ TIMEOUT_OS_ERROR_CODES = new Set(["ETIMEDOUT", "ESOCKETTIMEDOUT"]);
8283
+ TLS_ERROR_CODES2 = new Set([
8284
+ "SELF_SIGNED_CERT_IN_CHAIN",
8285
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
8286
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
8287
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
8288
+ "UNABLE_TO_GET_ISSUER_CERT",
8289
+ "CERT_HAS_EXPIRED",
8290
+ "CERT_UNTRUSTED",
8291
+ "ERR_TLS_CERT_ALTNAME_INVALID"
8292
+ ]);
8293
+ MISSING_DEPENDENCY_CODES = new Set([
8294
+ "MODULE_NOT_FOUND",
8295
+ "ERR_MODULE_NOT_FOUND"
8296
+ ]);
8297
+ INTERNAL_ERROR_NAMES = new Set([
8298
+ "TypeError",
8299
+ "ReferenceError",
8300
+ "SyntaxError",
8301
+ "RangeError"
8302
+ ]);
8303
+ });
8304
+
8083
8305
  // ../common/src/telemetry/telemetry-events.ts
8084
8306
  var CommonTelemetryEvents;
8085
8307
  var init_telemetry_events = __esm(() => {
8086
8308
  CommonTelemetryEvents = {
8087
- Error: "uip.error"
8309
+ Error: "uip.error",
8310
+ ShipSucceeded: "ship_succeeded"
8088
8311
  };
8089
8312
  });
8090
8313
 
@@ -8164,7 +8387,146 @@ var init_debug_telemetry_provider = __esm(() => {
8164
8387
  });
8165
8388
 
8166
8389
  // ../common/src/telemetry/detect-agent.ts
8167
- var init_detect_agent = () => {};
8390
+ function detectAgentFromEnv(env) {
8391
+ for (const agent of KNOWN_AGENTS) {
8392
+ const envValue = env[agent.envVar];
8393
+ if (agent.value !== undefined) {
8394
+ if (envValue === agent.value)
8395
+ return agent.id;
8396
+ } else {
8397
+ if (envValue)
8398
+ return agent.id;
8399
+ }
8400
+ }
8401
+ const agentEnv = env.AGENT;
8402
+ if (agentEnv) {
8403
+ if (agentEnv === "1" || agentEnv === "true")
8404
+ return "unknown";
8405
+ if (agentEnv.length <= 32)
8406
+ return agentEnv.toLowerCase();
8407
+ }
8408
+ return;
8409
+ }
8410
+ var KNOWN_AGENTS;
8411
+ var init_detect_agent = __esm(() => {
8412
+ KNOWN_AGENTS = [
8413
+ { envVar: "CLAUDECODE", value: "1", id: "claude-code" },
8414
+ { envVar: "CURSOR_AGENT", value: "1", id: "cursor" },
8415
+ { envVar: "GEMINI_CLI", value: "1", id: "gemini-cli" },
8416
+ { envVar: "CODEX_THREAD_ID", id: "codex" },
8417
+ { envVar: "CODEX_SANDBOX", id: "codex" },
8418
+ { envVar: "AUGMENT_AGENT", value: "1", id: "augment" },
8419
+ { envVar: "CLINE_ACTIVE", value: "true", id: "cline" }
8420
+ ];
8421
+ });
8422
+
8423
+ // ../common/src/telemetry/environment-info.ts
8424
+ var LOCAL_HOSTS;
8425
+ var init_environment_info = __esm(() => {
8426
+ LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
8427
+ });
8428
+
8429
+ // ../common/src/telemetry/execution-context.ts
8430
+ function currentEnv() {
8431
+ return typeof process === "undefined" ? {} : process.env;
8432
+ }
8433
+ function currentTtyState() {
8434
+ if (typeof process === "undefined")
8435
+ return false;
8436
+ return Boolean(process.stdout?.isTTY || process.stdin?.isTTY || process.stderr?.isTTY);
8437
+ }
8438
+ function detectCi(env) {
8439
+ const signature = CI_SIGNATURES.find((candidate) => candidate.matches(env));
8440
+ if (!signature)
8441
+ return;
8442
+ return {
8443
+ executionContext: signature.isScheduler?.(env) ? "scheduler" : "ci",
8444
+ ciProvider: signature.provider
8445
+ };
8446
+ }
8447
+ function detectExecutionContext(options = {}) {
8448
+ const env = options.env ?? currentEnv();
8449
+ const ci = detectCi(env);
8450
+ if (ci)
8451
+ return ci;
8452
+ const agent = options.agent ?? detectAgentFromEnv(env);
8453
+ if (agent) {
8454
+ return { executionContext: "agent" };
8455
+ }
8456
+ const authSignal = options.authSignal ?? authSignalSlot.get();
8457
+ if (authSignal === "service_account") {
8458
+ return { executionContext: "service_account" };
8459
+ }
8460
+ const isTty = options.isTty ?? currentTtyState();
8461
+ if (isTty) {
8462
+ return { executionContext: "manual" };
8463
+ }
8464
+ return { executionContext: "unknown" };
8465
+ }
8466
+ function getExecutionContextTelemetryProperties() {
8467
+ const detected = detectExecutionContext();
8468
+ return {
8469
+ execution_context: detected.executionContext,
8470
+ ...detected.ciProvider ? { ci_provider: detected.ciProvider } : {}
8471
+ };
8472
+ }
8473
+ var authSignalSlot, isTruthy = (value) => value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false", isEqual = (value, expected) => value?.toLowerCase() === expected, CI_SIGNATURES;
8474
+ var init_execution_context = __esm(() => {
8475
+ init_singleton();
8476
+ init_detect_agent();
8477
+ authSignalSlot = singleton("TelemetryExecutionContextAuthSignal");
8478
+ CI_SIGNATURES = [
8479
+ {
8480
+ provider: "github_actions",
8481
+ matches: (env) => isTruthy(env.GITHUB_ACTIONS),
8482
+ isScheduler: (env) => env.GITHUB_EVENT_NAME === "schedule"
8483
+ },
8484
+ {
8485
+ provider: "azure_devops",
8486
+ matches: (env) => isTruthy(env.TF_BUILD),
8487
+ isScheduler: (env) => isEqual(env.BUILD_REASON, "schedule")
8488
+ },
8489
+ {
8490
+ provider: "gitlab",
8491
+ matches: (env) => isTruthy(env.GITLAB_CI),
8492
+ isScheduler: (env) => env.CI_PIPELINE_SOURCE === "schedule"
8493
+ },
8494
+ {
8495
+ provider: "circleci",
8496
+ matches: (env) => isTruthy(env.CIRCLECI),
8497
+ isScheduler: (env) => env.CIRCLE_PIPELINE_TRIGGER_SOURCE === "scheduled_pipeline"
8498
+ },
8499
+ {
8500
+ provider: "jenkins",
8501
+ matches: (env) => isTruthy(env.JENKINS_URL) || isTruthy(env.JENKINS_HOME)
8502
+ },
8503
+ {
8504
+ provider: "teamcity",
8505
+ matches: (env) => isTruthy(env.TEAMCITY_VERSION)
8506
+ },
8507
+ {
8508
+ provider: "buildkite",
8509
+ matches: (env) => isTruthy(env.BUILDKITE),
8510
+ isScheduler: (env) => env.BUILDKITE_SOURCE === "schedule"
8511
+ },
8512
+ {
8513
+ provider: "bitbucket",
8514
+ matches: (env) => isTruthy(env.BITBUCKET_BUILD_NUMBER)
8515
+ },
8516
+ {
8517
+ provider: "travis",
8518
+ matches: (env) => isTruthy(env.TRAVIS)
8519
+ },
8520
+ {
8521
+ provider: "appveyor",
8522
+ matches: (env) => isTruthy(env.APPVEYOR)
8523
+ },
8524
+ {
8525
+ provider: "generic",
8526
+ matches: (env) => isTruthy(env.CI)
8527
+ }
8528
+ ];
8529
+ });
8168
8530
 
8169
8531
  // ../common/src/telemetry/node-context-storage.ts
8170
8532
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -8180,6 +8542,29 @@ class NodeContextStorage {
8180
8542
  }
8181
8543
  var init_node_context_storage = () => {};
8182
8544
 
8545
+ // ../common/src/telemetry/session-id.ts
8546
+ function getProcessEnv() {
8547
+ return globalThis.process?.env;
8548
+ }
8549
+ function normalizeSessionId(value) {
8550
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
8551
+ return;
8552
+ }
8553
+ const trimmed = String(value).trim();
8554
+ return trimmed || undefined;
8555
+ }
8556
+ function getConfiguredTelemetrySessionId() {
8557
+ return normalizeSessionId(getProcessEnv()?.[TELEMETRY_SESSION_ID_ENV]);
8558
+ }
8559
+ function resolveTelemetrySessionId(existingSessionId) {
8560
+ return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
8561
+ }
8562
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID", TELEMETRY_SESSION_ID_PROPERTY = "session_id", telemetrySessionIdSlot;
8563
+ var init_session_id = __esm(() => {
8564
+ init_singleton();
8565
+ telemetrySessionIdSlot = singleton("TelemetrySessionId");
8566
+ });
8567
+
8183
8568
  // ../common/src/telemetry/global-telemetry-properties.ts
8184
8569
  function getGlobalTelemetryProperties() {
8185
8570
  return telemetryPropsSlot.get();
@@ -8268,26 +8653,41 @@ class TelemetryService {
8268
8653
  return this.contextStorage.getContext();
8269
8654
  }
8270
8655
  enrichPropertiesWithContext(properties, context) {
8271
- return {
8272
- ...getGlobalTelemetryProperties(),
8656
+ const globalProperties = getGlobalTelemetryProperties();
8657
+ const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
8658
+ const sessionId = resolveTelemetrySessionId(existingSessionId);
8659
+ const enriched = {
8660
+ ...getExecutionContextTelemetryProperties(),
8661
+ ...globalProperties,
8273
8662
  ...this.defaultProperties,
8274
8663
  ...properties,
8275
8664
  ...context
8276
8665
  };
8666
+ if (sessionId === undefined) {
8667
+ delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
8668
+ } else {
8669
+ enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
8670
+ }
8671
+ return enriched;
8277
8672
  }
8278
8673
  generateId() {
8279
8674
  return crypto.randomUUID().replaceAll("-", "");
8280
8675
  }
8281
8676
  }
8282
8677
  var init_telemetry_service = __esm(() => {
8678
+ init_execution_context();
8283
8679
  init_global_telemetry_properties();
8680
+ init_session_id();
8284
8681
  });
8285
8682
 
8286
8683
  // ../common/src/telemetry/node.ts
8287
8684
  var init_node2 = __esm(() => {
8288
8685
  init_debug_telemetry_provider();
8289
8686
  init_detect_agent();
8687
+ init_environment_info();
8688
+ init_execution_context();
8290
8689
  init_node_context_storage();
8690
+ init_session_id();
8291
8691
  init_telemetry_service();
8292
8692
  });
8293
8693
 
@@ -8297,6 +8697,7 @@ var init_node_appinsights_telemetry_provider = __esm(() => {
8297
8697
  init_logger();
8298
8698
  init_singleton();
8299
8699
  init_global_telemetry_properties();
8700
+ init_session_id();
8300
8701
  init_global_telemetry_properties();
8301
8702
  providerSlot = singleton("TelemetryProvider");
8302
8703
  });
@@ -8702,6 +9103,7 @@ var init_formatter = __esm(() => {
8702
9103
  init_logger();
8703
9104
  init_output_context();
8704
9105
  init_output_format_context();
9106
+ init_command_terminal();
8705
9107
  init_telemetry_events();
8706
9108
  init_telemetry_init();
8707
9109
  CLI_ERROR_CODES = [
@@ -8776,8 +9178,24 @@ var init_formatter = __esm(() => {
8776
9178
  data.ErrorCode ??= defaultErrorCodeForFailure(data);
8777
9179
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
8778
9180
  process.exitCode = EXIT_CODES[data.Result] ?? 1;
8779
- const { SuppressTelemetry, ...envelope } = data;
8780
- if (!SuppressTelemetry) {
9181
+ recordCommandFailureTelemetry({
9182
+ result: data.Result,
9183
+ errorCode: data.ErrorCode,
9184
+ retry: data.Retry,
9185
+ message: data.Message,
9186
+ context: data.Context,
9187
+ exitCode: process.exitCode,
9188
+ errorClass: data.TelemetryErrorClass,
9189
+ terminalOutcome: data.TelemetryTerminalOutcome,
9190
+ terminalSignal: data.TelemetryTerminalSignal
9191
+ });
9192
+ const suppressTelemetry = data.SuppressTelemetry === true;
9193
+ const envelope = { ...data };
9194
+ delete envelope.SuppressTelemetry;
9195
+ delete envelope.TelemetryErrorClass;
9196
+ delete envelope.TelemetryTerminalOutcome;
9197
+ delete envelope.TelemetryTerminalSignal;
9198
+ if (!suppressTelemetry) {
8781
9199
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
8782
9200
  result: data.Result,
8783
9201
  errorCode: data.ErrorCode,
@@ -8841,6 +9259,159 @@ var init_formatter = __esm(() => {
8841
9259
  })(OutputFormatter ||= {});
8842
9260
  });
8843
9261
 
9262
+ // ../common/src/telemetry/command-attribution.ts
9263
+ function productMode(productArea, mode) {
9264
+ return { product_area: productArea, mode };
9265
+ }
9266
+ function attributionRecord(groups) {
9267
+ const record = {};
9268
+ for (const [productArea, mode, names] of groups) {
9269
+ const attribution = productMode(productArea, mode);
9270
+ for (const name of names) {
9271
+ record[name] = attribution;
9272
+ }
9273
+ }
9274
+ return record;
9275
+ }
9276
+ function commandAttribution(groups) {
9277
+ const entries = [];
9278
+ for (const [productArea, mode, prefixes] of groups) {
9279
+ const attribution = productMode(productArea, mode);
9280
+ for (const prefix of prefixes) {
9281
+ entries.push({ prefix, attribution });
9282
+ }
9283
+ }
9284
+ return entries;
9285
+ }
9286
+ function normalizeCommandPath(value) {
9287
+ if (typeof value !== "string") {
9288
+ return;
9289
+ }
9290
+ const trimmed = value.trim().toLowerCase();
9291
+ if (!trimmed) {
9292
+ return;
9293
+ }
9294
+ const tokens = trimmed.includes(" ") ? trimmed.split(/\s+/).filter((token) => token.length > 0).filter((token) => !token.startsWith("-")) : trimmed.split(".").filter((token) => token.length > 0);
9295
+ if (tokens.length === 0) {
9296
+ return;
9297
+ }
9298
+ const commandTokens = tokens[0] === "uip" ? tokens : ["uip", ...tokens];
9299
+ return commandTokens.join(".");
9300
+ }
9301
+ function getCommandProductModeAttribution(commandPath) {
9302
+ const normalized = normalizeCommandPath(commandPath);
9303
+ if (!normalized) {
9304
+ return;
9305
+ }
9306
+ return COMMAND_ATTRIBUTION.find(({ prefix }) => normalized === prefix || normalized.startsWith(`${prefix}.`))?.attribution;
9307
+ }
9308
+ function normalizeSkillNameWithOptions(value, options) {
9309
+ if (typeof value !== "string") {
9310
+ return;
9311
+ }
9312
+ const normalized = value.trim().toLowerCase();
9313
+ if (!normalized) {
9314
+ return;
9315
+ }
9316
+ const hasLegacyNamespace = normalized.startsWith(LEGACY_SKILL_NAMESPACE);
9317
+ if (hasLegacyNamespace && !options.allowLegacyNamespace) {
9318
+ return;
9319
+ }
9320
+ const skillName = hasLegacyNamespace ? normalized.slice(LEGACY_SKILL_NAMESPACE.length) : normalized;
9321
+ if (skillName.length > MAX_SKILL_NAME_LENGTH || !SKILL_NAME_PATTERN.test(skillName) || !KNOWN_SKILL_NAMES.has(skillName)) {
9322
+ return;
9323
+ }
9324
+ return skillName;
9325
+ }
9326
+ function normalizeSkillName(value) {
9327
+ return normalizeSkillNameWithOptions(value, {
9328
+ allowLegacyNamespace: false
9329
+ });
9330
+ }
9331
+ function buildCommandTelemetryAttribution(commandPath, skillSource) {
9332
+ const skillName = normalizeSkillName(skillSource);
9333
+ return {
9334
+ ...skillName ? { skill_name: skillName } : {},
9335
+ ...getCommandProductModeAttribution(commandPath)
9336
+ };
9337
+ }
9338
+ var LEGACY_SKILL_NAMESPACE = "uipath:", MAX_SKILL_NAME_LENGTH = 80, SKILL_NAME_PATTERN, SKILL_ATTRIBUTION, KNOWN_SKILL_NAMES, COMMAND_ATTRIBUTION;
9339
+ var init_command_attribution = __esm(() => {
9340
+ SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
9341
+ SKILL_ATTRIBUTION = attributionRecord([
9342
+ ["admin", "operate", ["uipath-admin"]],
9343
+ ["agents", "build", ["uipath-agents"]],
9344
+ ["api-workflow", "build", ["uipath-api-workflow"]],
9345
+ ["automation-discovery", "build", ["uipath-automation-discovery"]],
9346
+ ["coded-apps", "build", ["uipath-coded-apps"]],
9347
+ ["data-fabric", "operate", ["uipath-data-fabric"]],
9348
+ ["cli", "troubleshoot", ["uipath-feedback"]],
9349
+ ["governance", "operate", ["uipath-governance"]],
9350
+ ["action-center", "build", ["uipath-human-in-the-loop"]],
9351
+ ["document-understanding", "build", ["uipath-ixp"]],
9352
+ [
9353
+ "maestro",
9354
+ "build",
9355
+ ["uipath-maestro-bpmn", "uipath-maestro-case", "uipath-maestro-flow"]
9356
+ ],
9357
+ ["agenthub", "build", ["uipath-mcp-servers"]],
9358
+ ["solution", "build", ["uipath-planner", "uipath-solution"]],
9359
+ ["platform", "operate", ["uipath-platform"]],
9360
+ ["quality", "troubleshoot", ["uipath-review"]],
9361
+ ["rpa", "build", ["uipath-rpa"]],
9362
+ ["cli", "operate", ["uipath-skill-catalog"]],
9363
+ ["action-center", "operate", ["uipath-tasks"]],
9364
+ ["test-manager", "operate", ["uipath-test"]],
9365
+ ["platform", "troubleshoot", ["uipath-troubleshoot"]]
9366
+ ]);
9367
+ KNOWN_SKILL_NAMES = new Set(Object.keys(SKILL_ATTRIBUTION));
9368
+ COMMAND_ATTRIBUTION = commandAttribution([
9369
+ ["cli", "troubleshoot", ["uip.feedback"]],
9370
+ ["llm-gateway", "operate", ["uip.llm-configuration", "uip.model-hub"]],
9371
+ ["context-grounding", "build", ["uip.context-grounding"]],
9372
+ ["api-workflow", "build", ["uip.api-workflow"]],
9373
+ ["rpa", "build", ["uip.rpa-legacy"]],
9374
+ ["conversational", "operate", ["uip.conversational"]],
9375
+ ["agents", "build", ["uip.codedagent", "uip.agent"]],
9376
+ ["agenthub", "build", ["uip.agenthub"]],
9377
+ ["coded-apps", "build", ["uip.codedapp"]],
9378
+ ["functions", "build", ["uip.functions"]],
9379
+ ["solution", "build", ["uip.solution"]],
9380
+ ["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
9381
+ ["llm-observability", "troubleshoot", ["uip.traces"]],
9382
+ ["platform", "operate", ["uip.platform"]],
9383
+ ["admin", "operate", ["uip.admin"]],
9384
+ ["automation-ops", "operate", ["uip.aops"]],
9385
+ ["documentation", "troubleshoot", ["uip.docsai"]],
9386
+ ["governance", "operate", ["uip.gov"]],
9387
+ ["insights", "operate", ["uip.insights"]],
9388
+ ["document-understanding", "build", ["uip.ixp"]],
9389
+ ["process-mining", "operate", ["uip.pm"]],
9390
+ ["action-center", "operate", ["uip.tasks"]],
9391
+ ["test-manager", "operate", ["uip.tm"]],
9392
+ ["vertical-solutions", "build", ["uip.vss"]],
9393
+ ["data-fabric", "operate", ["uip.df"]],
9394
+ ["integration-service", "build", ["uip.is"]],
9395
+ ["orchestrator", "operate", ["uip.or"]],
9396
+ [
9397
+ "cli",
9398
+ "operate",
9399
+ [
9400
+ "uip.login",
9401
+ "uip.logout",
9402
+ "uip.user",
9403
+ "uip.config",
9404
+ "uip.tools",
9405
+ "uip.skills",
9406
+ "uip.completion",
9407
+ "uip.update",
9408
+ "uip.mcp",
9409
+ "uip.track"
9410
+ ]
9411
+ ]
9412
+ ]).sort((a, b) => b.prefix.length - a.prefix.length);
9413
+ });
9414
+
8844
9415
  // ../common/src/telemetry/pii-redactor.ts
8845
9416
  function shortHash(input) {
8846
9417
  let hash = 2166136261;
@@ -9016,12 +9587,20 @@ function commandHelpHint(commandPath) {
9016
9587
  const command = commandPath.replace(/\./g, " ");
9017
9588
  return `An unexpected error occurred. Run '${command} --help' to verify command syntax, or run with --log-level debug for details.`;
9018
9589
  }
9590
+ function isPromptCancellation(error) {
9591
+ return error instanceof Error && error.name === "ExitPromptError";
9592
+ }
9593
+ function exitCodeFromProcess(fallback) {
9594
+ return typeof process.exitCode === "number" ? process.exitCode : fallback;
9595
+ }
9019
9596
  var pollSignalSlot, cliErrorCodeValues, retryHintValues, processContext;
9020
9597
  var init_trackedAction = __esm(() => {
9021
9598
  init_esm();
9022
9599
  init_formatter();
9023
9600
  init_logger();
9024
9601
  init_singleton();
9602
+ init_command_attribution();
9603
+ init_command_terminal();
9025
9604
  init_pii_redactor();
9026
9605
  init_telemetry_init();
9027
9606
  pollSignalSlot = singleton("PollSignal");
@@ -9042,6 +9621,8 @@ var init_trackedAction = __esm(() => {
9042
9621
  const props = typeof properties === "function" ? properties(...args) : properties;
9043
9622
  const startTime = performance.now();
9044
9623
  let errorMessage;
9624
+ let fallbackExitCode = EXIT_CODES.Success;
9625
+ clearRecordedCommandFailureTelemetry();
9045
9626
  const [error] = await catchError(fn(...args));
9046
9627
  if (error) {
9047
9628
  errorMessage = error instanceof Error ? error.message : String(error);
@@ -9056,6 +9637,8 @@ var init_trackedAction = __esm(() => {
9056
9637
  const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
9057
9638
  const typedContext = typed.context ?? typed.Context;
9058
9639
  const customContext = isErrorContext(typedContext) ? typedContext : undefined;
9640
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
9641
+ fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
9059
9642
  OutputFormatter.error({
9060
9643
  Result: finalResult,
9061
9644
  ...customErrorCode ? { ErrorCode: customErrorCode } : {},
@@ -9064,16 +9647,26 @@ var init_trackedAction = __esm(() => {
9064
9647
  ...customRetry ? { Retry: customRetry } : {},
9065
9648
  ...customContext ? { Context: customContext } : {}
9066
9649
  });
9067
- context.exit(EXIT_CODES[finalResult]);
9650
+ context.exit(fallbackExitCode);
9068
9651
  }
9069
9652
  const durationMs = performance.now() - startTime;
9070
- const success = !error && (process.exitCode === undefined || process.exitCode === 0);
9653
+ const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
9654
+ const recordedFailure = takeRecordedCommandFailureTelemetry();
9655
+ const success = !error && exitCode === 0;
9656
+ const terminalTelemetry = buildCommandTerminalTelemetryProperties({
9657
+ error,
9658
+ exitCode,
9659
+ recordedFailure,
9660
+ pollSignal: context.pollSignal
9661
+ });
9071
9662
  telemetry.trackEvent(telemetryName, redactProperties({
9072
9663
  ...extractCommandParams(command),
9073
9664
  ...props,
9665
+ ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
9074
9666
  command: "true",
9075
9667
  duration: String(durationMs),
9076
9668
  success: String(success),
9669
+ ...terminalTelemetry,
9077
9670
  ...errorMessage ? { errorMessage } : {}
9078
9671
  }));
9079
9672
  });
@@ -9735,6 +10328,44 @@ var init_sdk_user_agent = __esm(() => {
9735
10328
  init_global_telemetry_properties();
9736
10329
  sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
9737
10330
  });
10331
+ // ../common/src/telemetry/ship-succeeded.ts
10332
+ function getShippedKeys() {
10333
+ const existing = shippedKeysSlot.get();
10334
+ if (existing) {
10335
+ return existing;
10336
+ }
10337
+ const keys = new Set;
10338
+ shippedKeysSlot.set(keys);
10339
+ return keys;
10340
+ }
10341
+ function dedupeKey(payload) {
10342
+ return [
10343
+ payload.command_name,
10344
+ payload.ship_kind,
10345
+ payload.target,
10346
+ payload.project_type,
10347
+ payload.artifact_correlation_key ?? payload.package_version_key ?? payload.deployment_key ?? payload.solution_id ?? payload.package_name ?? ""
10348
+ ].join("|");
10349
+ }
10350
+ function trackShipSucceeded(payload) {
10351
+ const keys = getShippedKeys();
10352
+ const key = dedupeKey(payload);
10353
+ if (keys.has(key)) {
10354
+ return false;
10355
+ }
10356
+ keys.add(key);
10357
+ telemetry.trackEvent(CommonTelemetryEvents.ShipSucceeded, redactProperties({ ...payload }));
10358
+ return true;
10359
+ }
10360
+ var shippedKeysSlot;
10361
+ var init_ship_succeeded = __esm(() => {
10362
+ init_singleton();
10363
+ init_pii_redactor();
10364
+ init_telemetry_events();
10365
+ init_telemetry_init();
10366
+ shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
10367
+ });
10368
+
9738
10369
  // ../common/src/tool-provider.ts
9739
10370
  var factorySlot;
9740
10371
  var init_tool_provider = __esm(() => {
@@ -9746,6 +10377,8 @@ var init_tool_provider = __esm(() => {
9746
10377
  var init_src2 = __esm(() => {
9747
10378
  init_console_guard();
9748
10379
  init_node_appinsights_telemetry_provider();
10380
+ init_pii_redactor();
10381
+ init_ship_succeeded();
9749
10382
  init_attachment_binding();
9750
10383
  init_command_examples();
9751
10384
  init_command_help();
@@ -9768,6 +10401,8 @@ var init_src2 = __esm(() => {
9768
10401
  init_screen_logger();
9769
10402
  init_sdk_user_agent();
9770
10403
  init_singleton();
10404
+ init_command_attribution();
10405
+ init_command_terminal();
9771
10406
  init_node2();
9772
10407
  init_telemetry_events();
9773
10408
  init_telemetry_init();
@@ -30457,6 +31092,9 @@ var init_selectTenant = __esm(() => {
30457
31092
  ]);
30458
31093
  });
30459
31094
 
31095
+ // ../auth/src/types.ts
31096
+ var AUTH_FLOW_ENV_VAR = "UIPATH_AUTH_FLOW";
31097
+
30460
31098
  // ../auth/src/interactive.ts
30461
31099
  var interactiveLoginWithDeps = async (options, deps) => {
30462
31100
  const {
@@ -30506,6 +31144,7 @@ var interactiveLoginWithDeps = async (options, deps) => {
30506
31144
  if (noBrowser && !resolvedSecret && !onEvent) {
30507
31145
  throw new Error("noBrowser login requires an onEvent subscriber to receive the " + "auth-url event — the authorize URL is delivered through it.");
30508
31146
  }
31147
+ const authFlow = resolvedSecret ? "client_credentials" : "authorization_code";
30509
31148
  const authPromise = resolvedSecret ? (async () => {
30510
31149
  return await clientCredentials({
30511
31150
  clientId: config.clientId,
@@ -30536,7 +31175,8 @@ var interactiveLoginWithDeps = async (options, deps) => {
30536
31175
  issuerAsserter(tokens.UIPATH_ACCESS_TOKEN, config.baseUrl);
30537
31176
  const credentials = {
30538
31177
  ...tokens,
30539
- UIPATH_URL: config.baseUrl
31178
+ UIPATH_URL: config.baseUrl,
31179
+ [AUTH_FLOW_ENV_VAR]: authFlow
30540
31180
  };
30541
31181
  try {
30542
31182
  const tokenData = jwtParser(tokens.UIPATH_ACCESS_TOKEN);
@@ -31130,7 +31770,8 @@ __export(exports_src2, {
31130
31770
  DEFAULT_AUTH_FILENAME: () => DEFAULT_AUTH_FILENAME,
31131
31771
  ClientCredentialsAuthenticationError: () => ClientCredentialsAuthenticationError,
31132
31772
  AuthProfileValidationError: () => AuthProfileValidationError,
31133
- AUTH_TIMEOUT_ERROR_CODE: () => AUTH_TIMEOUT_ERROR_CODE
31773
+ AUTH_TIMEOUT_ERROR_CODE: () => AUTH_TIMEOUT_ERROR_CODE,
31774
+ AUTH_FLOW_ENV_VAR: () => AUTH_FLOW_ENV_VAR
31134
31775
  });
31135
31776
  var authenticate = async ({
31136
31777
  baseUrl,
@@ -56457,7 +57098,7 @@ var init_package = __esm(() => {
56457
57098
  package_default5 = {
56458
57099
  name: "@uipath/integrationservice-sdk",
56459
57100
  license: "MIT",
56460
- version: "1.197.0-preview.65",
57101
+ version: "1.197.0-preview.66",
56461
57102
  repository: {
56462
57103
  type: "git",
56463
57104
  url: "https://github.com/UiPath/cli.git",
@@ -80470,7 +81111,7 @@ import"./packager-tool.js";
80470
81111
  var package_default = {
80471
81112
  name: "@uipath/agent-tool",
80472
81113
  license: "MIT",
80473
- version: "1.197.0-preview.65",
81114
+ version: "1.197.0-preview.66",
80474
81115
  description: "cli plugin for creating and managing UiPath low-code agents",
80475
81116
  private: false,
80476
81117
  repository: {
@@ -80645,7 +81286,7 @@ function applyConfigUpdate(agent, key, rawValue) {
80645
81286
  throw new Error(`Unknown config key: "${key}". Valid keys: ${Object.keys(CONFIG_KEY_MAP).join(", ")}`);
80646
81287
  }
80647
81288
  const parsed = parseValue(rawValue);
80648
- if (key === "engineSettings" && !isRecord(parsed)) {
81289
+ if (key === "engineSettings" && !isRecord2(parsed)) {
80649
81290
  throw new Error("engineSettings must be a JSON object");
80650
81291
  }
80651
81292
  let target = updated;
@@ -80672,7 +81313,7 @@ function parseValue(raw) {
80672
81313
  }
80673
81314
  return parsed;
80674
81315
  }
80675
- function isRecord(value) {
81316
+ function isRecord2(value) {
80676
81317
  return typeof value === "object" && value !== null && !Array.isArray(value);
80677
81318
  }
80678
81319
  function parsePromptTokens(prompt) {
@@ -85486,7 +86127,7 @@ class TextApiResponse2 {
85486
86127
  var package_default3 = {
85487
86128
  name: "@uipath/solution-sdk",
85488
86129
  license: "MIT",
85489
- version: "1.197.0-preview.65",
86130
+ version: "1.197.0-preview.66",
85490
86131
  repository: {
85491
86132
  type: "git",
85492
86133
  url: "https://github.com/UiPath/cli.git",
@@ -86290,7 +86931,7 @@ async function readUipxFile(fs7, solutionDir) {
86290
86931
  return { uipx, uipxFileName };
86291
86932
  }
86292
86933
  function validateUipxFile(parsed, uipxFileName) {
86293
- if (!isRecord2(parsed)) {
86934
+ if (!isRecord3(parsed)) {
86294
86935
  throw new Error(`Invalid .uipx file: ${uipxFileName} must contain a JSON object.`);
86295
86936
  }
86296
86937
  if (typeof parsed.SolutionId !== "string" || !parsed.SolutionId.trim()) {
@@ -86300,7 +86941,7 @@ function validateUipxFile(parsed, uipxFileName) {
86300
86941
  throw new Error("Invalid .uipx file: missing Projects.");
86301
86942
  }
86302
86943
  for (const [index, project] of parsed.Projects.entries()) {
86303
- if (!isRecord2(project)) {
86944
+ if (!isRecord3(project)) {
86304
86945
  throw new Error(`Invalid .uipx file: Projects[${index}] must be an object.`);
86305
86946
  }
86306
86947
  if (typeof project.ProjectRelativePath !== "string" || !project.ProjectRelativePath.trim()) {
@@ -86310,7 +86951,7 @@ function validateUipxFile(parsed, uipxFileName) {
86310
86951
  }
86311
86952
  return parsed;
86312
86953
  }
86313
- function isRecord2(value) {
86954
+ function isRecord3(value) {
86314
86955
  return typeof value === "object" && value !== null && !Array.isArray(value);
86315
86956
  }
86316
86957
  async function updateUipxSolutionId(fs7, uipxPath, newSolutionId) {
@@ -86568,11 +87209,11 @@ async function readProjectManifest(fs7, filePath, useProjectJson) {
86568
87209
  null
86569
87210
  ];
86570
87211
  }
86571
- if (!isRecord2(parsed)) {
87212
+ if (!isRecord3(parsed)) {
86572
87213
  return [new Error(`Invalid project file: ${filePath}`), null];
86573
87214
  }
86574
87215
  const designOptions = parsed.designOptions;
86575
- const outputType = useProjectJson && isRecord2(designOptions) ? readString(designOptions.outputType) : undefined;
87216
+ const outputType = useProjectJson && isRecord3(designOptions) ? readString(designOptions.outputType) : undefined;
86576
87217
  const projectType = outputType ?? readString(parsed.ProjectType);
86577
87218
  if (!projectType) {
86578
87219
  return [new Error(`ProjectType not found in ${filePath}`), null];
@@ -86599,7 +87240,7 @@ async function readSolutionManifest(fs7, solutionFile) {
86599
87240
  null
86600
87241
  ];
86601
87242
  }
86602
- if (!isRecord2(parsed)) {
87243
+ if (!isRecord3(parsed)) {
86603
87244
  return [
86604
87245
  new Error(`Invalid solution file: ${solutionFile} must contain a JSON object.`),
86605
87246
  null
@@ -86613,7 +87254,7 @@ async function readSolutionManifest(fs7, solutionFile) {
86613
87254
  }
86614
87255
  const projects = [];
86615
87256
  for (const [index, project] of parsed.Projects.entries()) {
86616
- if (!isRecord2(project)) {
87257
+ if (!isRecord3(project)) {
86617
87258
  return [
86618
87259
  new Error(`Invalid solution file: Projects[${index}] must be an object.`),
86619
87260
  null
@@ -87949,7 +88590,7 @@ var UUID_PATTERN2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}
87949
88590
  function isUUID(value) {
87950
88591
  return UUID_PATTERN2.test(value);
87951
88592
  }
87952
- function isRecord3(value) {
88593
+ function isRecord4(value) {
87953
88594
  return typeof value === "object" && value !== null && !Array.isArray(value);
87954
88595
  }
87955
88596
  function toForwardSlash2(path3) {
@@ -87998,7 +88639,7 @@ class AgentLocalWorkspaceEvalPreparer {
87998
88639
  }
87999
88640
  const projectFileContent = await this.fs.readFile(projectFilePath, "utf-8");
88000
88641
  const [projectFileError, parsedProjectFile] = catchError(() => JSON.parse(String(projectFileContent)));
88001
- if (projectFileError || !isRecord3(parsedProjectFile)) {
88642
+ if (projectFileError || !isRecord4(parsedProjectFile)) {
88002
88643
  throw new Error(`Invalid project.uiproj in ${agentDir}: ${projectFileError?.message ?? "expected a JSON object"}`);
88003
88644
  }
88004
88645
  const projectFile = {
@@ -88644,6 +89285,16 @@ var registerDeployCommand = (program2) => {
88644
89285
  },
88645
89286
  Instructions: provisionedFolderId ? `Deployment active and provisioned. Run: agent run list --folder-id ${provisionedFolderId}` : "Deployment active. Use 'agent run list --folder-id <id>' to find releases, then 'agent run start' to run."
88646
89287
  });
89288
+ trackShipSucceeded({
89289
+ ship_kind: "deploy",
89290
+ target: "orchestrator",
89291
+ project_type: "low_code_agent",
89292
+ command_name: "uip.agent.deploy",
89293
+ artifact_correlation_key: deploymentKey,
89294
+ deployment_key: deploymentKey,
89295
+ package_version_key: packageVersionKey,
89296
+ folder_key: activateResult.installedRootFolderKey
89297
+ });
88647
89298
  } else {
88648
89299
  OutputFormatter.success({
88649
89300
  Result: RESULTS.Success,
@@ -88659,6 +89310,16 @@ var registerDeployCommand = (program2) => {
88659
89310
  },
88660
89311
  Instructions: options.skipActivate ? `Installed${provisionedFolderId ? " and provisioned" : ""} but not activated. Activate manually or re-run without --skip-activate.` : `Deployment installed${provisionedFolderId ? " and provisioned" : ""}. Activate when ready.`
88661
89312
  });
89313
+ trackShipSucceeded({
89314
+ ship_kind: "deploy",
89315
+ target: "orchestrator",
89316
+ project_type: "low_code_agent",
89317
+ command_name: "uip.agent.deploy",
89318
+ artifact_correlation_key: deploymentKey,
89319
+ deployment_key: deploymentKey,
89320
+ package_version_key: packageVersionKey,
89321
+ folder_key: installResult.installedRootFolderKey
89322
+ });
88662
89323
  }
88663
89324
  })());
88664
89325
  if (error) {
@@ -89072,7 +89733,7 @@ class VoidApiResponse3 {
89072
89733
  var package_default4 = {
89073
89734
  name: "@uipath/agent-sdk",
89074
89735
  license: "MIT",
89075
- version: "1.197.0-preview.65",
89736
+ version: "1.197.0-preview.66",
89076
89737
  description: "SDK for the UiPath Agent Runtime API — evaluation execution and debug sessions.",
89077
89738
  repository: {
89078
89739
  type: "git",
@@ -93991,6 +94652,110 @@ async function uploadNupkgsToOrchestrator(solutionZipPath, loginStatus2, folderO
93991
94652
  }
93992
94653
  return { releases };
93993
94654
  }
94655
+ async function resolveAgentUisPath(inputPath, packageNameOverride) {
94656
+ const fs7 = getFileSystem();
94657
+ const absPath = fs7.path.resolve(inputPath);
94658
+ const pathExists = await fs7.exists(absPath);
94659
+ if (!pathExists || absPath.endsWith(".uis")) {
94660
+ return { absPath, uisPath: absPath };
94661
+ }
94662
+ const projectService = new AgentProjectService;
94663
+ const validation = await projectService.validateProjectStructure(absPath);
94664
+ if (!validation.valid) {
94665
+ throw new Error(`Invalid agent project:
94666
+ ${validation.errors.join(`
94667
+ `)}`);
94668
+ }
94669
+ const agent = await projectService.readAgentJson(absPath);
94670
+ const packageName = packageNameOverride ?? agent.metadata.name ?? fs7.path.basename(absPath);
94671
+ const tempDir = fs7.path.join(fs7.env.tmpdir(), `agent-publish-${Date.now()}`);
94672
+ await fs7.mkdir(tempDir);
94673
+ const uisPath = fs7.path.join(tempDir, `${packageName}.uis`);
94674
+ await createArchive(absPath, uisPath);
94675
+ OutputFormatter.log({
94676
+ Message: `Packed agent to ${uisPath}`
94677
+ });
94678
+ return { absPath, uisPath };
94679
+ }
94680
+ async function publishDirectAgentPackage(zipPath, loginStatus2, tenantName, packageName, packageVersion, folderId) {
94681
+ OutputFormatter.log({
94682
+ Message: "Uploading packages directly to Orchestrator..."
94683
+ });
94684
+ const result = await uploadNupkgsToOrchestrator(zipPath, { ...loginStatus2, tenantName }, folderId);
94685
+ OutputFormatter.success({
94686
+ Result: RESULTS.Success,
94687
+ Code: "AgentPublish",
94688
+ Data: {
94689
+ Status: "Published to Orchestrator (direct)",
94690
+ Name: packageName,
94691
+ Version: packageVersion,
94692
+ Releases: result.releases.map((r) => ({
94693
+ Name: r.name,
94694
+ Key: r.key,
94695
+ ProcessKey: r.processKey
94696
+ }))
94697
+ }
94698
+ });
94699
+ const firstRelease = result.releases[0];
94700
+ trackShipSucceeded({
94701
+ ship_kind: "publish",
94702
+ target: folderId ? "orchestrator_folder_package_feed" : "orchestrator_tenant_package_feed",
94703
+ project_type: "low_code_agent",
94704
+ command_name: "uip.agent.publish",
94705
+ artifact_correlation_key: firstRelease?.processKey ?? firstRelease?.key ?? `${packageName}:${packageVersion}`,
94706
+ package_name: packageName,
94707
+ package_version: packageVersion,
94708
+ folder_key: folderId
94709
+ });
94710
+ }
94711
+ async function publishSolutionAgentPackage(zipPath, loginStatus2, tenantName, packageName, packageVersion, locationKey) {
94712
+ const fs7 = getFileSystem();
94713
+ OutputFormatter.log({
94714
+ Message: "Publishing to Orchestrator..."
94715
+ });
94716
+ const fileBuffer = await fs7.readFile(zipPath);
94717
+ if (!fileBuffer) {
94718
+ throw new Error(`Failed to read solution zip: ${zipPath}`);
94719
+ }
94720
+ const basePath = `${loginStatus2.baseUrl}/${loginStatus2.organizationId}/${tenantName}/automationsolutions_`;
94721
+ const configuration = new Configuration3({
94722
+ basePath,
94723
+ accessToken: loginStatus2.accessToken
94724
+ });
94725
+ const api2 = new PackagesApi(configuration);
94726
+ const packageVersionKey = await api2.packagesUpload({
94727
+ locationKey,
94728
+ body: fileBuffer
94729
+ });
94730
+ OutputFormatter.success({
94731
+ Result: RESULTS.Success,
94732
+ Code: "AgentPublish",
94733
+ Data: {
94734
+ Status: "Published successfully",
94735
+ Name: packageName,
94736
+ Version: packageVersion,
94737
+ PackageVersionKey: packageVersionKey
94738
+ },
94739
+ Instructions: "Deploy via Orchestrator UI or use --direct flag for direct upload."
94740
+ });
94741
+ trackShipSucceeded({
94742
+ ship_kind: "publish",
94743
+ target: "tenant_solution_feed",
94744
+ project_type: "low_code_agent",
94745
+ command_name: "uip.agent.publish",
94746
+ artifact_correlation_key: packageVersionKey,
94747
+ package_version_key: packageVersionKey,
94748
+ package_name: packageName,
94749
+ package_version: packageVersion
94750
+ });
94751
+ }
94752
+ async function publishPackedAgentPackage(zipPath, loginStatus2, tenantName, packageName, options) {
94753
+ if (options.direct) {
94754
+ await publishDirectAgentPackage(zipPath, loginStatus2, tenantName, packageName, options.packageVersion, options.folderId);
94755
+ return;
94756
+ }
94757
+ await publishSolutionAgentPackage(zipPath, loginStatus2, tenantName, packageName, options.packageVersion, options.locationKey);
94758
+ }
93994
94759
  var registerPublishCommand = (program2) => {
93995
94760
  program2.command("publish").description("Pack and publish an agent to UiPath Orchestrator").argument("[path]", "Path to agent project directory or .uis file", ".").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant>")).option("-l, --location-key <guid>", "Location key (optional GUID)").option("-n, --name <name>", "Package name (default: agent name)").option("--package-version <version>", "Package version (default: 1.0.0)", "1.0.0").option("--folder-id <id>", "Orchestrator folder org unit ID for direct upload").option("--direct", "Upload nupkg directly to Orchestrator (bypasses solution deployment)").option("--login-validity <minutes>", "Minimum minutes before token expiration", (v) => Number.parseInt(v, 10), 10).examples(PUBLISH_EXAMPLES).trackedAction(processContext, async (inputPath, options) => {
93996
94761
  const [error40] = await catchError((async () => {
@@ -94001,35 +94766,13 @@ var registerPublishCommand = (program2) => {
94001
94766
  if (loginStatus2.loginStatus !== "Logged in" || !loginStatus2.accessToken || !loginStatus2.baseUrl || !loginStatus2.organizationId) {
94002
94767
  throw new Error("Not logged in. Run 'uip login' first.");
94003
94768
  }
94004
- const absPath = fs7.path.resolve(inputPath);
94005
- let uisPath;
94006
- const pathExists = await fs7.exists(absPath);
94007
- if (pathExists && !absPath.endsWith(".uis")) {
94008
- const projectService = new AgentProjectService;
94009
- const validation = await projectService.validateProjectStructure(absPath);
94010
- if (!validation.valid) {
94011
- throw new Error(`Invalid agent project:
94012
- ${validation.errors.join(`
94013
- `)}`);
94014
- }
94015
- const agent = await projectService.readAgentJson(absPath);
94016
- const packageName2 = options.name ?? agent.metadata.name ?? fs7.path.basename(absPath);
94017
- const tempDir = fs7.path.join(fs7.env.tmpdir(), `agent-publish-${Date.now()}`);
94018
- await fs7.mkdir(tempDir);
94019
- uisPath = fs7.path.join(tempDir, `${packageName2}.uis`);
94020
- await createArchive(absPath, uisPath);
94021
- OutputFormatter.log({
94022
- Message: `Packed agent to ${uisPath}`
94023
- });
94024
- } else {
94025
- uisPath = absPath;
94026
- }
94769
+ const { absPath, uisPath } = await resolveAgentUisPath(inputPath, options.name);
94027
94770
  const { execFile: execFile7 } = await import("node:child_process");
94028
94771
  const { promisify: promisify7 } = await import("node:util");
94029
94772
  const execFileAsync5 = promisify7(execFile7);
94030
94773
  const packOutputDir = fs7.path.join(fs7.env.tmpdir(), `agent-pack-output-${Date.now()}`);
94031
94774
  await fs7.mkdir(packOutputDir);
94032
- const packageName = options.name ?? fs7.path.basename(fs7.path.resolve(inputPath), ".uis");
94775
+ const packageName = options.name ?? fs7.path.basename(absPath, ".uis");
94033
94776
  const uipPath = process.argv[1];
94034
94777
  if (!uipPath) {
94035
94778
  throw new Error("Could not determine CLI entry point from process.argv.");
@@ -94065,55 +94808,7 @@ ${validation.errors.join(`
94065
94808
  if (!tenantName) {
94066
94809
  throw new Error("Tenant must be selected during login. Run 'uip login' or 'uip login tenant set <tenant>'.");
94067
94810
  }
94068
- if (options.direct) {
94069
- OutputFormatter.log({
94070
- Message: "Uploading packages directly to Orchestrator..."
94071
- });
94072
- const result = await uploadNupkgsToOrchestrator(zipPath, { ...loginStatus2, tenantName }, options.folderId);
94073
- OutputFormatter.success({
94074
- Result: RESULTS.Success,
94075
- Code: "AgentPublish",
94076
- Data: {
94077
- Status: "Published to Orchestrator (direct)",
94078
- Name: packageName,
94079
- Version: options.packageVersion,
94080
- Releases: result.releases.map((r) => ({
94081
- Name: r.name,
94082
- Key: r.key,
94083
- ProcessKey: r.processKey
94084
- }))
94085
- }
94086
- });
94087
- } else {
94088
- OutputFormatter.log({
94089
- Message: "Publishing to Orchestrator..."
94090
- });
94091
- const fileBuffer = await fs7.readFile(zipPath);
94092
- if (!fileBuffer) {
94093
- throw new Error(`Failed to read solution zip: ${zipPath}`);
94094
- }
94095
- const basePath = `${loginStatus2.baseUrl}/${loginStatus2.organizationId}/${tenantName}/automationsolutions_`;
94096
- const configuration = new Configuration3({
94097
- basePath,
94098
- accessToken: loginStatus2.accessToken
94099
- });
94100
- const api2 = new PackagesApi(configuration);
94101
- const packageVersionKey = await api2.packagesUpload({
94102
- locationKey: options.locationKey,
94103
- body: fileBuffer
94104
- });
94105
- OutputFormatter.success({
94106
- Result: RESULTS.Success,
94107
- Code: "AgentPublish",
94108
- Data: {
94109
- Status: "Published successfully",
94110
- Name: packageName,
94111
- Version: options.packageVersion,
94112
- PackageVersionKey: packageVersionKey
94113
- },
94114
- Instructions: "Deploy via Orchestrator UI or use --direct flag for direct upload."
94115
- });
94116
- }
94811
+ await publishPackedAgentPackage(zipPath, loginStatus2, tenantName, packageName, options);
94117
94812
  })());
94118
94813
  if (error40) {
94119
94814
  OutputFormatter.error({
@@ -94395,7 +95090,7 @@ function extractSolutions(value) {
94395
95090
  if (Array.isArray(value)) {
94396
95091
  return value.filter(isStudioSolutionSummary);
94397
95092
  }
94398
- if (!isRecord4(value)) {
95093
+ if (!isRecord5(value)) {
94399
95094
  return [];
94400
95095
  }
94401
95096
  for (const key of ["value", "data", "items", "results"]) {
@@ -94407,9 +95102,9 @@ function extractSolutions(value) {
94407
95102
  return [];
94408
95103
  }
94409
95104
  function isStudioSolutionSummary(value) {
94410
- return isRecord4(value) && typeof value.name === "string" && (value.id === undefined || typeof value.id === "string") && (value.solutionId === undefined || typeof value.solutionId === "string");
95105
+ return isRecord5(value) && typeof value.name === "string" && (value.id === undefined || typeof value.id === "string") && (value.solutionId === undefined || typeof value.solutionId === "string");
94411
95106
  }
94412
- function isRecord4(value) {
95107
+ function isRecord5(value) {
94413
95108
  return typeof value === "object" && value !== null && !Array.isArray(value);
94414
95109
  }
94415
95110
 
@@ -99212,17 +99907,17 @@ async function loadGuardrailPolicies(value) {
99212
99907
  return normalizeGuardrailPolicies(fileParsed);
99213
99908
  }
99214
99909
  function normalizeGuardrailPolicies(value) {
99215
- const policies = Array.isArray(value) ? value : isRecord5(value) && Array.isArray(value.policies) ? value.policies : isRecord5(value) ? [value] : undefined;
99910
+ const policies = Array.isArray(value) ? value : isRecord6(value) && Array.isArray(value.policies) ? value.policies : isRecord6(value) ? [value] : undefined;
99216
99911
  if (!policies) {
99217
99912
  throw new Error("Guardrails must be a JSON policy object, an array of policies, or an object with a policies array.");
99218
99913
  }
99219
99914
  return policies.map(normalizeGuardrailPolicy);
99220
99915
  }
99221
- function isRecord5(value) {
99916
+ function isRecord6(value) {
99222
99917
  return typeof value === "object" && value !== null && !Array.isArray(value);
99223
99918
  }
99224
99919
  function normalizeGuardrailPolicy(value) {
99225
- if (!isRecord5(value) || !instanceOfAgentGuardrailPolicy(value) || !isRecord5(value.action)) {
99920
+ if (!isRecord6(value) || !instanceOfAgentGuardrailPolicy(value) || !isRecord6(value.action)) {
99226
99921
  throw new Error("Each guardrail policy must be a JSON object with an action object.");
99227
99922
  }
99228
99923
  return value;
@@ -99279,4 +99974,4 @@ export {
99279
99974
  metadata
99280
99975
  };
99281
99976
 
99282
- //# debugId=D20CAD332169916D64756E2164756E21
99977
+ //# debugId=C57508477C5C9A0C64756E2164756E21
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/agent-tool",
3
3
  "license": "MIT",
4
- "version": "1.197.0-preview.65",
4
+ "version": "1.197.0-preview.66",
5
5
  "description": "cli plugin for creating and managing UiPath low-code agents",
6
6
  "private": false,
7
7
  "repository": {
@@ -26,5 +26,5 @@
26
26
  "files": [
27
27
  "dist"
28
28
  ],
29
- "gitHead": "9388ccbe5e739c9578bfd9b5395980fb63e11d9c"
29
+ "gitHead": "386b0837882b19062bf744c74949cdf9c5e48dea"
30
30
  }