@uipath/common 1.199.0-preview.97 → 1.200.0-preview.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3194,6 +3194,9 @@ async function extractErrorDetails(error, options) {
3194
3194
  if (!extractedMessage) {
3195
3195
  extractedMessage = body;
3196
3196
  }
3197
+ if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
3198
+ extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
3199
+ }
3197
3200
  } else {
3198
3201
  extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
3199
3202
  }
@@ -3248,6 +3251,8 @@ async function extractErrorDetails(error, options) {
3248
3251
  const extra = {};
3249
3252
  if (parsedBody.errorCode)
3250
3253
  extra.errorCode = parsedBody.errorCode;
3254
+ if (parsedBody.detail)
3255
+ extra.detail = parsedBody.detail;
3251
3256
  if (parsedBody.details)
3252
3257
  extra.details = parsedBody.details;
3253
3258
  if (parsedBody.errors != null)
@@ -6454,7 +6459,7 @@ function requireOmap() {
6454
6459
  function resolveYamlOmap(data) {
6455
6460
  if (data === null)
6456
6461
  return true;
6457
- const objectKeys = [];
6462
+ const objectKeys = {};
6458
6463
  const object = data;
6459
6464
  for (let index = 0, length = object.length;index < length; index += 1) {
6460
6465
  const pair = object[index];
@@ -6472,10 +6477,9 @@ function requireOmap() {
6472
6477
  }
6473
6478
  if (!pairHasKey)
6474
6479
  return false;
6475
- if (objectKeys.indexOf(pairKey) === -1)
6476
- objectKeys.push(pairKey);
6477
- else
6480
+ if (_hasOwnProperty.call(objectKeys, pairKey))
6478
6481
  return false;
6482
+ Object.defineProperty(objectKeys, pairKey, { value: true });
6479
6483
  }
6480
6484
  return true;
6481
6485
  }
@@ -9145,9 +9149,12 @@ function buildCommandTerminalTelemetryProperties(input) {
9145
9149
  // src/telemetry/telemetry-events.ts
9146
9150
  var CommonTelemetryEvents = {
9147
9151
  Error: "uip.error",
9148
- ShipSucceeded: "ship_succeeded"
9152
+ ShipSucceeded: "uip.ship.succeeded"
9149
9153
  };
9150
9154
 
9155
+ // src/telemetry/telemetry-init.ts
9156
+ import { spawn } from "node:child_process";
9157
+
9151
9158
  // src/registry.ts
9152
9159
  import { execFileSync as execFileSync2 } from "node:child_process";
9153
9160
  function readRegistryValue(keyPath, valueName) {
@@ -9476,8 +9483,18 @@ function getInboundTraceContext() {
9476
9483
 
9477
9484
  // src/telemetry/session-id.ts
9478
9485
  var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
9479
- var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
9480
- var telemetrySessionIdSlot = singleton("TelemetrySessionId");
9486
+ var SESSION_ID_MAX_LENGTH = 64;
9487
+ var RANDOM_SESSION_ID_LENGTH = 32;
9488
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "session_id_source";
9489
+ var CONTROL_CHARACTERS = /\p{Cc}/gu;
9490
+ var INHERITED_SESSION_SOURCES = [
9491
+ { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
9492
+ { envVar: "CODEX_THREAD_ID", source: "codex" },
9493
+ { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
9494
+ { envVar: "TERM_SESSION_ID", source: "terminal" },
9495
+ { envVar: "WT_SESSION", source: "terminal" }
9496
+ ];
9497
+ var telemetrySessionSlot = singleton("TelemetrySession");
9481
9498
  var telemetryOperationIdSlot = singleton("TelemetryOperationId");
9482
9499
  function getProcessEnv2() {
9483
9500
  return globalThis.process?.env;
@@ -9486,27 +9503,45 @@ function normalizeSessionId(value) {
9486
9503
  if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
9487
9504
  return;
9488
9505
  }
9489
- const trimmed = String(value).trim();
9490
- return trimmed || undefined;
9506
+ const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
9507
+ return cleaned || undefined;
9491
9508
  }
9492
9509
  function getConfiguredTelemetrySessionId() {
9493
9510
  return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
9494
9511
  }
9495
- function getTelemetrySessionId() {
9496
- const envSessionId = getConfiguredTelemetrySessionId();
9497
- if (envSessionId) {
9498
- return envSessionId;
9512
+ function getInheritedSession(env) {
9513
+ for (const candidate of INHERITED_SESSION_SOURCES) {
9514
+ const handle = normalizeSessionId(env[candidate.envVar]);
9515
+ if (handle) {
9516
+ return { id: handle, source: candidate.source };
9517
+ }
9499
9518
  }
9500
- const existing = telemetrySessionIdSlot.get();
9519
+ return;
9520
+ }
9521
+ function generateRandomSession() {
9522
+ const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
9523
+ crypto.getRandomValues(bytes);
9524
+ let hex = "";
9525
+ for (const byte of bytes) {
9526
+ hex += byte.toString(16).padStart(2, "0");
9527
+ }
9528
+ return { id: hex, source: "random" };
9529
+ }
9530
+ function resolveTelemetrySession() {
9531
+ const existing = telemetrySessionSlot.get();
9501
9532
  if (existing) {
9502
9533
  return existing;
9503
9534
  }
9504
- const generated = crypto.randomUUID();
9505
- telemetrySessionIdSlot.set(generated);
9506
- return generated;
9535
+ const declaredHandle = getConfiguredTelemetrySessionId();
9536
+ const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
9537
+ telemetrySessionSlot.set(resolved);
9538
+ return resolved;
9507
9539
  }
9508
- function resolveTelemetrySessionId(existingSessionId) {
9509
- return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
9540
+ function getTelemetrySessionId() {
9541
+ return resolveTelemetrySession().id;
9542
+ }
9543
+ function getTelemetrySessionSource() {
9544
+ return resolveTelemetrySession().source;
9510
9545
  }
9511
9546
  function getTelemetryOperationId() {
9512
9547
  const existing = telemetryOperationIdSlot.get();
@@ -9759,14 +9794,11 @@ class TelemetryService {
9759
9794
  }
9760
9795
  async trackDependencyOperation(name, type2, fn, properties) {
9761
9796
  const parentContext = this.getCurrentContext();
9762
- if (!parentContext) {
9763
- throw new Error("trackDependencyOperation must be called within a trackRequest block.");
9764
- }
9765
- const childContext = {
9797
+ const childContext = parentContext !== undefined ? {
9766
9798
  operationId: parentContext.operationId,
9767
9799
  parentId: parentContext.id,
9768
9800
  id: this.generateId()
9769
- };
9801
+ } : this.createRequestContext();
9770
9802
  const startTime = performance.now();
9771
9803
  try {
9772
9804
  const result = await this.contextStorage.run(childContext, fn);
@@ -9787,24 +9819,18 @@ class TelemetryService {
9787
9819
  }
9788
9820
  enrichPropertiesWithContext(properties, context) {
9789
9821
  const globalProperties = getGlobalTelemetryProperties();
9790
- const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
9791
- const sessionId = resolveTelemetrySessionId(existingSessionId);
9792
9822
  const enriched = {
9793
9823
  ...getExecutionContextTelemetryProperties(),
9794
9824
  ...globalProperties,
9795
9825
  ...this.defaultProperties,
9796
9826
  ...redactProperties(properties ?? {}),
9827
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
9797
9828
  ...context ? {
9798
9829
  [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
9799
9830
  ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
9800
9831
  [TELEMETRY_SPAN_ID_PROPERTY]: context.id
9801
9832
  } : {}
9802
9833
  };
9803
- if (sessionId === undefined) {
9804
- delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
9805
- } else {
9806
- enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
9807
- }
9808
9834
  return enriched;
9809
9835
  }
9810
9836
  generateId() {
@@ -9953,6 +9979,9 @@ function normalizeFlushCallbackError(response) {
9953
9979
  }
9954
9980
  return extractAppInsightsDumpMessage(text) ?? text;
9955
9981
  }
9982
+ function channelInternals(client) {
9983
+ return client.channel;
9984
+ }
9956
9985
  function setDefaultAppInsightsEnv(name, value) {
9957
9986
  if (process.env[name] === undefined) {
9958
9987
  process.env[name] = value;
@@ -10042,16 +10071,6 @@ class NodeAppInsightsTelemetryProvider {
10042
10071
  }
10043
10072
  return { operationId, parentId, spanId };
10044
10073
  }
10045
- promoteSessionTag(merged, tags) {
10046
- const client = this.client;
10047
- if (!client || !merged)
10048
- return;
10049
- const sessionId = merged[TELEMETRY_SESSION_ID_PROPERTY];
10050
- delete merged[TELEMETRY_SESSION_ID_PROPERTY];
10051
- if (sessionId) {
10052
- tags[client.context.keys.sessionId] = sessionId;
10053
- }
10054
- }
10055
10074
  leafTagOverrides(properties) {
10056
10075
  const client = this.client;
10057
10076
  if (!client)
@@ -10064,7 +10083,6 @@ class NodeAppInsightsTelemetryProvider {
10064
10083
  if (spanId) {
10065
10084
  tags[keys.operationParentId] = spanId;
10066
10085
  }
10067
- this.promoteSessionTag(properties, tags);
10068
10086
  return tags;
10069
10087
  }
10070
10088
  operationCorrelation(properties) {
@@ -10079,7 +10097,6 @@ class NodeAppInsightsTelemetryProvider {
10079
10097
  if (parentId) {
10080
10098
  tagOverrides[keys.operationParentId] = parentId;
10081
10099
  }
10082
- this.promoteSessionTag(properties, tagOverrides);
10083
10100
  return { tagOverrides, id: spanId };
10084
10101
  }
10085
10102
  async trackEvent(eventName, properties) {
@@ -10172,6 +10189,32 @@ class NodeAppInsightsTelemetryProvider {
10172
10189
  logger.warn(`[AppInsights] flush error (non-fatal): ${error.message}`);
10173
10190
  }
10174
10191
  }
10192
+ drainPendingEnvelopes() {
10193
+ const client = this.client;
10194
+ if (!client)
10195
+ return;
10196
+ const endpointUrl = client.config?.endpointUrl;
10197
+ if (!endpointUrl)
10198
+ return;
10199
+ const [error, envelopes] = catchError(() => {
10200
+ const channel = channelInternals(client);
10201
+ if (!channel || !Array.isArray(channel._buffer)) {
10202
+ throw new Error("unexpected channel shape");
10203
+ }
10204
+ if (channel._timeoutHandle) {
10205
+ clearTimeout(channel._timeoutHandle);
10206
+ channel._timeoutHandle = undefined;
10207
+ }
10208
+ const buffered = channel._buffer;
10209
+ channel._buffer = [];
10210
+ return buffered;
10211
+ });
10212
+ if (error) {
10213
+ logger.debug("[AppInsights] failed to drain the channel buffer");
10214
+ return;
10215
+ }
10216
+ return { endpointUrl, envelopes };
10217
+ }
10175
10218
  async shutdown() {
10176
10219
  const client = this.client;
10177
10220
  if (client) {
@@ -10179,6 +10222,19 @@ class NodeAppInsightsTelemetryProvider {
10179
10222
  if (statsbeatError) {
10180
10223
  logger.debug("[AppInsights] failed to shut down Statsbeat");
10181
10224
  }
10225
+ const [channelError] = catchError(() => {
10226
+ const channel = channelInternals(client);
10227
+ if (!channel)
10228
+ return;
10229
+ if (channel._timeoutHandle) {
10230
+ clearTimeout(channel._timeoutHandle);
10231
+ channel._timeoutHandle = undefined;
10232
+ }
10233
+ channel._buffer = [];
10234
+ });
10235
+ if (channelError) {
10236
+ logger.debug("[AppInsights] failed to clear the channel buffer");
10237
+ }
10182
10238
  }
10183
10239
  const appInsights = this.appInsightsModule;
10184
10240
  if (appInsights) {
@@ -10220,6 +10276,115 @@ function isTelemetryDisabled() {
10220
10276
  return value === "1" || value === "true";
10221
10277
  }
10222
10278
 
10279
+ // src/telemetry/telemetry-spool.ts
10280
+ var TELEMETRY_DRAIN_ARGV = "__uip-drain-telemetry";
10281
+ var sidecarEntrySlot = singleton("TelemetrySidecarEntry");
10282
+ function setTelemetrySidecarEntry(entryPath) {
10283
+ sidecarEntrySlot.set(entryPath);
10284
+ }
10285
+ function getTelemetrySidecarEntry() {
10286
+ return sidecarEntrySlot.get();
10287
+ }
10288
+ var PENDING_SUFFIX = ".json";
10289
+ var CLAIMED_SUFFIX = ".sending";
10290
+ var WRITE_TEMP_SUFFIX = ".tmp";
10291
+ var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
10292
+ var MAX_SPOOL_FILES = 50;
10293
+ function getTelemetrySpoolDir() {
10294
+ const fs7 = getFileSystem();
10295
+ return fs7.path.join(fs7.env.homedir(), ".uipath", "telemetry", "pending");
10296
+ }
10297
+ async function writeTelemetrySpoolFile(payload) {
10298
+ const fs7 = getFileSystem();
10299
+ const dir = getTelemetrySpoolDir();
10300
+ await fs7.mkdir(dir);
10301
+ const name = `${Date.now()}-${process.pid}`;
10302
+ const finalPath = fs7.path.join(dir, `${name}${PENDING_SUFFIX}`);
10303
+ const tempPath = fs7.path.join(dir, `${name}${WRITE_TEMP_SUFFIX}`);
10304
+ await fs7.writeFile(tempPath, JSON.stringify(payload));
10305
+ await fs7.rename(tempPath, finalPath);
10306
+ return finalPath;
10307
+ }
10308
+ function isSpoolPayload(value) {
10309
+ return value !== null && typeof value === "object" && typeof value.endpointUrl === "string" && value.endpointUrl.length > 0 && Array.isArray(value.envelopes);
10310
+ }
10311
+ async function listSpoolEntries(suffix) {
10312
+ const fs7 = getFileSystem();
10313
+ const dir = getTelemetrySpoolDir();
10314
+ const [readdirError, names] = await catchError(fs7.readdir(dir));
10315
+ if (readdirError) {
10316
+ return { dir, names: [] };
10317
+ }
10318
+ return {
10319
+ dir,
10320
+ names: names.filter((n) => n.endsWith(suffix)).sort((a, b) => a.localeCompare(b))
10321
+ };
10322
+ }
10323
+ async function claimPendingSpoolFiles() {
10324
+ const fs7 = getFileSystem();
10325
+ const { dir, names } = await listSpoolEntries(PENDING_SUFFIX);
10326
+ const claimed = [];
10327
+ for (const name of names) {
10328
+ const pendingPath = fs7.path.join(dir, name);
10329
+ const claimedPath = `${pendingPath.slice(0, -PENDING_SUFFIX.length)}${CLAIMED_SUFFIX}`;
10330
+ const [claimError] = await catchError(fs7.rename(pendingPath, claimedPath));
10331
+ if (claimError) {
10332
+ continue;
10333
+ }
10334
+ const [readError, raw] = await catchError(fs7.readFile(claimedPath, "utf-8"));
10335
+ if (readError || raw === null) {
10336
+ logger.debug(`[TelemetrySpool] could not read ${name}; leaving it for a later run`);
10337
+ await releaseClaimedSpoolFile(claimedPath);
10338
+ continue;
10339
+ }
10340
+ const [parseError, parsed] = catchError(() => JSON.parse(raw));
10341
+ if (parseError || !isSpoolPayload(parsed)) {
10342
+ logger.debug(`[TelemetrySpool] dropping malformed file: ${name}`);
10343
+ await catchError(fs7.rm(claimedPath));
10344
+ continue;
10345
+ }
10346
+ claimed.push({ claimedPath, payload: parsed });
10347
+ }
10348
+ return claimed;
10349
+ }
10350
+ async function releaseClaimedSpoolFile(claimedPath) {
10351
+ const fs7 = getFileSystem();
10352
+ const pendingPath = `${claimedPath.slice(0, -CLAIMED_SUFFIX.length)}${PENDING_SUFFIX}`;
10353
+ await catchError(fs7.rename(claimedPath, pendingPath));
10354
+ }
10355
+ async function discardClaimedSpoolFile(claimedPath) {
10356
+ const fs7 = getFileSystem();
10357
+ await catchError(fs7.rm(claimedPath));
10358
+ }
10359
+ async function sweepTelemetrySpool() {
10360
+ const fs7 = getFileSystem();
10361
+ const { dir, names } = await listSpoolEntries("");
10362
+ const now = Date.now();
10363
+ const pending = [];
10364
+ for (const name of names) {
10365
+ const filePath = fs7.path.join(dir, name);
10366
+ const [statError, stats] = await catchError(fs7.stat(filePath));
10367
+ if (statError || !stats) {
10368
+ continue;
10369
+ }
10370
+ if (now - stats.mtimeMs > MAX_SPOOL_AGE_MS) {
10371
+ await catchError(fs7.rm(filePath));
10372
+ continue;
10373
+ }
10374
+ if (name.endsWith(PENDING_SUFFIX)) {
10375
+ pending.push({ path: filePath, mtimeMs: stats.mtimeMs });
10376
+ }
10377
+ }
10378
+ if (pending.length > MAX_SPOOL_FILES) {
10379
+ pending.sort((a, b) => a.mtimeMs - b.mtimeMs);
10380
+ const excess = pending.slice(0, pending.length - MAX_SPOOL_FILES);
10381
+ for (const file of excess) {
10382
+ await catchError(fs7.rm(file.path));
10383
+ }
10384
+ logger.debug(`[TelemetrySpool] deleted ${excess.length} oldest files over the ${MAX_SPOOL_FILES}-file cap`);
10385
+ }
10386
+ }
10387
+
10223
10388
  // src/telemetry/telemetry-init.ts
10224
10389
  var telemetryInstanceSlot = singleton("TelemetryService");
10225
10390
  var DEFAULT_AI_CONNECTION_STRING = atob("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj");
@@ -10313,6 +10478,56 @@ async function runWithTimeout(operation, timeoutMs) {
10313
10478
  clearTimeout(timer);
10314
10479
  }
10315
10480
  }
10481
+ async function runProviderShutdown(provider) {
10482
+ const [shutdownError, shutdownResult] = await catchError(runWithTimeout(provider.shutdown(), FLUSH_SHUTDOWN_TIMEOUT_MS));
10483
+ if (shutdownError) {
10484
+ logger.warn(`[Telemetry] shutdown failed (non-fatal): ${shutdownError.message}`);
10485
+ } else if (shutdownResult === "timeout") {
10486
+ logger.warn(`[Telemetry] shutdown timed out after ${FLUSH_SHUTDOWN_TIMEOUT_MS}ms`);
10487
+ }
10488
+ }
10489
+ function isSyncFlushForced() {
10490
+ const value = process.env.UIPATH_TELEMETRY_SYNC_FLUSH;
10491
+ return value === "1" || value === "true";
10492
+ }
10493
+ function isDrainableTelemetryProvider(provider) {
10494
+ return "drainPendingEnvelopes" in provider && typeof provider.drainPendingEnvelopes === "function";
10495
+ }
10496
+ function spawnTelemetrySidecar(entryPath) {
10497
+ const child = spawn(process.execPath, [entryPath, TELEMETRY_DRAIN_ARGV], {
10498
+ cwd: getFileSystem().env.tmpdir(),
10499
+ detached: true,
10500
+ stdio: "ignore",
10501
+ windowsHide: true
10502
+ });
10503
+ child.on("error", (error) => {
10504
+ logger.debug(`[Telemetry] sidecar spawn failed (spool kept for a later run): ${error.message}`);
10505
+ });
10506
+ child.unref();
10507
+ }
10508
+ async function trySidecarHandoff(provider) {
10509
+ const entryPath = getTelemetrySidecarEntry();
10510
+ if (entryPath === undefined || isSyncFlushForced() || !isDrainableTelemetryProvider(provider)) {
10511
+ return false;
10512
+ }
10513
+ const pending = provider.drainPendingEnvelopes();
10514
+ if (!pending) {
10515
+ return false;
10516
+ }
10517
+ if (pending.envelopes.length > 0) {
10518
+ const [spoolError] = await catchError(writeTelemetrySpoolFile(pending));
10519
+ if (spoolError) {
10520
+ logger.debug(`[Telemetry] spool write failed; dropping ${pending.envelopes.length} pending envelope(s): ${spoolError.message}`);
10521
+ } else {
10522
+ const [spawnError] = catchError(() => spawnTelemetrySidecar(entryPath));
10523
+ if (spawnError) {
10524
+ logger.debug(`[Telemetry] sidecar spawn failed; spool will be sent by a future run: ${spawnError.message}`);
10525
+ }
10526
+ }
10527
+ }
10528
+ await runProviderShutdown(provider);
10529
+ return true;
10530
+ }
10316
10531
  async function telemetryFlushAndShutdown() {
10317
10532
  if (!isFlushableTelemetryProvider(telemetryProviderInstance)) {
10318
10533
  return;
@@ -10320,22 +10535,27 @@ async function telemetryFlushAndShutdown() {
10320
10535
  if (!telemetryFlushShutdownPromise) {
10321
10536
  const provider = telemetryProviderInstance;
10322
10537
  telemetryFlushShutdownPromise = (async () => {
10538
+ if (await trySidecarHandoff(provider)) {
10539
+ return;
10540
+ }
10323
10541
  const [flushError, flushResult] = await catchError(runWithTimeout(provider.flush(), FLUSH_SHUTDOWN_TIMEOUT_MS));
10324
10542
  if (flushError) {
10325
10543
  logger.warn(`[Telemetry] flush failed (non-fatal): ${flushError.message}`);
10326
10544
  } else if (flushResult === "timeout") {
10327
10545
  logger.warn(`[Telemetry] flush timed out after ${FLUSH_SHUTDOWN_TIMEOUT_MS}ms`);
10328
10546
  }
10329
- const [shutdownError, shutdownResult] = await catchError(runWithTimeout(provider.shutdown(), FLUSH_SHUTDOWN_TIMEOUT_MS));
10330
- if (shutdownError) {
10331
- logger.warn(`[Telemetry] shutdown failed (non-fatal): ${shutdownError.message}`);
10332
- } else if (shutdownResult === "timeout") {
10333
- logger.warn(`[Telemetry] shutdown timed out after ${FLUSH_SHUTDOWN_TIMEOUT_MS}ms`);
10334
- }
10547
+ await runProviderShutdown(provider);
10335
10548
  })();
10336
10549
  }
10337
10550
  await telemetryFlushShutdownPromise;
10338
10551
  }
10552
+ async function telemetryShutdownWithoutFlush() {
10553
+ if (!isFlushableTelemetryProvider(telemetryProviderInstance)) {
10554
+ return;
10555
+ }
10556
+ telemetryFlushShutdownPromise ??= runProviderShutdown(telemetryProviderInstance);
10557
+ await telemetryFlushShutdownPromise;
10558
+ }
10339
10559
 
10340
10560
  // src/formatter.ts
10341
10561
  var CLI_ERROR_CODES = [
@@ -10612,21 +10832,43 @@ function printTable(data, logFn, externalLogValue) {
10612
10832
  logFn(`Log: ${externalLogValue}`);
10613
10833
  }
10614
10834
  }
10835
+ function isPlainObjectArray(value) {
10836
+ return Array.isArray(value) && value.length > 0 && value.every(isPlainRecord);
10837
+ }
10838
+ function isNonEmptyPlainObject(value) {
10839
+ return isPlainRecord(value) && Object.keys(value).length > 0;
10840
+ }
10841
+ var NESTED_INDENT = " ";
10615
10842
  function printVerticalTable(data, logFn = console.log, externalLogValue) {
10616
10843
  const keys = Object.keys(data).filter((key) => !["code", "log"].includes(key.toLowerCase()));
10617
10844
  if (keys.length === 0)
10618
10845
  return;
10619
- const maxKeyWidth = Math.max(...keys.map((key) => key.length));
10846
+ const isBlockValue = (value) => isPlainObjectArray(value) || isNonEmptyPlainObject(value);
10847
+ const scalarKeys = keys.filter((key) => !isBlockValue(data[key]));
10848
+ const maxKeyWidth = scalarKeys.length > 0 ? Math.max(...scalarKeys.map((key) => key.length)) : 0;
10849
+ const termWidth = process.stdout.columns || 120;
10850
+ const nestedWidth = Math.max(termWidth - NESTED_INDENT.length, 1);
10620
10851
  keys.forEach((key) => {
10852
+ const value = data[key];
10853
+ if (isPlainObjectArray(value)) {
10854
+ logFn(`${key}:`);
10855
+ printResizableTable(value, (line) => logFn(`${NESTED_INDENT}${line}`), undefined, nestedWidth);
10856
+ return;
10857
+ }
10858
+ if (isNonEmptyPlainObject(value)) {
10859
+ logFn(`${key}:`);
10860
+ printVerticalTable(value, (line) => logFn(`${NESTED_INDENT}${line}`));
10861
+ return;
10862
+ }
10621
10863
  const keyCol = key.padEnd(maxKeyWidth);
10622
- logFn(`${keyCol} | ${cellToString(data[key])}`);
10864
+ logFn(`${keyCol} | ${cellToString(value)}`);
10623
10865
  });
10624
10866
  if (externalLogValue) {
10625
10867
  logFn("");
10626
10868
  logFn(`Log: ${externalLogValue}`);
10627
10869
  }
10628
10870
  }
10629
- function printResizableTable(data, logFn = console.log, externalLogValue) {
10871
+ function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth) {
10630
10872
  if (data.length === 0)
10631
10873
  return;
10632
10874
  const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
@@ -10639,7 +10881,7 @@ function printResizableTable(data, logFn = console.log, externalLogValue) {
10639
10881
  const naturalWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
10640
10882
  const separatorTotal = (keys.length - 1) * 3;
10641
10883
  const totalWidth = naturalWidths.reduce((a, b) => a + b, 0) + separatorTotal;
10642
- const termWidth = process.stdout.columns || 120;
10884
+ const termWidth = availableWidth ?? (process.stdout.columns || 120);
10643
10885
  if (totalWidth <= termWidth) {
10644
10886
  printTable(data, logFn, externalLogValue);
10645
10887
  return;
@@ -10729,6 +10971,19 @@ class FilterEvaluationError extends Error {
10729
10971
  this.instructions = `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
10730
10972
  }
10731
10973
  }
10974
+
10975
+ class FilterImplicitLimitError extends Error {
10976
+ __brand = "FilterImplicitLimitError";
10977
+ errorCode = "invalid_argument";
10978
+ instructions;
10979
+ retry = "RetryWillNotFix";
10980
+ result = RESULTS.ValidationError;
10981
+ constructor(defaultLimit) {
10982
+ super(`--output-filter requires an explicit --limit: this command defaults to --limit ${defaultLimit}, ` + `so the filter would silently apply to only the first ${defaultLimit} records.`);
10983
+ this.name = "FilterImplicitLimitError";
10984
+ this.instructions = "Pass --limit <n> to choose how many records the filter applies to. " + "To filter over all records, pass the command's maximum accepted --limit (see the option's description in --help).";
10985
+ }
10986
+ }
10732
10987
  function applyFilter(data, filter) {
10733
10988
  let result;
10734
10989
  try {
@@ -10982,7 +11237,7 @@ var COMMAND_ATTRIBUTION = commandAttribution([
10982
11237
  ["agents", "build", ["uip.codedagent", "uip.agent"]],
10983
11238
  ["agenthub", "build", ["uip.agenthub"]],
10984
11239
  ["coded-apps", "build", ["uip.codedapp"]],
10985
- ["functions", "build", ["uip.functions"]],
11240
+ ["functions", "build", ["uip.function", "uip.functions"]],
10986
11241
  ["solution", "build", ["uip.solution"]],
10987
11242
  ["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
10988
11243
  ["llm-observability", "troubleshoot", ["uip.traces"]],
@@ -11149,6 +11404,16 @@ function commandHelpHint(commandPath) {
11149
11404
  function isPromptCancellation(error) {
11150
11405
  return error instanceof Error && error.name === "ExitPromptError";
11151
11406
  }
11407
+ function implicitLimitViolation(cmd) {
11408
+ if (getOutputFilter() === undefined) {
11409
+ return;
11410
+ }
11411
+ const hasLimit = cmd.options.some((o) => o.attributeName() === "limit");
11412
+ if (!hasLimit || cmd.getOptionValueSource("limit") !== "default") {
11413
+ return;
11414
+ }
11415
+ return new FilterImplicitLimitError(String(cmd.opts().limit));
11416
+ }
11152
11417
  function exitCodeFromProcess(fallback) {
11153
11418
  return typeof process.exitCode === "number" ? process.exitCode : fallback;
11154
11419
  }
@@ -11162,7 +11427,13 @@ Command.prototype.trackedAction = function(context, fn, properties) {
11162
11427
  let errorMessage;
11163
11428
  let fallbackExitCode = EXIT_CODES.Success;
11164
11429
  clearRecordedCommandFailureTelemetry();
11165
- const [error] = await catchError(telemetry.runWithContext(requestContext, () => fn(...args)));
11430
+ const [error] = await catchError(telemetry.runWithContext(requestContext, () => {
11431
+ const violation = implicitLimitViolation(command);
11432
+ if (violation) {
11433
+ return Promise.reject(violation);
11434
+ }
11435
+ return fn(...args);
11436
+ }));
11166
11437
  if (error) {
11167
11438
  errorMessage = error instanceof Error ? error.message : String(error);
11168
11439
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
@@ -11412,6 +11683,40 @@ var GUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
11412
11683
  function isGuid(value) {
11413
11684
  return GUID_REGEX.test(value);
11414
11685
  }
11686
+ // src/host-global-options.ts
11687
+ var HOST_GLOBAL_OPTIONS_WITH_VALUE = [
11688
+ "--output",
11689
+ "--output-filter",
11690
+ "--log-level",
11691
+ "--log-file",
11692
+ "--profile"
11693
+ ];
11694
+ var HOST_GLOBAL_FLAGS = [
11695
+ "--json",
11696
+ "--interactive",
11697
+ "--no-interactive"
11698
+ ];
11699
+ var VALUE_OPTIONS = new Set(HOST_GLOBAL_OPTIONS_WITH_VALUE);
11700
+ var BOOLEAN_FLAGS = new Set(HOST_GLOBAL_FLAGS);
11701
+ function stripHostGlobalOptions(args) {
11702
+ const cleaned = [];
11703
+ for (let i = 0;i < args.length; i++) {
11704
+ const arg = args[i] ?? "";
11705
+ if (BOOLEAN_FLAGS.has(arg)) {
11706
+ continue;
11707
+ }
11708
+ if (VALUE_OPTIONS.has(arg)) {
11709
+ i++;
11710
+ continue;
11711
+ }
11712
+ const equalsIndex = arg.indexOf("=");
11713
+ if (equalsIndex > 0 && VALUE_OPTIONS.has(arg.slice(0, equalsIndex))) {
11714
+ continue;
11715
+ }
11716
+ cleaned.push(arg);
11717
+ }
11718
+ return cleaned;
11719
+ }
11415
11720
  // src/interactivity-context.ts
11416
11721
  var modeSlot = singleton("InteractivityMode");
11417
11722
  var interactiveFlagSlot = singleton("InteractiveFlag");
@@ -11575,6 +11880,22 @@ function mapPackageMetadataOptions(opts) {
11575
11880
  }
11576
11881
  return fields;
11577
11882
  }
11883
+ // src/packager-tool-import.ts
11884
+ var REGISTER_EXPORT = "registerPackagerFactories";
11885
+ async function importPackagerTool(specifier) {
11886
+ const [importError, mod2] = await catchError(import(specifier));
11887
+ if (importError)
11888
+ return importError;
11889
+ const register = mod2?.[REGISTER_EXPORT];
11890
+ if (typeof register !== "function") {
11891
+ logger.debug(`'${specifier}' has no '${REGISTER_EXPORT}' export — treating it as a ` + "legacy entry point that registered its factories at import.");
11892
+ return;
11893
+ }
11894
+ const [registerError] = catchError(() => {
11895
+ register();
11896
+ });
11897
+ return registerError;
11898
+ }
11578
11899
  // src/polling/abort-controller.ts
11579
11900
  var created = false;
11580
11901
  function createPollAbortController() {
@@ -12061,9 +12382,15 @@ var FAILURE_STATUSES = new Set([
12061
12382
  "stopped"
12062
12383
  ]);
12063
12384
  function isTerminalStatus(status) {
12385
+ if (typeof status !== "string") {
12386
+ return false;
12387
+ }
12064
12388
  return TERMINAL_STATUSES.has(status.toLowerCase());
12065
12389
  }
12066
12390
  function isFailureStatus(status) {
12391
+ if (typeof status !== "string") {
12392
+ return false;
12393
+ }
12067
12394
  return FAILURE_STATUSES.has(status.toLowerCase());
12068
12395
  }
12069
12396
  function isSuccessStatus(status) {
@@ -12205,6 +12532,68 @@ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
12205
12532
  function installSdkCodingAgentHeader(BaseApiClass) {
12206
12533
  installRequestHeaderForwarding(BaseApiClass, codingAgentPatchKey(), (headers) => addSdkCodingAgentHeader(headers));
12207
12534
  }
12535
+ // src/tool-module-import.ts
12536
+ async function importToolModule(specifier) {
12537
+ return await import(specifier);
12538
+ }
12539
+
12540
+ // src/tool-provider.ts
12541
+ var factorySlot = singleton("PackagerFactoryProvider");
12542
+ function setPackagerFactoryProvider(provider) {
12543
+ factorySlot.set(provider);
12544
+ }
12545
+ var moduleSlot = singleton("ToolModuleProvider");
12546
+ function setToolModuleProvider(provider) {
12547
+ moduleSlot.set(provider);
12548
+ }
12549
+ async function ensureToolModule(verb, packageName, moduleName) {
12550
+ if (!/^[a-z0-9-]+$/.test(moduleName)) {
12551
+ throw new Error(`Invalid tool module name '${moduleName}'.`);
12552
+ }
12553
+ const provider = moduleSlot.get();
12554
+ if (provider) {
12555
+ return provider(verb, moduleName);
12556
+ }
12557
+ const specifier = `${packageName}/${moduleName}`;
12558
+ const [importError, mod2] = await catchError(importToolModule(specifier));
12559
+ if (importError) {
12560
+ logger.debug(`No tool-module provider registered; import of '${specifier}' failed: ${importError.message}`);
12561
+ throw new Error(`This command needs '${packageName}'. Install it.`, {
12562
+ cause: importError
12563
+ });
12564
+ }
12565
+ return mod2;
12566
+ }
12567
+ async function ensurePackagerFactory(verb, packageName) {
12568
+ const provider = factorySlot.get();
12569
+ if (provider) {
12570
+ await provider(verb);
12571
+ return;
12572
+ }
12573
+ const importError = packageName ? await loadPackagerTool(`${packageName}/packager-tool`) : undefined;
12574
+ if (packageName && !importError)
12575
+ return;
12576
+ throw new Error(packageName ? `Packing this project type needs '${packageName}'. Install it.` : `Packing this project type needs the packager factory for '${verb}', and no package provides it.`, { cause: importError });
12577
+ }
12578
+ async function loadPackagerTool(specifier) {
12579
+ const error = await importPackagerTool(specifier);
12580
+ if (error) {
12581
+ logger.debug(`No packager factory provider registered; import of '${specifier}' failed: ${error.message}`);
12582
+ return error;
12583
+ }
12584
+ logger.debug(`No packager factory provider registered; loaded '${specifier}' directly.`);
12585
+ return;
12586
+ }
12587
+
12588
+ // src/solution-project-artifacts.ts
12589
+ async function ensureProjectArtifacts(args) {
12590
+ const [error, mod2] = await catchError(ensureToolModule("solution", "@uipath/solution-tool", "init"));
12591
+ if (error) {
12592
+ logger.warn(`Solution artifact-resource generation skipped for project "${args.projectName}": ${error.message}. ` + "Run 'uip solution project add' to finish setup.");
12593
+ return { Created: false, Error: error.message };
12594
+ }
12595
+ return mod2.addProjectArtifactsToSolutionAsync(args);
12596
+ }
12208
12597
  // src/stdin.ts
12209
12598
  async function readStdin() {
12210
12599
  if (process.stdin.isTTY) {
@@ -12304,30 +12693,24 @@ function trackShipSucceeded(payload) {
12304
12693
  telemetry.trackEvent(CommonTelemetryEvents.ShipSucceeded, redactProperties({ ...payload }));
12305
12694
  return true;
12306
12695
  }
12307
- // src/tool-provider.ts
12308
- var factorySlot = singleton("PackagerFactoryProvider");
12309
- function setPackagerFactoryProvider(provider) {
12310
- factorySlot.set(provider);
12311
- }
12312
- async function ensurePackagerFactory(verb) {
12313
- const provider = factorySlot.get();
12314
- if (!provider) {
12315
- throw new Error(`Packager factory for '${verb}' is required but no factory provider is registered. ` + `Run 'uip tools install ${verb}' manually.`);
12316
- }
12317
- await provider(verb);
12318
- }
12319
12696
  export {
12697
+ writeTelemetrySpoolFile,
12320
12698
  withCompleter,
12321
12699
  wasInteractiveFlagPassed,
12322
12700
  warnDeprecatedTenantOption,
12323
12701
  warnDeprecatedOptionAlias,
12324
12702
  validateOutputFilter,
12325
12703
  trackShipSucceeded,
12704
+ telemetryShutdownWithoutFlush,
12326
12705
  telemetryInit,
12327
12706
  telemetryFlushAndShutdown,
12328
12707
  telemetry,
12329
12708
  takeRecordedCommandFailureTelemetry,
12709
+ sweepTelemetrySpool,
12710
+ stripHostGlobalOptions,
12330
12711
  singleton,
12712
+ setToolModuleProvider,
12713
+ setTelemetrySidecarEntry,
12331
12714
  setSdkUserAgentHostToken,
12332
12715
  setProcessContextPollSignal,
12333
12716
  setPreviewBuild,
@@ -12346,12 +12729,12 @@ export {
12346
12729
  runValidators,
12347
12730
  runChecks,
12348
12731
  restoreConsole,
12349
- resolveTelemetrySessionId,
12350
12732
  resolveEnvReference,
12351
12733
  resolveDeprecatedOptionAlias,
12352
12734
  resolveAttachmentInputs,
12353
12735
  resetLoggerInstance,
12354
12736
  requireConfirmation,
12737
+ releaseClaimedSpoolFile,
12355
12738
  registerPackageMetadataOptions,
12356
12739
  redactValue,
12357
12740
  redactProperty,
@@ -12391,6 +12774,9 @@ export {
12391
12774
  installSdkCodingAgentHeader,
12392
12775
  installConsoleGuard,
12393
12776
  hashContent,
12777
+ getTelemetrySpoolDir,
12778
+ getTelemetrySidecarEntry,
12779
+ getTelemetrySessionSource,
12394
12780
  getTelemetrySessionId,
12395
12781
  getSdkUserAgentToken,
12396
12782
  getRecordedCommandFailureTelemetry,
@@ -12414,7 +12800,10 @@ export {
12414
12800
  extractErrorDetails,
12415
12801
  extractCommandHelp,
12416
12802
  escapeNonAscii,
12803
+ ensureToolModule,
12804
+ ensureProjectArtifacts,
12417
12805
  ensurePackagerFactory,
12806
+ discardClaimedSpoolFile,
12418
12807
  detectExecutionContext,
12419
12808
  detectAgentVersion,
12420
12809
  detectAgent,
@@ -12427,6 +12816,7 @@ export {
12427
12816
  configureLogger,
12428
12817
  collectCommands,
12429
12818
  clearRecordedCommandFailureTelemetry,
12819
+ claimPendingSpoolFiles,
12430
12820
  catchError,
12431
12821
  canPrompt,
12432
12822
  buildSkillEventTelemetryAttribution,
@@ -12444,22 +12834,29 @@ export {
12444
12834
  TelemetryService,
12445
12835
  TELEMETRY_TRACEPARENT_ENV,
12446
12836
  TELEMETRY_SPAN_ID_PROPERTY,
12447
- TELEMETRY_SESSION_ID_PROPERTY,
12837
+ TELEMETRY_SESSION_SOURCE_PROPERTY,
12448
12838
  TELEMETRY_SESSION_ID_ENV,
12449
12839
  TELEMETRY_PARENT_ID_PROPERTY,
12450
12840
  TELEMETRY_OPERATION_ID_PROPERTY,
12841
+ TELEMETRY_DRAIN_ARGV,
12451
12842
  TELEMETRY_COMMAND_ARG_PREFIX,
12452
12843
  SuccessOutput,
12453
12844
  ScreenLogger,
12454
12845
  RETRY_HINTS,
12455
12846
  RESULTS,
12847
+ REGISTER_EXPORT,
12456
12848
  PollOutcome,
12457
12849
  Pagination,
12458
12850
  POLL_DEFAULTS,
12459
12851
  OutputFormatter,
12460
12852
  NodeContextStorage,
12461
12853
  MIN_INTERVAL_MS,
12854
+ MAX_SPOOL_FILES,
12855
+ MAX_SPOOL_AGE_MS,
12462
12856
  LogLevel,
12857
+ HOST_GLOBAL_OPTIONS_WITH_VALUE,
12858
+ HOST_GLOBAL_FLAGS,
12859
+ FilterImplicitLimitError,
12463
12860
  FilterEvaluationError,
12464
12861
  FailureOutput,
12465
12862
  ErrorDecision,
@@ -12483,4 +12880,4 @@ export {
12483
12880
  ATTACHMENT_INSTRUCTIONS
12484
12881
  };
12485
12882
 
12486
- //# debugId=0104AD30EA6F6A7264756E2164756E21
12883
+ //# debugId=C8D78C124860EA5264756E2164756E21