@uipath/common 1.206.0-preview.303 → 1.207.0-preview.305

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
@@ -7409,12 +7409,26 @@ class NodeFileSystem {
7409
7409
  throw error;
7410
7410
  }
7411
7411
  }
7412
- async writeFile(filePath, data) {
7412
+ async writeFile(filePath, data, options) {
7413
7413
  const dir = path2.dirname(filePath);
7414
7414
  if (dir) {
7415
7415
  await fs6.mkdir(dir, { recursive: true });
7416
7416
  }
7417
- await fs6.writeFile(filePath, data);
7417
+ if (options?.mode === undefined || process.platform === "win32") {
7418
+ if (options?.exclusive) {
7419
+ await fs6.writeFile(filePath, data, { flag: "wx" });
7420
+ } else {
7421
+ await fs6.writeFile(filePath, data);
7422
+ }
7423
+ return;
7424
+ }
7425
+ const handle = await fs6.open(filePath, options.exclusive ? "wx" : "w", options.mode);
7426
+ try {
7427
+ await handle.chmod(options.mode);
7428
+ await handle.writeFile(data);
7429
+ } finally {
7430
+ await handle.close();
7431
+ }
7418
7432
  }
7419
7433
  async appendFile(filePath, data) {
7420
7434
  const dir = path2.dirname(filePath);
@@ -7449,7 +7463,8 @@ class NodeFileSystem {
7449
7463
  isDirectory: () => stats.isDirectory(),
7450
7464
  size: stats.size,
7451
7465
  mtimeMs: stats.mtimeMs,
7452
- ctimeMs: stats.ctimeMs
7466
+ ctimeMs: stats.ctimeMs,
7467
+ mode: stats.mode
7453
7468
  };
7454
7469
  } catch (error) {
7455
7470
  if (this.isEnoent(error))
@@ -7460,8 +7475,13 @@ class NodeFileSystem {
7460
7475
  async exists(filePath) {
7461
7476
  return existsSync(filePath);
7462
7477
  }
7463
- async mkdir(dirPath) {
7464
- await fs6.mkdir(dirPath, { recursive: true });
7478
+ async mkdir(dirPath, options) {
7479
+ await fs6.mkdir(dirPath, { recursive: true, mode: options?.mode });
7480
+ }
7481
+ async chmod(targetPath, mode) {
7482
+ if (process.platform === "win32")
7483
+ return;
7484
+ await fs6.chmod(targetPath, mode);
7465
7485
  }
7466
7486
  async acquireLock(lockPath) {
7467
7487
  const canonicalPath = await this.canonicalizeLockTarget(lockPath);
@@ -7611,7 +7631,7 @@ class NodeFileSystem {
7611
7631
  async getTempDir() {
7612
7632
  return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-"));
7613
7633
  }
7614
- async copyDirectory(sourcePath, destPath) {
7634
+ async copyDirectory(sourcePath, destPath, options) {
7615
7635
  const sourceStats = await this.stat(sourcePath);
7616
7636
  if (!sourceStats) {
7617
7637
  throw new Error(`Source directory does not exist: ${sourcePath}`);
@@ -7628,7 +7648,9 @@ class NodeFileSystem {
7628
7648
  if (!entryStats)
7629
7649
  continue;
7630
7650
  if (entryStats.isDirectory()) {
7631
- await this.copyDirectory(srcEntry, destEntry);
7651
+ if (options?.skipDirectoryNames?.includes(entry))
7652
+ continue;
7653
+ await this.copyDirectory(srcEntry, destEntry, options);
7632
7654
  } else if (entryStats.isFile()) {
7633
7655
  const content = await this.readFile(srcEntry);
7634
7656
  if (content !== null) {
@@ -7692,13 +7714,15 @@ var ProjectDimensions = {
7692
7714
  SolutionKey: "SolutionKey",
7693
7715
  SolutionProjectKey: "SolutionProjectKey",
7694
7716
  SolutionIdentityStatus: "SolutionIdentityStatus",
7695
- PreviousSolutionKey: "PreviousSolutionKey"
7717
+ PreviousSolutionKey: "PreviousSolutionKey",
7718
+ PreviousProjectKey: "PreviousProjectKey"
7696
7719
  };
7697
7720
  var GUID_KEY_DIMENSIONS = new Set([
7698
7721
  ProjectDimensions.ProjectKey,
7699
7722
  ProjectDimensions.SolutionKey,
7700
7723
  ProjectDimensions.SolutionProjectKey,
7701
- ProjectDimensions.PreviousSolutionKey
7724
+ ProjectDimensions.PreviousSolutionKey,
7725
+ ProjectDimensions.PreviousProjectKey
7702
7726
  ]);
7703
7727
  var ShipDimensions = {
7704
7728
  ShipKind: "ShipKind",
@@ -7878,9 +7902,7 @@ async function withinProjectIdentityBudget(work, onTimeout) {
7878
7902
  }
7879
7903
  }
7880
7904
 
7881
- // src/telemetry/pseudonymize.ts
7882
- var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
7883
- var PSEUDONYM_HEX_LENGTH = 32;
7905
+ // src/sha256.ts
7884
7906
  var SHA256_K = new Uint32Array([
7885
7907
  1116352408,
7886
7908
  1899447441,
@@ -7960,7 +7982,7 @@ var SHA256_INITIAL_STATE = new Uint32Array([
7960
7982
  function rotr(value, bits) {
7961
7983
  return (value >>> bits | value << 32 - bits) >>> 0;
7962
7984
  }
7963
- function sha256Hex(input) {
7985
+ function sha256Words(input) {
7964
7986
  const bytes = new TextEncoder().encode(input);
7965
7987
  const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
7966
7988
  const buffer = new Uint8Array(paddedLength);
@@ -8016,12 +8038,27 @@ function sha256Hex(input) {
8016
8038
  state[6] = state[6] + g >>> 0;
8017
8039
  state[7] = state[7] + h >>> 0;
8018
8040
  }
8041
+ return state;
8042
+ }
8043
+ function sha256Hex(input) {
8019
8044
  let hex = "";
8020
- for (const word of state) {
8045
+ for (const word of sha256Words(input)) {
8021
8046
  hex += word.toString(16).padStart(8, "0");
8022
8047
  }
8023
8048
  return hex;
8024
8049
  }
8050
+ function sha256Base64Url(input) {
8051
+ const bytes = new Uint8Array(32);
8052
+ const view = new DataView(bytes.buffer);
8053
+ for (const [i, word] of sha256Words(input).entries()) {
8054
+ view.setUint32(i * 4, word);
8055
+ }
8056
+ return btoa(String.fromCharCode(...bytes)).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
8057
+ }
8058
+
8059
+ // src/telemetry/pseudonymize.ts
8060
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
8061
+ var PSEUDONYM_HEX_LENGTH = 32;
8025
8062
  function resolveSha256Hex() {
8026
8063
  try {
8027
8064
  const nodeCrypto = __require("node:crypto");
@@ -8420,13 +8457,25 @@ function settlePromiseLike(thenable) {
8420
8457
  return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
8421
8458
  }
8422
8459
 
8460
+ // src/result-types.ts
8461
+ var RESULTS = {
8462
+ Success: "Success",
8463
+ Failure: "Failure",
8464
+ ConfigError: "ConfigError",
8465
+ AuthenticationError: "AuthenticationError",
8466
+ ValidationError: "ValidationError",
8467
+ TimeoutError: "TimeoutError"
8468
+ };
8469
+
8423
8470
  // src/error-codes.ts
8424
8471
  var CLI_ERROR_CODES = [
8425
8472
  "invalid_argument",
8473
+ "confirmation_required",
8426
8474
  "authentication_required",
8427
8475
  "permission_denied",
8428
8476
  "local_permission_denied",
8429
8477
  "not_found",
8478
+ "not_enabled",
8430
8479
  "rate_limited",
8431
8480
  "network_error",
8432
8481
  "timeout",
@@ -8465,6 +8514,12 @@ function carriedRetry(error) {
8465
8514
  const retry = error.retry;
8466
8515
  return isRetryHint(retry) ? retry : undefined;
8467
8516
  }
8517
+ function carriedResult(error) {
8518
+ if (!error || typeof error !== "object")
8519
+ return;
8520
+ const result = error.result;
8521
+ return typeof result === "string" && result !== RESULTS.Success && Object.values(RESULTS).includes(result) ? result : undefined;
8522
+ }
8468
8523
  function defaultRetryForErrorCode(errorCode) {
8469
8524
  switch (errorCode) {
8470
8525
  case "network_error":
@@ -8903,6 +8958,8 @@ async function extractErrorDetails(error, options) {
8903
8958
  }
8904
8959
  if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
8905
8960
  context.errorCode = parsedBody.errorCode;
8961
+ } else if (typeof parsedBody?.errorCode === "number") {
8962
+ context.errorCode = String(parsedBody.errorCode);
8906
8963
  } else if (parsedBody?.code && typeof parsedBody.code === "string") {
8907
8964
  context.errorCode = parsedBody.code;
8908
8965
  }
@@ -9133,20 +9190,10 @@ function instructionsFor(ctx, err) {
9133
9190
  }
9134
9191
  }
9135
9192
 
9136
- // src/result-types.ts
9137
- var RESULTS = {
9138
- Success: "Success",
9139
- Failure: "Failure",
9140
- ConfigError: "ConfigError",
9141
- AuthenticationError: "AuthenticationError",
9142
- ValidationError: "ValidationError",
9143
- TimeoutError: "TimeoutError"
9144
- };
9145
-
9146
9193
  // src/classified-failure.ts
9147
9194
  var MAX_QUOTED_BODY_CHARS = 200;
9148
- async function classifiedFailure(message, error) {
9149
- const details = await extractErrorDetails(error);
9195
+ async function classifiedFailure(message, error, options) {
9196
+ const details = await extractErrorDetails(error, options);
9150
9197
  return {
9151
9198
  Result: details.result,
9152
9199
  ErrorCode: details.errorCode,
@@ -9830,7 +9877,10 @@ var AUTH_ERROR_CODES = new Set([
9830
9877
  var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
9831
9878
  "local_permission_denied"
9832
9879
  ]);
9833
- var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
9880
+ var VALIDATION_ERROR_CODES = new Set([
9881
+ "invalid_argument",
9882
+ "confirmation_required"
9883
+ ]);
9834
9884
  var NETWORK_HTTP_ERROR_CODES = new Set([
9835
9885
  "network_error",
9836
9886
  "rate_limited",
@@ -10062,6 +10112,247 @@ var CommonTelemetryEvents = {
10062
10112
  // src/telemetry/telemetry-init.ts
10063
10113
  import { spawn } from "node:child_process";
10064
10114
 
10115
+ // src/telemetry/appinsights-span-fields.ts
10116
+ function toOperationUrn(name) {
10117
+ if (URL.canParse(name))
10118
+ return name;
10119
+ const sanitized = encodeURIComponent(name).replace(/%2F/g, "/");
10120
+ return `urn:uip:${sanitized}`;
10121
+ }
10122
+ function spanStart(duration) {
10123
+ return new Date(Date.now() - duration);
10124
+ }
10125
+
10126
+ // src/telemetry/global-telemetry-properties.ts
10127
+ var telemetryPropsSlot = singleton("TelemetryDefaultProps");
10128
+ function setGlobalTelemetryProperties(properties) {
10129
+ const existing = getGlobalTelemetryProperties();
10130
+ telemetryPropsSlot.set({ ...existing, ...properties });
10131
+ }
10132
+ function getGlobalTelemetryProperties() {
10133
+ return telemetryPropsSlot.get();
10134
+ }
10135
+
10136
+ // src/telemetry/trace-context.ts
10137
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
10138
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
10139
+ function getProcessEnv() {
10140
+ return globalThis.process?.env;
10141
+ }
10142
+ function parseInboundTraceparent(value) {
10143
+ if (!value) {
10144
+ return;
10145
+ }
10146
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
10147
+ if (!match) {
10148
+ return;
10149
+ }
10150
+ const [, traceId, parentSpanId] = match;
10151
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
10152
+ return;
10153
+ }
10154
+ return { traceId, parentSpanId };
10155
+ }
10156
+ function getInboundTraceContext() {
10157
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
10158
+ }
10159
+
10160
+ // src/telemetry/session-id.ts
10161
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
10162
+ var SESSION_ID_MAX_LENGTH = 64;
10163
+ var RANDOM_SESSION_ID_LENGTH = 32;
10164
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
10165
+ var CONTROL_CHARACTERS = /\p{Cc}/gu;
10166
+ var INHERITED_SESSION_SOURCES = [
10167
+ { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
10168
+ { envVar: "CODEX_THREAD_ID", source: "codex" },
10169
+ { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
10170
+ { envVar: "TERM_SESSION_ID", source: "terminal" },
10171
+ { envVar: "WT_SESSION", source: "terminal" }
10172
+ ];
10173
+ var telemetrySessionSlot = singleton("TelemetrySession");
10174
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
10175
+ function getProcessEnv2() {
10176
+ return globalThis.process?.env;
10177
+ }
10178
+ function normalizeSessionId(value) {
10179
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
10180
+ return;
10181
+ }
10182
+ const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
10183
+ return cleaned || undefined;
10184
+ }
10185
+ function getConfiguredTelemetrySessionId() {
10186
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
10187
+ }
10188
+ function getInheritedSession(env) {
10189
+ for (const candidate of INHERITED_SESSION_SOURCES) {
10190
+ const handle = normalizeSessionId(env[candidate.envVar]);
10191
+ if (handle) {
10192
+ return { id: handle, source: candidate.source };
10193
+ }
10194
+ }
10195
+ return;
10196
+ }
10197
+ function generateRandomSession() {
10198
+ const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
10199
+ crypto.getRandomValues(bytes);
10200
+ let hex = "";
10201
+ for (const byte of bytes) {
10202
+ hex += byte.toString(16).padStart(2, "0");
10203
+ }
10204
+ return { id: hex, source: "random" };
10205
+ }
10206
+ function resolveTelemetrySession() {
10207
+ const existing = telemetrySessionSlot.get();
10208
+ if (existing) {
10209
+ return existing;
10210
+ }
10211
+ const declaredHandle = getConfiguredTelemetrySessionId();
10212
+ const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
10213
+ telemetrySessionSlot.set(resolved);
10214
+ return resolved;
10215
+ }
10216
+ function getTelemetrySessionId() {
10217
+ return resolveTelemetrySession().id;
10218
+ }
10219
+ function getTelemetrySessionSource() {
10220
+ return resolveTelemetrySession().source;
10221
+ }
10222
+ function getTelemetryOperationId() {
10223
+ const existing = telemetryOperationIdSlot.get();
10224
+ if (existing) {
10225
+ return existing;
10226
+ }
10227
+ const inboundTraceId = getInboundTraceContext()?.traceId;
10228
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
10229
+ telemetryOperationIdSlot.set(generated);
10230
+ return generated;
10231
+ }
10232
+ function resetTelemetryInvocationIds() {
10233
+ telemetrySessionSlot.clear();
10234
+ telemetryOperationIdSlot.clear();
10235
+ }
10236
+
10237
+ // src/telemetry/browser-appinsights-telemetry-provider.ts
10238
+ class BrowserAppInsightsTelemetryProvider {
10239
+ target;
10240
+ pending = [];
10241
+ applicationVersion;
10242
+ constructor(target) {
10243
+ this.target = target;
10244
+ }
10245
+ setApplicationVersion(version) {
10246
+ this.applicationVersion = version;
10247
+ }
10248
+ getSessionId() {
10249
+ return getTelemetrySessionId();
10250
+ }
10251
+ async trackEvent(event) {
10252
+ this.enqueue("Event", "EventData", event, new Date, {
10253
+ name: event.name
10254
+ });
10255
+ }
10256
+ async trackException(exception) {
10257
+ const { error } = exception;
10258
+ this.enqueue("Exception", "ExceptionData", exception, new Date, {
10259
+ exceptions: [
10260
+ {
10261
+ typeName: error.name,
10262
+ message: error.message,
10263
+ hasFullStack: error.stack !== undefined,
10264
+ stack: error.stack
10265
+ }
10266
+ ]
10267
+ });
10268
+ }
10269
+ async trackRequest(span) {
10270
+ const { name, durationMs, success, startedAt, id } = span;
10271
+ this.enqueue("Request", "RequestData", span, startedAt ?? spanStart(durationMs), {
10272
+ id: id ?? crypto.randomUUID().replaceAll("-", "").slice(0, 16),
10273
+ name,
10274
+ url: toOperationUrn(name),
10275
+ duration: formatDuration(durationMs),
10276
+ success,
10277
+ responseCode: success ? "200" : "500"
10278
+ });
10279
+ }
10280
+ async trackDependency(span) {
10281
+ const { name, type, durationMs, success, startedAt, id, resultCode } = span;
10282
+ this.enqueue("RemoteDependency", "RemoteDependencyData", span, startedAt ?? spanStart(durationMs), {
10283
+ ...id ? { id } : {},
10284
+ name,
10285
+ type,
10286
+ duration: formatDuration(durationMs),
10287
+ success,
10288
+ resultCode: resultCode ?? (success ? "200" : "500")
10289
+ });
10290
+ }
10291
+ async flush() {
10292
+ if (this.pending.length === 0)
10293
+ return;
10294
+ const batch = this.pending;
10295
+ this.pending = [];
10296
+ const [error] = await catchError(fetch(`${this.target.ingestionOrigin}/v2/track`, {
10297
+ method: "POST",
10298
+ headers: { "Content-Type": "application/json" },
10299
+ body: JSON.stringify(batch),
10300
+ keepalive: true
10301
+ }));
10302
+ if (error) {
10303
+ logger.debug(`[AppInsights] browser send failed: ${error.message}`);
10304
+ }
10305
+ }
10306
+ async shutdown() {
10307
+ await this.flush();
10308
+ }
10309
+ enqueue(itemType, baseType, item, time, fields) {
10310
+ const iKey = this.target.instrumentationKey;
10311
+ this.pending.push({
10312
+ name: `Microsoft.ApplicationInsights.${iKey.replaceAll("-", "")}.${itemType}`,
10313
+ time: time.toISOString(),
10314
+ iKey,
10315
+ tags: this.tags(item),
10316
+ data: {
10317
+ baseType,
10318
+ baseData: {
10319
+ ver: 2,
10320
+ ...fields,
10321
+ properties: stringProperties({
10322
+ ...getGlobalTelemetryProperties(),
10323
+ ...item.properties
10324
+ })
10325
+ }
10326
+ }
10327
+ });
10328
+ }
10329
+ tags(item) {
10330
+ return {
10331
+ "ai.session.id": getTelemetrySessionId(),
10332
+ "ai.operation.id": item.operationId ?? getTelemetryOperationId(),
10333
+ ...item.parentId ? { "ai.operation.parentId": item.parentId } : {},
10334
+ ...this.applicationVersion ? { "ai.application.ver": this.applicationVersion } : {},
10335
+ "ai.internal.sdkVersion": "uip-browser"
10336
+ };
10337
+ }
10338
+ }
10339
+ function stringProperties(properties) {
10340
+ const result = {};
10341
+ for (const [key, value] of Object.entries(properties)) {
10342
+ if (value === undefined)
10343
+ continue;
10344
+ result[key] = typeof value === "string" ? value : JSON.stringify(value);
10345
+ }
10346
+ return result;
10347
+ }
10348
+ function formatDuration(durationMs) {
10349
+ const ms = Math.max(0, Math.round(durationMs));
10350
+ const pad = (value, width = 2) => String(value).padStart(width, "0");
10351
+ const days = Math.floor(ms / 86400000);
10352
+ const time = `${pad(Math.floor(ms / 3600000) % 24)}:${pad(Math.floor(ms / 60000) % 60)}:${pad(Math.floor(ms / 1000) % 60)}.${pad(ms % 1000, 3)}`;
10353
+ return days > 0 ? `${days}.${time}` : time;
10354
+ }
10355
+
10065
10356
  // src/registry.ts
10066
10357
  import { execFileSync as execFileSync2 } from "node:child_process";
10067
10358
  function readRegistryValue(keyPath, valueName) {
@@ -10388,112 +10679,6 @@ class NodeContextStorage {
10388
10679
  return this.storage.getStore();
10389
10680
  }
10390
10681
  }
10391
- // src/telemetry/trace-context.ts
10392
- var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
10393
- var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
10394
- function getProcessEnv() {
10395
- return globalThis.process?.env;
10396
- }
10397
- function parseInboundTraceparent(value) {
10398
- if (!value) {
10399
- return;
10400
- }
10401
- const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
10402
- if (!match) {
10403
- return;
10404
- }
10405
- const [, traceId, parentSpanId] = match;
10406
- if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
10407
- return;
10408
- }
10409
- return { traceId, parentSpanId };
10410
- }
10411
- function getInboundTraceContext() {
10412
- return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
10413
- }
10414
-
10415
- // src/telemetry/session-id.ts
10416
- var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
10417
- var SESSION_ID_MAX_LENGTH = 64;
10418
- var RANDOM_SESSION_ID_LENGTH = 32;
10419
- var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
10420
- var CONTROL_CHARACTERS = /\p{Cc}/gu;
10421
- var INHERITED_SESSION_SOURCES = [
10422
- { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
10423
- { envVar: "CODEX_THREAD_ID", source: "codex" },
10424
- { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
10425
- { envVar: "TERM_SESSION_ID", source: "terminal" },
10426
- { envVar: "WT_SESSION", source: "terminal" }
10427
- ];
10428
- var telemetrySessionSlot = singleton("TelemetrySession");
10429
- var telemetryOperationIdSlot = singleton("TelemetryOperationId");
10430
- function getProcessEnv2() {
10431
- return globalThis.process?.env;
10432
- }
10433
- function normalizeSessionId(value) {
10434
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
10435
- return;
10436
- }
10437
- const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
10438
- return cleaned || undefined;
10439
- }
10440
- function getConfiguredTelemetrySessionId() {
10441
- return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
10442
- }
10443
- function getInheritedSession(env) {
10444
- for (const candidate of INHERITED_SESSION_SOURCES) {
10445
- const handle = normalizeSessionId(env[candidate.envVar]);
10446
- if (handle) {
10447
- return { id: handle, source: candidate.source };
10448
- }
10449
- }
10450
- return;
10451
- }
10452
- function generateRandomSession() {
10453
- const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
10454
- crypto.getRandomValues(bytes);
10455
- let hex = "";
10456
- for (const byte of bytes) {
10457
- hex += byte.toString(16).padStart(2, "0");
10458
- }
10459
- return { id: hex, source: "random" };
10460
- }
10461
- function resolveTelemetrySession() {
10462
- const existing = telemetrySessionSlot.get();
10463
- if (existing) {
10464
- return existing;
10465
- }
10466
- const declaredHandle = getConfiguredTelemetrySessionId();
10467
- const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
10468
- telemetrySessionSlot.set(resolved);
10469
- return resolved;
10470
- }
10471
- function getTelemetrySessionId() {
10472
- return resolveTelemetrySession().id;
10473
- }
10474
- function getTelemetrySessionSource() {
10475
- return resolveTelemetrySession().source;
10476
- }
10477
- function getTelemetryOperationId() {
10478
- const existing = telemetryOperationIdSlot.get();
10479
- if (existing) {
10480
- return existing;
10481
- }
10482
- const inboundTraceId = getInboundTraceContext()?.traceId;
10483
- const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
10484
- telemetryOperationIdSlot.set(generated);
10485
- return generated;
10486
- }
10487
- // src/telemetry/global-telemetry-properties.ts
10488
- var telemetryPropsSlot = singleton("TelemetryDefaultProps");
10489
- function setGlobalTelemetryProperties(properties) {
10490
- const existing = getGlobalTelemetryProperties();
10491
- telemetryPropsSlot.set({ ...existing, ...properties });
10492
- }
10493
- function getGlobalTelemetryProperties() {
10494
- return telemetryPropsSlot.get();
10495
- }
10496
-
10497
10682
  // src/telemetry/span-clock.ts
10498
10683
  function startSpanClock() {
10499
10684
  const started = performance.now();
@@ -10767,15 +10952,6 @@ function getProxyAuthHttpsAgent() {
10767
10952
 
10768
10953
  // src/telemetry/node-appinsights-telemetry-provider.ts
10769
10954
  var providerSlot = singleton("TelemetryProvider");
10770
- function toOperationUrn(name) {
10771
- if (URL.canParse(name))
10772
- return name;
10773
- const sanitized = encodeURIComponent(name).replace(/%2F/g, "/");
10774
- return `urn:uip:${sanitized}`;
10775
- }
10776
- function spanStart(duration) {
10777
- return new Date(Date.now() - duration);
10778
- }
10779
10955
  function isRecord2(value) {
10780
10956
  return value !== null && typeof value === "object";
10781
10957
  }
@@ -11126,6 +11302,15 @@ function isTelemetryDisabled() {
11126
11302
  function isProjectTelemetryDisabled() {
11127
11303
  return isTelemetryDisabled() || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "1" || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "true";
11128
11304
  }
11305
+ function connectionStringValue(connectionString, key) {
11306
+ for (const part of connectionString.split(";")) {
11307
+ const separator = part.indexOf("=");
11308
+ if (separator !== -1 && part.slice(0, separator).trim().toLowerCase() === key.toLowerCase()) {
11309
+ return part.slice(separator + 1).trim();
11310
+ }
11311
+ }
11312
+ return;
11313
+ }
11129
11314
 
11130
11315
  // src/telemetry/telemetry-spool.ts
11131
11316
  var TELEMETRY_DRAIN_ARGV = "__uip-drain-telemetry";
@@ -11244,18 +11429,19 @@ function getConnectionString() {
11244
11429
  }
11245
11430
  var DEFAULT_INGESTION_ORIGIN = "https://dc.services.visualstudio.com";
11246
11431
  function getTelemetryIngestionOrigin() {
11247
- for (const part of getConnectionString().split(";")) {
11248
- const separator = part.indexOf("=");
11249
- if (separator === -1) {
11250
- continue;
11251
- }
11252
- if (part.slice(0, separator).trim().toLowerCase() !== "ingestionendpoint") {
11253
- continue;
11254
- }
11255
- const [error, url] = catchError(() => new URL(part.slice(separator + 1).trim()));
11256
- return error ? DEFAULT_INGESTION_ORIGIN : url.origin;
11257
- }
11258
- return DEFAULT_INGESTION_ORIGIN;
11432
+ const endpoint = connectionStringValue(getConnectionString(), "IngestionEndpoint");
11433
+ if (endpoint === undefined) {
11434
+ return DEFAULT_INGESTION_ORIGIN;
11435
+ }
11436
+ const [error, url] = catchError(() => new URL(endpoint));
11437
+ return error ? DEFAULT_INGESTION_ORIGIN : url.origin;
11438
+ }
11439
+ var browserProviderSlot = singleton("BrowserAppInsightsTelemetryProvider");
11440
+ function getBrowserAppInsightsProvider() {
11441
+ return browserProviderSlot.getOrInit(() => new BrowserAppInsightsTelemetryProvider({
11442
+ instrumentationKey: connectionStringValue(getConnectionString(), "InstrumentationKey") ?? "",
11443
+ ingestionOrigin: getTelemetryIngestionOrigin()
11444
+ }));
11259
11445
  }
11260
11446
  async function createAppInsightsProvider() {
11261
11447
  return getOrCreateProvider(getConnectionString());
@@ -11269,6 +11455,11 @@ async function createTelemetryProvider(options) {
11269
11455
  telemetryProviderInstance = fallback;
11270
11456
  return { provider: fallback, name: "Disabled" };
11271
11457
  }
11458
+ if (options?.browserAppInsights) {
11459
+ const provider = getBrowserAppInsightsProvider();
11460
+ telemetryProviderInstance = provider;
11461
+ return { provider, name: "BrowserAppInsightsTelemetryProvider" };
11462
+ }
11272
11463
  if (options?.appInsights === false) {
11273
11464
  const fallback = new LoggerTelemetryProvider;
11274
11465
  telemetryProviderInstance = fallback;
@@ -11316,14 +11507,15 @@ var telemetry = new Proxy({}, {
11316
11507
  });
11317
11508
  async function telemetryInit(options) {
11318
11509
  const { provider, name: providerName } = await createTelemetryProvider({
11319
- appInsights: options?.appInsights
11510
+ appInsights: options?.appInsights,
11511
+ browserAppInsights: options?.browserAppInsights
11320
11512
  });
11321
11513
  const existing = getGlobalTelemetryInstance();
11322
11514
  const instance = existing ?? new TelemetryService(provider, new NodeContextStorage);
11323
11515
  instance.setProvider(provider);
11324
11516
  setGlobalTelemetryInstance(instance);
11325
11517
  _localTelemetryInstance = instance;
11326
- const isAppInsights = providerName === "NodeAppInsightsTelemetryProvider";
11518
+ const isAppInsights = providerName === "BrowserAppInsightsTelemetryProvider" || providerName === "NodeAppInsightsTelemetryProvider";
11327
11519
  if (options?.version && isAppInsights) {
11328
11520
  provider.setApplicationVersion(options.version);
11329
11521
  }
@@ -11354,6 +11546,14 @@ async function runWithTimeout(operation, timeoutMs) {
11354
11546
  clearTimeout(timer);
11355
11547
  }
11356
11548
  }
11549
+ async function runProviderFlush(provider) {
11550
+ const [flushError, flushResult] = await catchError(runWithTimeout(provider.flush(), FLUSH_SHUTDOWN_TIMEOUT_MS));
11551
+ if (flushError) {
11552
+ logger.warn(`[Telemetry] flush failed (non-fatal): ${flushError.message}`);
11553
+ } else if (flushResult === "timeout") {
11554
+ logger.warn(`[Telemetry] flush timed out after ${FLUSH_SHUTDOWN_TIMEOUT_MS}ms`);
11555
+ }
11556
+ }
11357
11557
  async function runProviderShutdown(provider) {
11358
11558
  const [shutdownError, shutdownResult] = await catchError(runWithTimeout(provider.shutdown(), FLUSH_SHUTDOWN_TIMEOUT_MS));
11359
11559
  if (shutdownError) {
@@ -11446,18 +11646,17 @@ async function telemetryFlushAndShutdown() {
11446
11646
  if (!isFlushableTelemetryProvider(telemetryProviderInstance)) {
11447
11647
  return;
11448
11648
  }
11649
+ if (telemetryProviderInstance === browserProviderSlot.get()) {
11650
+ await runProviderFlush(telemetryProviderInstance);
11651
+ return;
11652
+ }
11449
11653
  if (!telemetryFlushShutdownPromise) {
11450
11654
  const provider = telemetryProviderInstance;
11451
11655
  telemetryFlushShutdownPromise = (async () => {
11452
11656
  if (await trySidecarHandoff(provider)) {
11453
11657
  return;
11454
11658
  }
11455
- const [flushError, flushResult] = await catchError(runWithTimeout(provider.flush(), FLUSH_SHUTDOWN_TIMEOUT_MS));
11456
- if (flushError) {
11457
- logger.warn(`[Telemetry] flush failed (non-fatal): ${flushError.message}`);
11458
- } else if (flushResult === "timeout") {
11459
- logger.warn(`[Telemetry] flush timed out after ${FLUSH_SHUTDOWN_TIMEOUT_MS}ms`);
11460
- }
11659
+ await runProviderFlush(provider);
11461
11660
  await runProviderShutdown(provider);
11462
11661
  })();
11463
11662
  }
@@ -11724,7 +11923,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
11724
11923
  const pagedRows = extractPagedRows(data.Data);
11725
11924
  const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
11726
11925
  items.forEach((item) => {
11727
- const values = Object.values(item).map((v) => v ?? "").join("\t");
11926
+ const values = item === null || typeof item !== "object" ? String(item ?? "") : Object.values(item).map((v) => v ?? "").join("\t");
11728
11927
  logFn(values);
11729
11928
  });
11730
11929
  } else {
@@ -11739,7 +11938,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
11739
11938
  default: {
11740
11939
  const hasData = "Data" in data && data.Data != null;
11741
11940
  const pagedRows = hasData ? extractPagedRows(data.Data) : null;
11742
- const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
11941
+ const resolvedRows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
11942
+ const rows = resolvedRows && isPrimitiveArray(resolvedRows) ? resolvedRows.map((entry) => ({ Value: entry })) : resolvedRows;
11743
11943
  if (hasData && !(rows !== null && rows.length === 0)) {
11744
11944
  const logValue = data.Log;
11745
11945
  if (rows !== null) {
@@ -11796,6 +11996,9 @@ function printTable(data, logFn, externalLogValue, tableRowStyle) {
11796
11996
  function isPlainObjectArray(value) {
11797
11997
  return Array.isArray(value) && value.length > 0 && value.every(isPlainRecord);
11798
11998
  }
11999
+ function isPrimitiveArray(value) {
12000
+ return Array.isArray(value) && value.length > 0 && value.every((entry) => entry === null || typeof entry !== "object");
12001
+ }
11799
12002
  function isNonEmptyPlainObject(value) {
11800
12003
  return isPlainRecord(value) && Object.keys(value).length > 0;
11801
12004
  }
@@ -12151,12 +12354,12 @@ class FilterEvaluationError extends Error {
12151
12354
  instructions;
12152
12355
  retry = "RetryWillNotFix";
12153
12356
  result = RESULTS.ValidationError;
12154
- constructor(filter, cause) {
12357
+ constructor(filter, cause, hint) {
12155
12358
  const underlying = cause instanceof Error ? cause.message : String(cause);
12156
- super(`Filter '${filter}' failed to evaluate: ${underlying}`);
12359
+ super(`Filter '${filter}' failed to evaluate: ${underlying}` + (hint ? ` ${hint.detail}` : ""));
12157
12360
  this.name = "FilterEvaluationError";
12158
12361
  this.filter = filter;
12159
- 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(@)'.";
12362
+ this.instructions = (hint ? `${hint.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(@)'.";
12160
12363
  }
12161
12364
  }
12162
12365
 
@@ -12292,6 +12495,93 @@ function nameList(names, cap = 12) {
12292
12495
  const rest = names.length - shown.length;
12293
12496
  return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
12294
12497
  }
12498
+ function notFieldsOn(names, scope) {
12499
+ return `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
12500
+ }
12501
+ function failingFieldRead(ast, isList, fn, argIndex) {
12502
+ const [left, right, condition] = ast.children ?? [];
12503
+ let scopes = [];
12504
+ if (!isList) {
12505
+ scopes = [ast];
12506
+ } else if (ast.type === "FilterProjection" && left?.type === "Identity") {
12507
+ scopes = [condition, right];
12508
+ } else if (ast.type === "Projection" && (left?.type === "Identity" || left?.type === "Flatten" && left.children?.[0]?.type === "Identity")) {
12509
+ scopes = [right];
12510
+ }
12511
+ const reads = new Set;
12512
+ let tracked = 0;
12513
+ const visit = (node) => {
12514
+ if (!node)
12515
+ return;
12516
+ switch (node.type) {
12517
+ case "Function": {
12518
+ const arg = node.children?.[argIndex - 1];
12519
+ if (node.name === fn && arg?.type === "Field" && arg.name) {
12520
+ reads.add(arg.name);
12521
+ tracked++;
12522
+ }
12523
+ node.children?.forEach(visit);
12524
+ return;
12525
+ }
12526
+ case "AndExpression":
12527
+ case "OrExpression":
12528
+ case "NotExpression":
12529
+ case "Comparator":
12530
+ case "MultiSelectList":
12531
+ case "MultiSelectHash":
12532
+ node.children?.forEach(visit);
12533
+ return;
12534
+ case "KeyValuePair":
12535
+ visit(node.value);
12536
+ return;
12537
+ }
12538
+ };
12539
+ scopes.forEach(visit);
12540
+ const calls = (node) => {
12541
+ if (node === null || typeof node !== "object")
12542
+ return 0;
12543
+ const own = node.type === "Function" && node.name === fn ? 1 : 0;
12544
+ const next = node.type === "KeyValuePair" ? [node.value] : node.children ?? [];
12545
+ return own + next.reduce((sum, child) => sum + calls(child), 0);
12546
+ };
12547
+ return reads.size === 1 && tracked === calls(ast) ? [...reads][0] : undefined;
12548
+ }
12549
+ function fieldExpression(name) {
12550
+ return /^[A-Za-z_]\w*$/.test(name) ? name : JSON.stringify(name);
12551
+ }
12552
+ function evaluationHint(codec, filter, data, cause) {
12553
+ const underlying = cause instanceof Error ? cause.message : String(cause);
12554
+ const failure = /\b(\w+)\(\) expected argument (\d+) to be type (\S+) but received type null\b/.exec(underlying);
12555
+ if (!failure)
12556
+ return;
12557
+ const [, fn, position, expected] = failure;
12558
+ const name = failingFieldRead(codec.compile(filter), Array.isArray(data), fn, Number(position));
12559
+ if (name === undefined)
12560
+ return;
12561
+ const present = availableFields(data);
12562
+ if (present.length === 0)
12563
+ return;
12564
+ const scope = `${countRecords(data)} record(s)`;
12565
+ if (!present.includes(name)) {
12566
+ return {
12567
+ detail: `${notFieldsOn([name], scope)}. Available fields: ${nameList(present)}.`,
12568
+ instructions: "Use a field the records have; names are case-sensitive."
12569
+ };
12570
+ }
12571
+ const records = Array.isArray(data) ? data : [data];
12572
+ const unset = records.filter((r) => r?.[name] == null).length;
12573
+ const field = fieldExpression(name);
12574
+ let fallback;
12575
+ if (expected.split(",").includes("string")) {
12576
+ fallback = "''";
12577
+ } else if (expected.split(",").includes("array")) {
12578
+ fallback = "`[]`";
12579
+ }
12580
+ return {
12581
+ detail: `\`${name}\` is null or missing on ${unset} of the ${scope} it read.`,
12582
+ instructions: fallback ? `Give it a default where ${fn}() reads it, e.g. \`${field} || ${fallback}\`.` : `Filter out the records where \`${name}\` is null before ${fn}() reads it.`
12583
+ };
12584
+ }
12295
12585
  function buildFilterWarning(filter, data, outcome) {
12296
12586
  const present = availableFields(data);
12297
12587
  const refs = referencedFields(filter);
@@ -12299,7 +12589,7 @@ function buildFilterWarning(filter, data, outcome) {
12299
12589
  const unchecked = refs.nested.filter((name) => !present.includes(name));
12300
12590
  const count = countRecords(data);
12301
12591
  const scope = `${count} record(s)`;
12302
- const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
12592
+ const isNotAField = (names) => notFieldsOn(names, scope);
12303
12593
  const soundness = unchecked.length > 0 ? `${nameList(unchecked)} ${unchecked.length === 1 ? "reads" : "read"} below the top level, so ${unchecked.length === 1 ? "it was" : "they were"} not checked against the record keys` : refs.top.length > 0 ? "every field it names exists" : "";
12304
12594
  const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
12305
12595
  let detail;
@@ -12350,7 +12640,8 @@ function applyFilter(data, filter, onWarning) {
12350
12640
  try {
12351
12641
  result = codec.search(data, filter);
12352
12642
  } catch (err) {
12353
- throw new FilterEvaluationError(filter, err);
12643
+ const [, hint] = catchError(() => evaluationHint(codec, filter, data, err));
12644
+ throw new FilterEvaluationError(filter, err, hint);
12354
12645
  }
12355
12646
  const inputCount = countRecords(data);
12356
12647
  const warn = (outcome) => {
@@ -12736,6 +13027,14 @@ function getProjectTelemetryCapture(command) {
12736
13027
  function attachProjectTelemetryCapture(command, capture) {
12737
13028
  command[CAPTURE] = capture;
12738
13029
  }
13030
+ async function setProjectTelemetryTarget(command, target) {
13031
+ const capture = getProjectTelemetryCapture(command);
13032
+ if (!capture)
13033
+ return;
13034
+ const [error] = await catchError(() => capture.setTarget(target));
13035
+ if (error)
13036
+ logSkipped("project identity target", error);
13037
+ }
12739
13038
  function createProjectCommandResolver(root, rules, read) {
12740
13039
  return createIdentityCommandResolver(root, rules, async (target, command) => identityWithContext(command, await read(target)));
12741
13040
  }
@@ -13349,7 +13648,7 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
13349
13648
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
13350
13649
  const typed = error;
13351
13650
  const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
13352
- const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
13651
+ const customResult = carriedResult(error);
13353
13652
  const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
13354
13653
  const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
13355
13654
  const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
@@ -13535,14 +13834,17 @@ async function mapWithConcurrency(items, limit, fn) {
13535
13834
  return results;
13536
13835
  }
13537
13836
  // src/confirmation.ts
13538
- function requireConfirmation(flags, operation) {
13837
+ function requireConfirmation(flags, operation, options) {
13539
13838
  if (flags.yes === true || flags.force === true) {
13540
13839
  return true;
13541
13840
  }
13841
+ const message = options?.reversible ? `Confirmation required: this will ${operation}.` : `Confirmation required: this will ${operation} and cannot be undone.`;
13542
13842
  OutputFormatter.error({
13543
13843
  Result: RESULTS.Failure,
13544
- Message: `Confirmation required: this will ${operation} and cannot be undone.`,
13545
- Instructions: "Re-run with --yes to confirm."
13844
+ Message: message,
13845
+ Instructions: options?.instructions ?? "Re-run with --yes to confirm.",
13846
+ ErrorCode: "confirmation_required",
13847
+ Retry: "RetryWillNotFix"
13546
13848
  });
13547
13849
  processContext.exit(1);
13548
13850
  return false;
@@ -14942,6 +15244,15 @@ function isFailureStatus(status) {
14942
15244
  function isSuccessStatus(status) {
14943
15245
  return isTerminalStatus(status) && !isFailureStatus(status);
14944
15246
  }
15247
+ // src/relayed-output.ts
15248
+ var RELAYED_OUTPUT_SYMBOL = Symbol.for("@uipath/common/relayed-output");
15249
+ function markOutputRelayed(cmd) {
15250
+ cmd[RELAYED_OUTPUT_SYMBOL] = true;
15251
+ return cmd;
15252
+ }
15253
+ function isOutputRelayed(cmd) {
15254
+ return cmd[RELAYED_OUTPUT_SYMBOL] === true;
15255
+ }
14945
15256
  // src/report-failure.ts
14946
15257
  async function reportFailure(message, error, options = {}) {
14947
15258
  const failure = await classifiedFailure(message, error);
@@ -15081,34 +15392,62 @@ function unsupportedSolutionProjectType(projectType) {
15081
15392
  }
15082
15393
  // src/stdin.ts
15083
15394
  async function readStdin() {
15395
+ return readPipedStdin();
15396
+ }
15397
+ function readPipedStdin(idleTimeoutMs) {
15084
15398
  if (process.stdin.isTTY) {
15085
- return null;
15399
+ return Promise.resolve(null);
15086
15400
  }
15087
15401
  return new Promise((resolve, reject) => {
15402
+ const stdin = process.stdin;
15088
15403
  let data = "";
15089
- process.stdin.setEncoding("utf8");
15090
- process.stdin.on("data", (chunk) => {
15404
+ let timer;
15405
+ const detach = () => {
15406
+ clearTimeout(timer);
15407
+ stdin.off("data", onData);
15408
+ stdin.off("end", onEnd);
15409
+ stdin.off("error", onError);
15410
+ };
15411
+ const release = () => {
15412
+ detach();
15413
+ stdin.pause();
15414
+ stdin.unref?.();
15415
+ };
15416
+ const armTimer = () => {
15417
+ clearTimeout(timer);
15418
+ if (idleTimeoutMs === undefined) {
15419
+ return;
15420
+ }
15421
+ timer = setTimeout(() => {
15422
+ release();
15423
+ if (!data.trim()) {
15424
+ resolve(null);
15425
+ return;
15426
+ }
15427
+ reject(new Error(`Timed out: stdin was idle for ${idleTimeoutMs} ms before end of input.`));
15428
+ }, idleTimeoutMs);
15429
+ };
15430
+ const onData = (chunk) => {
15091
15431
  data += chunk;
15092
- });
15093
- process.stdin.on("end", () => resolve(data.trim() || null));
15094
- process.stdin.on("error", reject);
15432
+ armTimer();
15433
+ };
15434
+ const onEnd = () => {
15435
+ detach();
15436
+ resolve(data.trim() || null);
15437
+ };
15438
+ const onError = (err) => {
15439
+ detach();
15440
+ reject(err);
15441
+ };
15442
+ armTimer();
15443
+ stdin.setEncoding("utf8");
15444
+ stdin.on("data", onData);
15445
+ stdin.on("end", onEnd);
15446
+ stdin.on("error", onError);
15095
15447
  });
15096
15448
  }
15097
15449
  async function readStdinWithTimeout(timeoutMs) {
15098
- let timer;
15099
- const timeout = new Promise((resolve) => {
15100
- timer = setTimeout(() => {
15101
- process.stdin.unref?.();
15102
- resolve(null);
15103
- }, timeoutMs);
15104
- });
15105
- try {
15106
- return await Promise.race([readStdin(), timeout]);
15107
- } finally {
15108
- if (timer) {
15109
- clearTimeout(timer);
15110
- }
15111
- }
15450
+ return readPipedStdin(timeoutMs);
15112
15451
  }
15113
15452
  // src/telemetry/browser-context-storage.ts
15114
15453
  class BrowserContextStorage {
@@ -15355,6 +15694,7 @@ export {
15355
15694
  canPrompt,
15356
15695
  carriedErrorCode,
15357
15696
  carriedInstructions,
15697
+ carriedResult,
15358
15698
  carriedRetry,
15359
15699
  catchError,
15360
15700
  claimPendingSpoolFiles,
@@ -15375,6 +15715,7 @@ export {
15375
15715
  createPollAbortController,
15376
15716
  createProjectCommandResolver,
15377
15717
  createTelemetryProvider,
15718
+ defaultRetryForErrorCode,
15378
15719
  deriveCommandParts,
15379
15720
  deriveCommandPath,
15380
15721
  describeConnectivityError,
@@ -15444,6 +15785,7 @@ export {
15444
15785
  isGuid,
15445
15786
  isHtmlDocument,
15446
15787
  isOutputFormat,
15788
+ isOutputRelayed,
15447
15789
  isPreviewBuild,
15448
15790
  isProjectTelemetryDisabled,
15449
15791
  isRetryHint,
@@ -15461,6 +15803,7 @@ export {
15461
15803
  mapWithConcurrency,
15462
15804
  markCommandStart,
15463
15805
  markLongLivedHost,
15806
+ markOutputRelayed,
15464
15807
  mimeTypeForFileName,
15465
15808
  msToDuration,
15466
15809
  namedOrLegacy,
@@ -15512,6 +15855,7 @@ export {
15512
15855
  resetInvocationRequest,
15513
15856
  resetLoggerInstance,
15514
15857
  resetOutputCodecs,
15858
+ resetTelemetryInvocationIds,
15515
15859
  resetTimings,
15516
15860
  resolveAttachmentInputs,
15517
15861
  resolveDeprecatedOptionAlias,
@@ -15537,10 +15881,13 @@ export {
15537
15881
  setPackagerFactoryProvider,
15538
15882
  setPreviewBuild,
15539
15883
  setProcessContextPollSignal,
15884
+ setProjectTelemetryTarget,
15540
15885
  setProxyAuthHttpsAgent,
15541
15886
  setSdkUserAgentHostToken,
15542
15887
  setTelemetrySidecarEntry,
15543
15888
  setTimingCommand,
15889
+ sha256Base64Url,
15890
+ sha256Hex,
15544
15891
  singleton,
15545
15892
  solutionIdentityProperties,
15546
15893
  splitPackagedName,
@@ -15571,4 +15918,4 @@ export {
15571
15918
  writeTelemetrySpoolFile
15572
15919
  };
15573
15920
 
15574
- //# debugId=B2E7D391B7CC585C64756E2164756E21
15921
+ //# debugId=569827BF4649875F64756E2164756E21