@uipath/docsai-tool 1.206.0-preview.306 → 1.207.0-preview.307

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
@@ -3,7 +3,7 @@ import {
3
3
  Command,
4
4
  metadata2,
5
5
  registerCommands2
6
- } from "./tool-59gyhza0.js";
6
+ } from "./tool-xf64tz3h.js";
7
7
 
8
8
  // src/index.ts
9
9
  var program = new Command;
@@ -9023,7 +9023,7 @@ var package_default = {
9023
9023
  name: "@uipath/docsai-tool",
9024
9024
  author: "UiPath",
9025
9025
  license: "SEE LICENSE IN LICENSE.txt",
9026
- version: "1.206.0-preview.306",
9026
+ version: "1.207.0-preview.307",
9027
9027
  description: "Search UiPath documentation with AI-powered answers.",
9028
9028
  private: false,
9029
9029
  repository: {
@@ -9116,12 +9116,26 @@ class NodeFileSystem {
9116
9116
  throw error;
9117
9117
  }
9118
9118
  }
9119
- async writeFile(filePath, data) {
9119
+ async writeFile(filePath, data, options) {
9120
9120
  const dir = path.dirname(filePath);
9121
9121
  if (dir) {
9122
9122
  await fs.mkdir(dir, { recursive: true });
9123
9123
  }
9124
- await fs.writeFile(filePath, data);
9124
+ if (options?.mode === undefined || process.platform === "win32") {
9125
+ if (options?.exclusive) {
9126
+ await fs.writeFile(filePath, data, { flag: "wx" });
9127
+ } else {
9128
+ await fs.writeFile(filePath, data);
9129
+ }
9130
+ return;
9131
+ }
9132
+ const handle = await fs.open(filePath, options.exclusive ? "wx" : "w", options.mode);
9133
+ try {
9134
+ await handle.chmod(options.mode);
9135
+ await handle.writeFile(data);
9136
+ } finally {
9137
+ await handle.close();
9138
+ }
9125
9139
  }
9126
9140
  async appendFile(filePath, data) {
9127
9141
  const dir = path.dirname(filePath);
@@ -9156,7 +9170,8 @@ class NodeFileSystem {
9156
9170
  isDirectory: () => stats.isDirectory(),
9157
9171
  size: stats.size,
9158
9172
  mtimeMs: stats.mtimeMs,
9159
- ctimeMs: stats.ctimeMs
9173
+ ctimeMs: stats.ctimeMs,
9174
+ mode: stats.mode
9160
9175
  };
9161
9176
  } catch (error) {
9162
9177
  if (this.isEnoent(error))
@@ -9167,8 +9182,13 @@ class NodeFileSystem {
9167
9182
  async exists(filePath) {
9168
9183
  return existsSync(filePath);
9169
9184
  }
9170
- async mkdir(dirPath) {
9171
- await fs.mkdir(dirPath, { recursive: true });
9185
+ async mkdir(dirPath, options) {
9186
+ await fs.mkdir(dirPath, { recursive: true, mode: options?.mode });
9187
+ }
9188
+ async chmod(targetPath, mode) {
9189
+ if (process.platform === "win32")
9190
+ return;
9191
+ await fs.chmod(targetPath, mode);
9172
9192
  }
9173
9193
  async acquireLock(lockPath) {
9174
9194
  const canonicalPath = await this.canonicalizeLockTarget(lockPath);
@@ -9318,7 +9338,7 @@ class NodeFileSystem {
9318
9338
  async getTempDir() {
9319
9339
  return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
9320
9340
  }
9321
- async copyDirectory(sourcePath, destPath) {
9341
+ async copyDirectory(sourcePath, destPath, options) {
9322
9342
  const sourceStats = await this.stat(sourcePath);
9323
9343
  if (!sourceStats) {
9324
9344
  throw new Error(`Source directory does not exist: ${sourcePath}`);
@@ -9335,7 +9355,9 @@ class NodeFileSystem {
9335
9355
  if (!entryStats)
9336
9356
  continue;
9337
9357
  if (entryStats.isDirectory()) {
9338
- await this.copyDirectory(srcEntry, destEntry);
9358
+ if (options?.skipDirectoryNames?.includes(entry))
9359
+ continue;
9360
+ await this.copyDirectory(srcEntry, destEntry, options);
9339
9361
  } else if (entryStats.isFile()) {
9340
9362
  const content = await this.readFile(srcEntry);
9341
9363
  if (content !== null) {
@@ -9398,13 +9420,15 @@ var ProjectDimensions = {
9398
9420
  SolutionKey: "SolutionKey",
9399
9421
  SolutionProjectKey: "SolutionProjectKey",
9400
9422
  SolutionIdentityStatus: "SolutionIdentityStatus",
9401
- PreviousSolutionKey: "PreviousSolutionKey"
9423
+ PreviousSolutionKey: "PreviousSolutionKey",
9424
+ PreviousProjectKey: "PreviousProjectKey"
9402
9425
  };
9403
9426
  var GUID_KEY_DIMENSIONS = new Set([
9404
9427
  ProjectDimensions.ProjectKey,
9405
9428
  ProjectDimensions.SolutionKey,
9406
9429
  ProjectDimensions.SolutionProjectKey,
9407
- ProjectDimensions.PreviousSolutionKey
9430
+ ProjectDimensions.PreviousSolutionKey,
9431
+ ProjectDimensions.PreviousProjectKey
9408
9432
  ]);
9409
9433
  var ShipDimensions = {
9410
9434
  ShipKind: "ShipKind",
@@ -9558,9 +9582,7 @@ async function withinProjectIdentityBudget(work, onTimeout) {
9558
9582
  }
9559
9583
  }
9560
9584
 
9561
- // ../common/src/telemetry/pseudonymize.ts
9562
- var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
9563
- var PSEUDONYM_HEX_LENGTH = 32;
9585
+ // ../common/src/sha256.ts
9564
9586
  var SHA256_K = new Uint32Array([
9565
9587
  1116352408,
9566
9588
  1899447441,
@@ -9640,7 +9662,7 @@ var SHA256_INITIAL_STATE = new Uint32Array([
9640
9662
  function rotr(value, bits) {
9641
9663
  return (value >>> bits | value << 32 - bits) >>> 0;
9642
9664
  }
9643
- function sha256Hex(input) {
9665
+ function sha256Words(input) {
9644
9666
  const bytes = new TextEncoder().encode(input);
9645
9667
  const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
9646
9668
  const buffer = new Uint8Array(paddedLength);
@@ -9696,12 +9718,19 @@ function sha256Hex(input) {
9696
9718
  state[6] = state[6] + g >>> 0;
9697
9719
  state[7] = state[7] + h >>> 0;
9698
9720
  }
9721
+ return state;
9722
+ }
9723
+ function sha256Hex(input) {
9699
9724
  let hex = "";
9700
- for (const word of state) {
9725
+ for (const word of sha256Words(input)) {
9701
9726
  hex += word.toString(16).padStart(8, "0");
9702
9727
  }
9703
9728
  return hex;
9704
9729
  }
9730
+
9731
+ // ../common/src/telemetry/pseudonymize.ts
9732
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
9733
+ var PSEUDONYM_HEX_LENGTH = 32;
9705
9734
  function resolveSha256Hex() {
9706
9735
  try {
9707
9736
  const nodeCrypto = __require("node:crypto");
@@ -10097,13 +10126,25 @@ function settlePromiseLike(thenable) {
10097
10126
  return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
10098
10127
  }
10099
10128
 
10129
+ // ../common/src/result-types.ts
10130
+ var RESULTS = {
10131
+ Success: "Success",
10132
+ Failure: "Failure",
10133
+ ConfigError: "ConfigError",
10134
+ AuthenticationError: "AuthenticationError",
10135
+ ValidationError: "ValidationError",
10136
+ TimeoutError: "TimeoutError"
10137
+ };
10138
+
10100
10139
  // ../common/src/error-codes.ts
10101
10140
  var CLI_ERROR_CODES = [
10102
10141
  "invalid_argument",
10142
+ "confirmation_required",
10103
10143
  "authentication_required",
10104
10144
  "permission_denied",
10105
10145
  "local_permission_denied",
10106
10146
  "not_found",
10147
+ "not_enabled",
10107
10148
  "rate_limited",
10108
10149
  "network_error",
10109
10150
  "timeout",
@@ -10142,6 +10183,12 @@ function carriedRetry(error) {
10142
10183
  const retry = error.retry;
10143
10184
  return isRetryHint(retry) ? retry : undefined;
10144
10185
  }
10186
+ function carriedResult(error) {
10187
+ if (!error || typeof error !== "object")
10188
+ return;
10189
+ const result = error.result;
10190
+ return typeof result === "string" && result !== RESULTS.Success && Object.values(RESULTS).includes(result) ? result : undefined;
10191
+ }
10145
10192
  function defaultRetryForErrorCode(errorCode) {
10146
10193
  switch (errorCode) {
10147
10194
  case "network_error":
@@ -10531,6 +10578,8 @@ async function extractErrorDetails(error, options) {
10531
10578
  }
10532
10579
  if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
10533
10580
  context.errorCode = parsedBody.errorCode;
10581
+ } else if (typeof parsedBody?.errorCode === "number") {
10582
+ context.errorCode = String(parsedBody.errorCode);
10534
10583
  } else if (parsedBody?.code && typeof parsedBody.code === "string") {
10535
10584
  context.errorCode = parsedBody.code;
10536
10585
  }
@@ -10587,15 +10636,17 @@ async function extractErrorDetails(error, options) {
10587
10636
  ...parsedErrors ? { parsedErrors } : {}
10588
10637
  };
10589
10638
  }
10590
- // ../common/src/result-types.ts
10591
- var RESULTS = {
10592
- Success: "Success",
10593
- Failure: "Failure",
10594
- ConfigError: "ConfigError",
10595
- AuthenticationError: "AuthenticationError",
10596
- ValidationError: "ValidationError",
10597
- TimeoutError: "TimeoutError"
10598
- };
10639
+ // ../common/src/classified-failure.ts
10640
+ function notSupportedFailure(operation, instructions, context) {
10641
+ return {
10642
+ Result: RESULTS.Failure,
10643
+ ErrorCode: "not_supported",
10644
+ Message: `${operation} isn't supported on the connected environment.`,
10645
+ Instructions: instructions,
10646
+ Retry: "RetryWillNotFix",
10647
+ ...context ? { Context: context } : {}
10648
+ };
10649
+ }
10599
10650
  // ../../node_modules/commander/index.js
10600
10651
  var exports_commander = {};
10601
10652
  __exportCjs(exports_commander, {
@@ -11028,7 +11079,10 @@ var AUTH_ERROR_CODES = new Set([
11028
11079
  var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
11029
11080
  "local_permission_denied"
11030
11081
  ]);
11031
- var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
11082
+ var VALIDATION_ERROR_CODES = new Set([
11083
+ "invalid_argument",
11084
+ "confirmation_required"
11085
+ ]);
11032
11086
  var NETWORK_HTTP_ERROR_CODES = new Set([
11033
11087
  "network_error",
11034
11088
  "rate_limited",
@@ -11254,6 +11308,109 @@ var CommonTelemetryEvents = {
11254
11308
  ShipSucceeded: "Cli.ShipSucceeded"
11255
11309
  };
11256
11310
 
11311
+ // ../common/src/telemetry/global-telemetry-properties.ts
11312
+ var telemetryPropsSlot = singleton("TelemetryDefaultProps");
11313
+ function getGlobalTelemetryProperties() {
11314
+ return telemetryPropsSlot.get();
11315
+ }
11316
+
11317
+ // ../common/src/telemetry/trace-context.ts
11318
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
11319
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
11320
+ function getProcessEnv() {
11321
+ return globalThis.process?.env;
11322
+ }
11323
+ function parseInboundTraceparent(value) {
11324
+ if (!value) {
11325
+ return;
11326
+ }
11327
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
11328
+ if (!match) {
11329
+ return;
11330
+ }
11331
+ const [, traceId, parentSpanId] = match;
11332
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
11333
+ return;
11334
+ }
11335
+ return { traceId, parentSpanId };
11336
+ }
11337
+ function getInboundTraceContext() {
11338
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
11339
+ }
11340
+
11341
+ // ../common/src/telemetry/session-id.ts
11342
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
11343
+ var SESSION_ID_MAX_LENGTH = 64;
11344
+ var RANDOM_SESSION_ID_LENGTH = 32;
11345
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
11346
+ var CONTROL_CHARACTERS = /\p{Cc}/gu;
11347
+ var INHERITED_SESSION_SOURCES = [
11348
+ { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
11349
+ { envVar: "CODEX_THREAD_ID", source: "codex" },
11350
+ { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
11351
+ { envVar: "TERM_SESSION_ID", source: "terminal" },
11352
+ { envVar: "WT_SESSION", source: "terminal" }
11353
+ ];
11354
+ var telemetrySessionSlot = singleton("TelemetrySession");
11355
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
11356
+ function getProcessEnv2() {
11357
+ return globalThis.process?.env;
11358
+ }
11359
+ function normalizeSessionId(value) {
11360
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
11361
+ return;
11362
+ }
11363
+ const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
11364
+ return cleaned || undefined;
11365
+ }
11366
+ function getConfiguredTelemetrySessionId() {
11367
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
11368
+ }
11369
+ function getInheritedSession(env) {
11370
+ for (const candidate of INHERITED_SESSION_SOURCES) {
11371
+ const handle = normalizeSessionId(env[candidate.envVar]);
11372
+ if (handle) {
11373
+ return { id: handle, source: candidate.source };
11374
+ }
11375
+ }
11376
+ return;
11377
+ }
11378
+ function generateRandomSession() {
11379
+ const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
11380
+ crypto.getRandomValues(bytes);
11381
+ let hex = "";
11382
+ for (const byte of bytes) {
11383
+ hex += byte.toString(16).padStart(2, "0");
11384
+ }
11385
+ return { id: hex, source: "random" };
11386
+ }
11387
+ function resolveTelemetrySession() {
11388
+ const existing = telemetrySessionSlot.get();
11389
+ if (existing) {
11390
+ return existing;
11391
+ }
11392
+ const declaredHandle = getConfiguredTelemetrySessionId();
11393
+ const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
11394
+ telemetrySessionSlot.set(resolved);
11395
+ return resolved;
11396
+ }
11397
+ function getTelemetrySessionId() {
11398
+ return resolveTelemetrySession().id;
11399
+ }
11400
+ function getTelemetrySessionSource() {
11401
+ return resolveTelemetrySession().source;
11402
+ }
11403
+ function getTelemetryOperationId() {
11404
+ const existing = telemetryOperationIdSlot.get();
11405
+ if (existing) {
11406
+ return existing;
11407
+ }
11408
+ const inboundTraceId = getInboundTraceContext()?.traceId;
11409
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
11410
+ telemetryOperationIdSlot.set(generated);
11411
+ return generated;
11412
+ }
11413
+
11257
11414
  // ../common/src/registry.ts
11258
11415
  import { execFileSync } from "node:child_process";
11259
11416
  function readRegistryValue(keyPath, valueName) {
@@ -11475,108 +11632,6 @@ class NodeContextStorage {
11475
11632
  return this.storage.getStore();
11476
11633
  }
11477
11634
  }
11478
- // ../common/src/telemetry/trace-context.ts
11479
- var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
11480
- var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
11481
- function getProcessEnv() {
11482
- return globalThis.process?.env;
11483
- }
11484
- function parseInboundTraceparent(value) {
11485
- if (!value) {
11486
- return;
11487
- }
11488
- const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
11489
- if (!match) {
11490
- return;
11491
- }
11492
- const [, traceId, parentSpanId] = match;
11493
- if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
11494
- return;
11495
- }
11496
- return { traceId, parentSpanId };
11497
- }
11498
- function getInboundTraceContext() {
11499
- return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
11500
- }
11501
-
11502
- // ../common/src/telemetry/session-id.ts
11503
- var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
11504
- var SESSION_ID_MAX_LENGTH = 64;
11505
- var RANDOM_SESSION_ID_LENGTH = 32;
11506
- var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
11507
- var CONTROL_CHARACTERS = /\p{Cc}/gu;
11508
- var INHERITED_SESSION_SOURCES = [
11509
- { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
11510
- { envVar: "CODEX_THREAD_ID", source: "codex" },
11511
- { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
11512
- { envVar: "TERM_SESSION_ID", source: "terminal" },
11513
- { envVar: "WT_SESSION", source: "terminal" }
11514
- ];
11515
- var telemetrySessionSlot = singleton("TelemetrySession");
11516
- var telemetryOperationIdSlot = singleton("TelemetryOperationId");
11517
- function getProcessEnv2() {
11518
- return globalThis.process?.env;
11519
- }
11520
- function normalizeSessionId(value) {
11521
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
11522
- return;
11523
- }
11524
- const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
11525
- return cleaned || undefined;
11526
- }
11527
- function getConfiguredTelemetrySessionId() {
11528
- return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
11529
- }
11530
- function getInheritedSession(env) {
11531
- for (const candidate of INHERITED_SESSION_SOURCES) {
11532
- const handle = normalizeSessionId(env[candidate.envVar]);
11533
- if (handle) {
11534
- return { id: handle, source: candidate.source };
11535
- }
11536
- }
11537
- return;
11538
- }
11539
- function generateRandomSession() {
11540
- const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
11541
- crypto.getRandomValues(bytes);
11542
- let hex = "";
11543
- for (const byte of bytes) {
11544
- hex += byte.toString(16).padStart(2, "0");
11545
- }
11546
- return { id: hex, source: "random" };
11547
- }
11548
- function resolveTelemetrySession() {
11549
- const existing = telemetrySessionSlot.get();
11550
- if (existing) {
11551
- return existing;
11552
- }
11553
- const declaredHandle = getConfiguredTelemetrySessionId();
11554
- const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
11555
- telemetrySessionSlot.set(resolved);
11556
- return resolved;
11557
- }
11558
- function getTelemetrySessionId() {
11559
- return resolveTelemetrySession().id;
11560
- }
11561
- function getTelemetrySessionSource() {
11562
- return resolveTelemetrySession().source;
11563
- }
11564
- function getTelemetryOperationId() {
11565
- const existing = telemetryOperationIdSlot.get();
11566
- if (existing) {
11567
- return existing;
11568
- }
11569
- const inboundTraceId = getInboundTraceContext()?.traceId;
11570
- const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
11571
- telemetryOperationIdSlot.set(generated);
11572
- return generated;
11573
- }
11574
- // ../common/src/telemetry/global-telemetry-properties.ts
11575
- var telemetryPropsSlot = singleton("TelemetryDefaultProps");
11576
- function getGlobalTelemetryProperties() {
11577
- return telemetryPropsSlot.get();
11578
- }
11579
-
11580
11635
  // ../common/src/telemetry/span-clock.ts
11581
11636
  function startSpanClock() {
11582
11637
  const started = performance.now();
@@ -11790,6 +11845,7 @@ var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
11790
11845
  // ../common/src/telemetry/telemetry-init.ts
11791
11846
  var telemetryInstanceSlot = singleton("TelemetryService");
11792
11847
  var DEFAULT_AI_CONNECTION_STRING = atob("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj");
11848
+ var browserProviderSlot = singleton("BrowserAppInsightsTelemetryProvider");
11793
11849
  function getGlobalTelemetryInstance() {
11794
11850
  const existing = telemetryInstanceSlot.get();
11795
11851
  if (existing && typeof existing === "object" && "trackEvent" in existing && typeof existing.trackEvent === "function") {
@@ -11973,7 +12029,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
11973
12029
  const pagedRows = extractPagedRows(data.Data);
11974
12030
  const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
11975
12031
  items.forEach((item) => {
11976
- const values = Object.values(item).map((v) => v ?? "").join("\t");
12032
+ const values = item === null || typeof item !== "object" ? String(item ?? "") : Object.values(item).map((v) => v ?? "").join("\t");
11977
12033
  logFn(values);
11978
12034
  });
11979
12035
  } else {
@@ -11988,7 +12044,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
11988
12044
  default: {
11989
12045
  const hasData = "Data" in data && data.Data != null;
11990
12046
  const pagedRows = hasData ? extractPagedRows(data.Data) : null;
11991
- const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
12047
+ const resolvedRows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
12048
+ const rows = resolvedRows && isPrimitiveArray(resolvedRows) ? resolvedRows.map((entry) => ({ Value: entry })) : resolvedRows;
11992
12049
  if (hasData && !(rows !== null && rows.length === 0)) {
11993
12050
  const logValue = data.Log;
11994
12051
  if (rows !== null) {
@@ -12045,6 +12102,9 @@ function printTable(data, logFn, externalLogValue, tableRowStyle) {
12045
12102
  function isPlainObjectArray(value) {
12046
12103
  return Array.isArray(value) && value.length > 0 && value.every(isPlainRecord);
12047
12104
  }
12105
+ function isPrimitiveArray(value) {
12106
+ return Array.isArray(value) && value.length > 0 && value.every((entry) => entry === null || typeof entry !== "object");
12107
+ }
12048
12108
  function isNonEmptyPlainObject(value) {
12049
12109
  return isPlainRecord(value) && Object.keys(value).length > 0;
12050
12110
  }
@@ -12391,12 +12451,12 @@ class FilterEvaluationError extends Error {
12391
12451
  instructions;
12392
12452
  retry = "RetryWillNotFix";
12393
12453
  result = RESULTS.ValidationError;
12394
- constructor(filter, cause) {
12454
+ constructor(filter, cause, hint) {
12395
12455
  const underlying = cause instanceof Error ? cause.message : String(cause);
12396
- super(`Filter '${filter}' failed to evaluate: ${underlying}`);
12456
+ super(`Filter '${filter}' failed to evaluate: ${underlying}` + (hint ? ` ${hint.detail}` : ""));
12397
12457
  this.name = "FilterEvaluationError";
12398
12458
  this.filter = filter;
12399
- 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(@)'.";
12459
+ 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(@)'.";
12400
12460
  }
12401
12461
  }
12402
12462
 
@@ -12518,6 +12578,93 @@ function nameList(names, cap = 12) {
12518
12578
  const rest = names.length - shown.length;
12519
12579
  return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
12520
12580
  }
12581
+ function notFieldsOn(names, scope) {
12582
+ return `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
12583
+ }
12584
+ function failingFieldRead(ast, isList, fn, argIndex) {
12585
+ const [left, right, condition] = ast.children ?? [];
12586
+ let scopes = [];
12587
+ if (!isList) {
12588
+ scopes = [ast];
12589
+ } else if (ast.type === "FilterProjection" && left?.type === "Identity") {
12590
+ scopes = [condition, right];
12591
+ } else if (ast.type === "Projection" && (left?.type === "Identity" || left?.type === "Flatten" && left.children?.[0]?.type === "Identity")) {
12592
+ scopes = [right];
12593
+ }
12594
+ const reads = new Set;
12595
+ let tracked = 0;
12596
+ const visit = (node) => {
12597
+ if (!node)
12598
+ return;
12599
+ switch (node.type) {
12600
+ case "Function": {
12601
+ const arg = node.children?.[argIndex - 1];
12602
+ if (node.name === fn && arg?.type === "Field" && arg.name) {
12603
+ reads.add(arg.name);
12604
+ tracked++;
12605
+ }
12606
+ node.children?.forEach(visit);
12607
+ return;
12608
+ }
12609
+ case "AndExpression":
12610
+ case "OrExpression":
12611
+ case "NotExpression":
12612
+ case "Comparator":
12613
+ case "MultiSelectList":
12614
+ case "MultiSelectHash":
12615
+ node.children?.forEach(visit);
12616
+ return;
12617
+ case "KeyValuePair":
12618
+ visit(node.value);
12619
+ return;
12620
+ }
12621
+ };
12622
+ scopes.forEach(visit);
12623
+ const calls = (node) => {
12624
+ if (node === null || typeof node !== "object")
12625
+ return 0;
12626
+ const own = node.type === "Function" && node.name === fn ? 1 : 0;
12627
+ const next = node.type === "KeyValuePair" ? [node.value] : node.children ?? [];
12628
+ return own + next.reduce((sum, child) => sum + calls(child), 0);
12629
+ };
12630
+ return reads.size === 1 && tracked === calls(ast) ? [...reads][0] : undefined;
12631
+ }
12632
+ function fieldExpression(name) {
12633
+ return /^[A-Za-z_]\w*$/.test(name) ? name : JSON.stringify(name);
12634
+ }
12635
+ function evaluationHint(codec, filter, data, cause) {
12636
+ const underlying = cause instanceof Error ? cause.message : String(cause);
12637
+ const failure = /\b(\w+)\(\) expected argument (\d+) to be type (\S+) but received type null\b/.exec(underlying);
12638
+ if (!failure)
12639
+ return;
12640
+ const [, fn, position, expected] = failure;
12641
+ const name = failingFieldRead(codec.compile(filter), Array.isArray(data), fn, Number(position));
12642
+ if (name === undefined)
12643
+ return;
12644
+ const present = availableFields(data);
12645
+ if (present.length === 0)
12646
+ return;
12647
+ const scope = `${countRecords(data)} record(s)`;
12648
+ if (!present.includes(name)) {
12649
+ return {
12650
+ detail: `${notFieldsOn([name], scope)}. Available fields: ${nameList(present)}.`,
12651
+ instructions: "Use a field the records have; names are case-sensitive."
12652
+ };
12653
+ }
12654
+ const records = Array.isArray(data) ? data : [data];
12655
+ const unset = records.filter((r) => r?.[name] == null).length;
12656
+ const field = fieldExpression(name);
12657
+ let fallback;
12658
+ if (expected.split(",").includes("string")) {
12659
+ fallback = "''";
12660
+ } else if (expected.split(",").includes("array")) {
12661
+ fallback = "`[]`";
12662
+ }
12663
+ return {
12664
+ detail: `\`${name}\` is null or missing on ${unset} of the ${scope} it read.`,
12665
+ 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.`
12666
+ };
12667
+ }
12521
12668
  function buildFilterWarning(filter, data, outcome) {
12522
12669
  const present = availableFields(data);
12523
12670
  const refs = referencedFields(filter);
@@ -12525,7 +12672,7 @@ function buildFilterWarning(filter, data, outcome) {
12525
12672
  const unchecked = refs.nested.filter((name) => !present.includes(name));
12526
12673
  const count = countRecords(data);
12527
12674
  const scope = `${count} record(s)`;
12528
- const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
12675
+ const isNotAField = (names) => notFieldsOn(names, scope);
12529
12676
  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" : "";
12530
12677
  const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
12531
12678
  let detail;
@@ -12576,7 +12723,8 @@ function applyFilter(data, filter, onWarning) {
12576
12723
  try {
12577
12724
  result = codec.search(data, filter);
12578
12725
  } catch (err) {
12579
- throw new FilterEvaluationError(filter, err);
12726
+ const [, hint] = catchError(() => evaluationHint(codec, filter, data, err));
12727
+ throw new FilterEvaluationError(filter, err, hint);
12580
12728
  }
12581
12729
  const inputCount = countRecords(data);
12582
12730
  const warn = (outcome) => {
@@ -13467,7 +13615,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
13467
13615
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
13468
13616
  const typed = error;
13469
13617
  const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
13470
- const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
13618
+ const customResult = carriedResult(error);
13471
13619
  const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
13472
13620
  const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
13473
13621
  const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
@@ -13846,6 +13994,8 @@ var FAILURE_STATUSES = new Set([
13846
13994
  "canceled",
13847
13995
  "stopped"
13848
13996
  ]);
13997
+ // ../common/src/relayed-output.ts
13998
+ var RELAYED_OUTPUT_SYMBOL = Symbol.for("@uipath/common/relayed-output");
13849
13999
  // ../common/src/screen-logger.ts
13850
14000
  var ScreenLogger;
13851
14001
  ((ScreenLogger) => {
@@ -13893,6 +14043,8 @@ function settlePromiseLike2(thenable) {
13893
14043
  // ../auth/src/constants.ts
13894
14044
  var UIPATH_HOME_DIR = ".uipath";
13895
14045
  var AUTH_FILENAME = ".auth";
14046
+ var AUTH_FILE_MODE = 384;
14047
+ var AUTH_DIR_MODE = 448;
13896
14048
  var DEFAULT_BASE_URL = "https://cloud.uipath.com";
13897
14049
  var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
13898
14050
 
@@ -14716,6 +14868,38 @@ var loadEnvFileAsync = async ({ envPath }) => {
14716
14868
  }
14717
14869
  return parseEnvContent(content);
14718
14870
  };
14871
+ var findAuthHomeDir = (fs, dir) => {
14872
+ let current = dir;
14873
+ for (;; ) {
14874
+ if (fs.path.basename(current) === UIPATH_HOME_DIR)
14875
+ return current;
14876
+ const parent = fs.path.dirname(current);
14877
+ if (parent === current)
14878
+ return;
14879
+ current = parent;
14880
+ }
14881
+ };
14882
+ var TEMP_FILE_ATTEMPTS = 5;
14883
+ var isFileExists = (error) => error instanceof Error && error.code === "EEXIST";
14884
+ var writeTempFile = async (fs, targetPath, content) => {
14885
+ for (let attempt = 1;; attempt++) {
14886
+ const tempPath = `${targetPath}.${crypto.randomUUID()}.tmp`;
14887
+ try {
14888
+ await fs.writeFile(tempPath, content, {
14889
+ mode: AUTH_FILE_MODE,
14890
+ exclusive: true
14891
+ });
14892
+ return tempPath;
14893
+ } catch (error) {
14894
+ if (!isFileExists(error)) {
14895
+ await fs.rm(tempPath).catch(() => {});
14896
+ throw error;
14897
+ }
14898
+ if (attempt === TEMP_FILE_ATTEMPTS)
14899
+ throw error;
14900
+ }
14901
+ }
14902
+ };
14719
14903
  var saveEnvFileAsync = async ({
14720
14904
  envPath,
14721
14905
  data,
@@ -14743,10 +14927,18 @@ var saveEnvFileAsync = async ({
14743
14927
  `)}
14744
14928
  `;
14745
14929
  const dir = fs.path.dirname(absolutePath);
14746
- await fs.mkdir(dir);
14747
- const tempPath = `${absolutePath}.tmp`;
14748
- await fs.writeFile(tempPath, content);
14749
- await fs.rename(tempPath, absolutePath);
14930
+ await fs.mkdir(dir, { mode: AUTH_DIR_MODE });
14931
+ const authHomeDir = findAuthHomeDir(fs, dir);
14932
+ if (authHomeDir !== undefined) {
14933
+ await fs.chmod?.(authHomeDir, AUTH_DIR_MODE);
14934
+ }
14935
+ const tempPath = await writeTempFile(fs, absolutePath, content);
14936
+ try {
14937
+ await fs.rename(tempPath, absolutePath);
14938
+ } catch (error) {
14939
+ await fs.rm(tempPath).catch(() => {});
14940
+ throw error;
14941
+ }
14750
14942
  };
14751
14943
 
14752
14944
  // ../auth/src/loginStatus.ts
@@ -25490,7 +25682,28 @@ function withHttpStatus(error) {
25490
25682
  }
25491
25683
  return { message: error.message, status: code, cause: error };
25492
25684
  }
25685
+ var SERVICE_NOT_FOUND = "Service 'docsai' not found";
25686
+ var UNSUPPORTED_ISSUER = "Token issuer is not supported";
25687
+ function isDocsAINotOffered(error) {
25688
+ const { code, message } = error ?? {};
25689
+ if (code !== 404 || typeof message !== "string") {
25690
+ return false;
25691
+ }
25692
+ const body = message.split("Error POSTing to endpoint:")[1]?.trim() ?? "";
25693
+ return body === "" || body.includes(SERVICE_NOT_FOUND);
25694
+ }
25695
+ function isUnsupportedIssuer(content) {
25696
+ return content.some((c) => c.type === "text" && c.text?.includes(UNSUPPORTED_ISSUER));
25697
+ }
25698
+ function reportNotSupported(context) {
25699
+ OutputFormatter.error(notSupportedFailure("DocsAI documentation search", "DocsAI is not available on the connected environment. Search the documentation at https://docs.uipath.com instead.", context));
25700
+ processContext.exit(1);
25701
+ }
25493
25702
  async function reportQueryError(error) {
25703
+ if (isDocsAINotOffered(error)) {
25704
+ reportNotSupported({ httpStatus: 404 });
25705
+ return;
25706
+ }
25494
25707
  const details = await extractErrorDetails(withHttpStatus(error));
25495
25708
  OutputFormatter.error({
25496
25709
  Result: details.result,
@@ -25527,6 +25740,10 @@ var registerAskCommand = (program) => {
25527
25740
  return;
25528
25741
  }
25529
25742
  if (result.isError) {
25743
+ if (isUnsupportedIssuer(result.content)) {
25744
+ reportNotSupported({ httpStatus: 401 });
25745
+ return;
25746
+ }
25530
25747
  OutputFormatter.error({
25531
25748
  Result: RESULTS.Failure,
25532
25749
  Message: "DocsAI returned an error",
@@ -25562,4 +25779,4 @@ var registerCommands2 = async (program) => {
25562
25779
 
25563
25780
  export { Command, metadata2, registerCommands2 };
25564
25781
 
25565
- //# debugId=84A4AC207097887C64756E2164756E21
25782
+ //# debugId=10903B9BDC561AF364756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata2,
3
3
  registerCommands2
4
- } from "./tool-59gyhza0.js";
4
+ } from "./tool-xf64tz3h.js";
5
5
  export {
6
6
  metadata2 as metadata,
7
7
  registerCommands2 as registerCommands
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/docsai-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.206.0-preview.306",
5
+ "version": "1.207.0-preview.307",
6
6
  "description": "Search UiPath documentation with AI-powered answers.",
7
7
  "private": false,
8
8
  "repository": {
@@ -27,5 +27,5 @@
27
27
  "files": [
28
28
  "dist"
29
29
  ],
30
- "gitHead": "0b8843ae9b6d2f69a0203f96ab91e5d55e416383"
30
+ "gitHead": "a625ed8ac421089170db3cb8b95c497f3c7b0d62"
31
31
  }