@uipath/llm-gateway-tool 1.206.0-preview.301 → 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.
Files changed (2) hide show
  1. package/dist/tool.js +330 -148
  2. package/package.json +2 -2
package/dist/tool.js CHANGED
@@ -2082,7 +2082,7 @@ var package_default = {
2082
2082
  name: "@uipath/llm-gateway-tool",
2083
2083
  author: "UiPath",
2084
2084
  license: "SEE LICENSE IN LICENSE.txt",
2085
- version: "1.206.0-preview.301",
2085
+ version: "1.207.0-preview.305",
2086
2086
  description: "CLI plugin for UiPath LLM Gateway model discovery.",
2087
2087
  private: false,
2088
2088
  repository: {
@@ -2170,12 +2170,26 @@ class NodeFileSystem {
2170
2170
  throw error;
2171
2171
  }
2172
2172
  }
2173
- async writeFile(filePath, data) {
2173
+ async writeFile(filePath, data, options) {
2174
2174
  const dir = path.dirname(filePath);
2175
2175
  if (dir) {
2176
2176
  await fs.mkdir(dir, { recursive: true });
2177
2177
  }
2178
- await fs.writeFile(filePath, data);
2178
+ if (options?.mode === undefined || process.platform === "win32") {
2179
+ if (options?.exclusive) {
2180
+ await fs.writeFile(filePath, data, { flag: "wx" });
2181
+ } else {
2182
+ await fs.writeFile(filePath, data);
2183
+ }
2184
+ return;
2185
+ }
2186
+ const handle = await fs.open(filePath, options.exclusive ? "wx" : "w", options.mode);
2187
+ try {
2188
+ await handle.chmod(options.mode);
2189
+ await handle.writeFile(data);
2190
+ } finally {
2191
+ await handle.close();
2192
+ }
2179
2193
  }
2180
2194
  async appendFile(filePath, data) {
2181
2195
  const dir = path.dirname(filePath);
@@ -2210,7 +2224,8 @@ class NodeFileSystem {
2210
2224
  isDirectory: () => stats.isDirectory(),
2211
2225
  size: stats.size,
2212
2226
  mtimeMs: stats.mtimeMs,
2213
- ctimeMs: stats.ctimeMs
2227
+ ctimeMs: stats.ctimeMs,
2228
+ mode: stats.mode
2214
2229
  };
2215
2230
  } catch (error) {
2216
2231
  if (this.isEnoent(error))
@@ -2221,8 +2236,13 @@ class NodeFileSystem {
2221
2236
  async exists(filePath) {
2222
2237
  return existsSync(filePath);
2223
2238
  }
2224
- async mkdir(dirPath) {
2225
- await fs.mkdir(dirPath, { recursive: true });
2239
+ async mkdir(dirPath, options) {
2240
+ await fs.mkdir(dirPath, { recursive: true, mode: options?.mode });
2241
+ }
2242
+ async chmod(targetPath, mode) {
2243
+ if (process.platform === "win32")
2244
+ return;
2245
+ await fs.chmod(targetPath, mode);
2226
2246
  }
2227
2247
  async acquireLock(lockPath) {
2228
2248
  const canonicalPath = await this.canonicalizeLockTarget(lockPath);
@@ -2372,7 +2392,7 @@ class NodeFileSystem {
2372
2392
  async getTempDir() {
2373
2393
  return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
2374
2394
  }
2375
- async copyDirectory(sourcePath, destPath) {
2395
+ async copyDirectory(sourcePath, destPath, options) {
2376
2396
  const sourceStats = await this.stat(sourcePath);
2377
2397
  if (!sourceStats) {
2378
2398
  throw new Error(`Source directory does not exist: ${sourcePath}`);
@@ -2389,7 +2409,9 @@ class NodeFileSystem {
2389
2409
  if (!entryStats)
2390
2410
  continue;
2391
2411
  if (entryStats.isDirectory()) {
2392
- await this.copyDirectory(srcEntry, destEntry);
2412
+ if (options?.skipDirectoryNames?.includes(entry))
2413
+ continue;
2414
+ await this.copyDirectory(srcEntry, destEntry, options);
2393
2415
  } else if (entryStats.isFile()) {
2394
2416
  const content = await this.readFile(srcEntry);
2395
2417
  if (content !== null) {
@@ -2452,13 +2474,15 @@ var ProjectDimensions = {
2452
2474
  SolutionKey: "SolutionKey",
2453
2475
  SolutionProjectKey: "SolutionProjectKey",
2454
2476
  SolutionIdentityStatus: "SolutionIdentityStatus",
2455
- PreviousSolutionKey: "PreviousSolutionKey"
2477
+ PreviousSolutionKey: "PreviousSolutionKey",
2478
+ PreviousProjectKey: "PreviousProjectKey"
2456
2479
  };
2457
2480
  var GUID_KEY_DIMENSIONS = new Set([
2458
2481
  ProjectDimensions.ProjectKey,
2459
2482
  ProjectDimensions.SolutionKey,
2460
2483
  ProjectDimensions.SolutionProjectKey,
2461
- ProjectDimensions.PreviousSolutionKey
2484
+ ProjectDimensions.PreviousSolutionKey,
2485
+ ProjectDimensions.PreviousProjectKey
2462
2486
  ]);
2463
2487
  var ShipDimensions = {
2464
2488
  ShipKind: "ShipKind",
@@ -2612,9 +2636,7 @@ async function withinProjectIdentityBudget(work, onTimeout) {
2612
2636
  }
2613
2637
  }
2614
2638
 
2615
- // ../../common/src/telemetry/pseudonymize.ts
2616
- var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2617
- var PSEUDONYM_HEX_LENGTH = 32;
2639
+ // ../../common/src/sha256.ts
2618
2640
  var SHA256_K = new Uint32Array([
2619
2641
  1116352408,
2620
2642
  1899447441,
@@ -2694,7 +2716,7 @@ var SHA256_INITIAL_STATE = new Uint32Array([
2694
2716
  function rotr(value, bits) {
2695
2717
  return (value >>> bits | value << 32 - bits) >>> 0;
2696
2718
  }
2697
- function sha256Hex(input) {
2719
+ function sha256Words(input) {
2698
2720
  const bytes = new TextEncoder().encode(input);
2699
2721
  const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
2700
2722
  const buffer = new Uint8Array(paddedLength);
@@ -2750,12 +2772,19 @@ function sha256Hex(input) {
2750
2772
  state[6] = state[6] + g >>> 0;
2751
2773
  state[7] = state[7] + h >>> 0;
2752
2774
  }
2775
+ return state;
2776
+ }
2777
+ function sha256Hex(input) {
2753
2778
  let hex = "";
2754
- for (const word of state) {
2779
+ for (const word of sha256Words(input)) {
2755
2780
  hex += word.toString(16).padStart(8, "0");
2756
2781
  }
2757
2782
  return hex;
2758
2783
  }
2784
+
2785
+ // ../../common/src/telemetry/pseudonymize.ts
2786
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2787
+ var PSEUDONYM_HEX_LENGTH = 32;
2759
2788
  function resolveSha256Hex() {
2760
2789
  try {
2761
2790
  const nodeCrypto = __require("node:crypto");
@@ -3151,13 +3180,25 @@ function settlePromiseLike(thenable) {
3151
3180
  return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
3152
3181
  }
3153
3182
 
3183
+ // ../../common/src/result-types.ts
3184
+ var RESULTS = {
3185
+ Success: "Success",
3186
+ Failure: "Failure",
3187
+ ConfigError: "ConfigError",
3188
+ AuthenticationError: "AuthenticationError",
3189
+ ValidationError: "ValidationError",
3190
+ TimeoutError: "TimeoutError"
3191
+ };
3192
+
3154
3193
  // ../../common/src/error-codes.ts
3155
3194
  var CLI_ERROR_CODES = [
3156
3195
  "invalid_argument",
3196
+ "confirmation_required",
3157
3197
  "authentication_required",
3158
3198
  "permission_denied",
3159
3199
  "local_permission_denied",
3160
3200
  "not_found",
3201
+ "not_enabled",
3161
3202
  "rate_limited",
3162
3203
  "network_error",
3163
3204
  "timeout",
@@ -3196,6 +3237,12 @@ function carriedRetry(error) {
3196
3237
  const retry = error.retry;
3197
3238
  return isRetryHint(retry) ? retry : undefined;
3198
3239
  }
3240
+ function carriedResult(error) {
3241
+ if (!error || typeof error !== "object")
3242
+ return;
3243
+ const result = error.result;
3244
+ return typeof result === "string" && result !== RESULTS.Success && Object.values(RESULTS).includes(result) ? result : undefined;
3245
+ }
3199
3246
  function defaultRetryForErrorCode(errorCode) {
3200
3247
  switch (errorCode) {
3201
3248
  case "network_error":
@@ -3585,6 +3632,8 @@ async function extractErrorDetails(error, options) {
3585
3632
  }
3586
3633
  if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
3587
3634
  context.errorCode = parsedBody.errorCode;
3635
+ } else if (typeof parsedBody?.errorCode === "number") {
3636
+ context.errorCode = String(parsedBody.errorCode);
3588
3637
  } else if (parsedBody?.code && typeof parsedBody.code === "string") {
3589
3638
  context.errorCode = parsedBody.code;
3590
3639
  }
@@ -3645,15 +3694,6 @@ async function extractErrorMessage(error, options) {
3645
3694
  const { message } = await extractErrorDetails(error, options);
3646
3695
  return message;
3647
3696
  }
3648
- // ../../common/src/result-types.ts
3649
- var RESULTS = {
3650
- Success: "Success",
3651
- Failure: "Failure",
3652
- ConfigError: "ConfigError",
3653
- AuthenticationError: "AuthenticationError",
3654
- ValidationError: "ValidationError",
3655
- TimeoutError: "TimeoutError"
3656
- };
3657
3697
  // ../../../node_modules/commander/index.js
3658
3698
  var exports_commander = {};
3659
3699
  __exportCjs(exports_commander, {
@@ -4086,7 +4126,10 @@ var AUTH_ERROR_CODES = new Set([
4086
4126
  var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
4087
4127
  "local_permission_denied"
4088
4128
  ]);
4089
- var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
4129
+ var VALIDATION_ERROR_CODES = new Set([
4130
+ "invalid_argument",
4131
+ "confirmation_required"
4132
+ ]);
4090
4133
  var NETWORK_HTTP_ERROR_CODES = new Set([
4091
4134
  "network_error",
4092
4135
  "rate_limited",
@@ -4312,6 +4355,109 @@ var CommonTelemetryEvents = {
4312
4355
  ShipSucceeded: "Cli.ShipSucceeded"
4313
4356
  };
4314
4357
 
4358
+ // ../../common/src/telemetry/global-telemetry-properties.ts
4359
+ var telemetryPropsSlot = singleton("TelemetryDefaultProps");
4360
+ function getGlobalTelemetryProperties() {
4361
+ return telemetryPropsSlot.get();
4362
+ }
4363
+
4364
+ // ../../common/src/telemetry/trace-context.ts
4365
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
4366
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
4367
+ function getProcessEnv() {
4368
+ return globalThis.process?.env;
4369
+ }
4370
+ function parseInboundTraceparent(value) {
4371
+ if (!value) {
4372
+ return;
4373
+ }
4374
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
4375
+ if (!match) {
4376
+ return;
4377
+ }
4378
+ const [, traceId, parentSpanId] = match;
4379
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
4380
+ return;
4381
+ }
4382
+ return { traceId, parentSpanId };
4383
+ }
4384
+ function getInboundTraceContext() {
4385
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
4386
+ }
4387
+
4388
+ // ../../common/src/telemetry/session-id.ts
4389
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
4390
+ var SESSION_ID_MAX_LENGTH = 64;
4391
+ var RANDOM_SESSION_ID_LENGTH = 32;
4392
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
4393
+ var CONTROL_CHARACTERS = /\p{Cc}/gu;
4394
+ var INHERITED_SESSION_SOURCES = [
4395
+ { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
4396
+ { envVar: "CODEX_THREAD_ID", source: "codex" },
4397
+ { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
4398
+ { envVar: "TERM_SESSION_ID", source: "terminal" },
4399
+ { envVar: "WT_SESSION", source: "terminal" }
4400
+ ];
4401
+ var telemetrySessionSlot = singleton("TelemetrySession");
4402
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
4403
+ function getProcessEnv2() {
4404
+ return globalThis.process?.env;
4405
+ }
4406
+ function normalizeSessionId(value) {
4407
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
4408
+ return;
4409
+ }
4410
+ const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
4411
+ return cleaned || undefined;
4412
+ }
4413
+ function getConfiguredTelemetrySessionId() {
4414
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
4415
+ }
4416
+ function getInheritedSession(env) {
4417
+ for (const candidate of INHERITED_SESSION_SOURCES) {
4418
+ const handle = normalizeSessionId(env[candidate.envVar]);
4419
+ if (handle) {
4420
+ return { id: handle, source: candidate.source };
4421
+ }
4422
+ }
4423
+ return;
4424
+ }
4425
+ function generateRandomSession() {
4426
+ const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
4427
+ crypto.getRandomValues(bytes);
4428
+ let hex = "";
4429
+ for (const byte of bytes) {
4430
+ hex += byte.toString(16).padStart(2, "0");
4431
+ }
4432
+ return { id: hex, source: "random" };
4433
+ }
4434
+ function resolveTelemetrySession() {
4435
+ const existing = telemetrySessionSlot.get();
4436
+ if (existing) {
4437
+ return existing;
4438
+ }
4439
+ const declaredHandle = getConfiguredTelemetrySessionId();
4440
+ const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
4441
+ telemetrySessionSlot.set(resolved);
4442
+ return resolved;
4443
+ }
4444
+ function getTelemetrySessionId() {
4445
+ return resolveTelemetrySession().id;
4446
+ }
4447
+ function getTelemetrySessionSource() {
4448
+ return resolveTelemetrySession().source;
4449
+ }
4450
+ function getTelemetryOperationId() {
4451
+ const existing = telemetryOperationIdSlot.get();
4452
+ if (existing) {
4453
+ return existing;
4454
+ }
4455
+ const inboundTraceId = getInboundTraceContext()?.traceId;
4456
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
4457
+ telemetryOperationIdSlot.set(generated);
4458
+ return generated;
4459
+ }
4460
+
4315
4461
  // ../../common/src/registry.ts
4316
4462
  import { execFileSync } from "node:child_process";
4317
4463
  function readRegistryValue(keyPath, valueName) {
@@ -4533,108 +4679,6 @@ class NodeContextStorage {
4533
4679
  return this.storage.getStore();
4534
4680
  }
4535
4681
  }
4536
- // ../../common/src/telemetry/trace-context.ts
4537
- var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
4538
- var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
4539
- function getProcessEnv() {
4540
- return globalThis.process?.env;
4541
- }
4542
- function parseInboundTraceparent(value) {
4543
- if (!value) {
4544
- return;
4545
- }
4546
- const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
4547
- if (!match) {
4548
- return;
4549
- }
4550
- const [, traceId, parentSpanId] = match;
4551
- if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
4552
- return;
4553
- }
4554
- return { traceId, parentSpanId };
4555
- }
4556
- function getInboundTraceContext() {
4557
- return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
4558
- }
4559
-
4560
- // ../../common/src/telemetry/session-id.ts
4561
- var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
4562
- var SESSION_ID_MAX_LENGTH = 64;
4563
- var RANDOM_SESSION_ID_LENGTH = 32;
4564
- var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
4565
- var CONTROL_CHARACTERS = /\p{Cc}/gu;
4566
- var INHERITED_SESSION_SOURCES = [
4567
- { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
4568
- { envVar: "CODEX_THREAD_ID", source: "codex" },
4569
- { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
4570
- { envVar: "TERM_SESSION_ID", source: "terminal" },
4571
- { envVar: "WT_SESSION", source: "terminal" }
4572
- ];
4573
- var telemetrySessionSlot = singleton("TelemetrySession");
4574
- var telemetryOperationIdSlot = singleton("TelemetryOperationId");
4575
- function getProcessEnv2() {
4576
- return globalThis.process?.env;
4577
- }
4578
- function normalizeSessionId(value) {
4579
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
4580
- return;
4581
- }
4582
- const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
4583
- return cleaned || undefined;
4584
- }
4585
- function getConfiguredTelemetrySessionId() {
4586
- return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
4587
- }
4588
- function getInheritedSession(env) {
4589
- for (const candidate of INHERITED_SESSION_SOURCES) {
4590
- const handle = normalizeSessionId(env[candidate.envVar]);
4591
- if (handle) {
4592
- return { id: handle, source: candidate.source };
4593
- }
4594
- }
4595
- return;
4596
- }
4597
- function generateRandomSession() {
4598
- const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
4599
- crypto.getRandomValues(bytes);
4600
- let hex = "";
4601
- for (const byte of bytes) {
4602
- hex += byte.toString(16).padStart(2, "0");
4603
- }
4604
- return { id: hex, source: "random" };
4605
- }
4606
- function resolveTelemetrySession() {
4607
- const existing = telemetrySessionSlot.get();
4608
- if (existing) {
4609
- return existing;
4610
- }
4611
- const declaredHandle = getConfiguredTelemetrySessionId();
4612
- const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
4613
- telemetrySessionSlot.set(resolved);
4614
- return resolved;
4615
- }
4616
- function getTelemetrySessionId() {
4617
- return resolveTelemetrySession().id;
4618
- }
4619
- function getTelemetrySessionSource() {
4620
- return resolveTelemetrySession().source;
4621
- }
4622
- function getTelemetryOperationId() {
4623
- const existing = telemetryOperationIdSlot.get();
4624
- if (existing) {
4625
- return existing;
4626
- }
4627
- const inboundTraceId = getInboundTraceContext()?.traceId;
4628
- const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
4629
- telemetryOperationIdSlot.set(generated);
4630
- return generated;
4631
- }
4632
- // ../../common/src/telemetry/global-telemetry-properties.ts
4633
- var telemetryPropsSlot = singleton("TelemetryDefaultProps");
4634
- function getGlobalTelemetryProperties() {
4635
- return telemetryPropsSlot.get();
4636
- }
4637
-
4638
4682
  // ../../common/src/telemetry/span-clock.ts
4639
4683
  function startSpanClock() {
4640
4684
  const started = performance.now();
@@ -4848,6 +4892,7 @@ var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
4848
4892
  // ../../common/src/telemetry/telemetry-init.ts
4849
4893
  var telemetryInstanceSlot = singleton("TelemetryService");
4850
4894
  var DEFAULT_AI_CONNECTION_STRING = atob("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj");
4895
+ var browserProviderSlot = singleton("BrowserAppInsightsTelemetryProvider");
4851
4896
  function getGlobalTelemetryInstance() {
4852
4897
  const existing = telemetryInstanceSlot.get();
4853
4898
  if (existing && typeof existing === "object" && "trackEvent" in existing && typeof existing.trackEvent === "function") {
@@ -5031,7 +5076,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
5031
5076
  const pagedRows = extractPagedRows(data.Data);
5032
5077
  const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
5033
5078
  items.forEach((item) => {
5034
- const values = Object.values(item).map((v) => v ?? "").join("\t");
5079
+ const values = item === null || typeof item !== "object" ? String(item ?? "") : Object.values(item).map((v) => v ?? "").join("\t");
5035
5080
  logFn(values);
5036
5081
  });
5037
5082
  } else {
@@ -5046,7 +5091,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
5046
5091
  default: {
5047
5092
  const hasData = "Data" in data && data.Data != null;
5048
5093
  const pagedRows = hasData ? extractPagedRows(data.Data) : null;
5049
- const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
5094
+ const resolvedRows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
5095
+ const rows = resolvedRows && isPrimitiveArray(resolvedRows) ? resolvedRows.map((entry) => ({ Value: entry })) : resolvedRows;
5050
5096
  if (hasData && !(rows !== null && rows.length === 0)) {
5051
5097
  const logValue = data.Log;
5052
5098
  if (rows !== null) {
@@ -5103,6 +5149,9 @@ function printTable(data, logFn, externalLogValue, tableRowStyle) {
5103
5149
  function isPlainObjectArray(value) {
5104
5150
  return Array.isArray(value) && value.length > 0 && value.every(isPlainRecord);
5105
5151
  }
5152
+ function isPrimitiveArray(value) {
5153
+ return Array.isArray(value) && value.length > 0 && value.every((entry) => entry === null || typeof entry !== "object");
5154
+ }
5106
5155
  function isNonEmptyPlainObject(value) {
5107
5156
  return isPlainRecord(value) && Object.keys(value).length > 0;
5108
5157
  }
@@ -5449,12 +5498,12 @@ class FilterEvaluationError extends Error {
5449
5498
  instructions;
5450
5499
  retry = "RetryWillNotFix";
5451
5500
  result = RESULTS.ValidationError;
5452
- constructor(filter, cause) {
5501
+ constructor(filter, cause, hint) {
5453
5502
  const underlying = cause instanceof Error ? cause.message : String(cause);
5454
- super(`Filter '${filter}' failed to evaluate: ${underlying}`);
5503
+ super(`Filter '${filter}' failed to evaluate: ${underlying}` + (hint ? ` ${hint.detail}` : ""));
5455
5504
  this.name = "FilterEvaluationError";
5456
5505
  this.filter = filter;
5457
- 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(@)'.";
5506
+ 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(@)'.";
5458
5507
  }
5459
5508
  }
5460
5509
 
@@ -5576,6 +5625,93 @@ function nameList(names, cap = 12) {
5576
5625
  const rest = names.length - shown.length;
5577
5626
  return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
5578
5627
  }
5628
+ function notFieldsOn(names, scope) {
5629
+ return `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
5630
+ }
5631
+ function failingFieldRead(ast, isList, fn, argIndex) {
5632
+ const [left, right, condition] = ast.children ?? [];
5633
+ let scopes = [];
5634
+ if (!isList) {
5635
+ scopes = [ast];
5636
+ } else if (ast.type === "FilterProjection" && left?.type === "Identity") {
5637
+ scopes = [condition, right];
5638
+ } else if (ast.type === "Projection" && (left?.type === "Identity" || left?.type === "Flatten" && left.children?.[0]?.type === "Identity")) {
5639
+ scopes = [right];
5640
+ }
5641
+ const reads = new Set;
5642
+ let tracked = 0;
5643
+ const visit = (node) => {
5644
+ if (!node)
5645
+ return;
5646
+ switch (node.type) {
5647
+ case "Function": {
5648
+ const arg = node.children?.[argIndex - 1];
5649
+ if (node.name === fn && arg?.type === "Field" && arg.name) {
5650
+ reads.add(arg.name);
5651
+ tracked++;
5652
+ }
5653
+ node.children?.forEach(visit);
5654
+ return;
5655
+ }
5656
+ case "AndExpression":
5657
+ case "OrExpression":
5658
+ case "NotExpression":
5659
+ case "Comparator":
5660
+ case "MultiSelectList":
5661
+ case "MultiSelectHash":
5662
+ node.children?.forEach(visit);
5663
+ return;
5664
+ case "KeyValuePair":
5665
+ visit(node.value);
5666
+ return;
5667
+ }
5668
+ };
5669
+ scopes.forEach(visit);
5670
+ const calls = (node) => {
5671
+ if (node === null || typeof node !== "object")
5672
+ return 0;
5673
+ const own = node.type === "Function" && node.name === fn ? 1 : 0;
5674
+ const next = node.type === "KeyValuePair" ? [node.value] : node.children ?? [];
5675
+ return own + next.reduce((sum, child) => sum + calls(child), 0);
5676
+ };
5677
+ return reads.size === 1 && tracked === calls(ast) ? [...reads][0] : undefined;
5678
+ }
5679
+ function fieldExpression(name) {
5680
+ return /^[A-Za-z_]\w*$/.test(name) ? name : JSON.stringify(name);
5681
+ }
5682
+ function evaluationHint(codec, filter, data, cause) {
5683
+ const underlying = cause instanceof Error ? cause.message : String(cause);
5684
+ const failure = /\b(\w+)\(\) expected argument (\d+) to be type (\S+) but received type null\b/.exec(underlying);
5685
+ if (!failure)
5686
+ return;
5687
+ const [, fn, position, expected] = failure;
5688
+ const name = failingFieldRead(codec.compile(filter), Array.isArray(data), fn, Number(position));
5689
+ if (name === undefined)
5690
+ return;
5691
+ const present = availableFields(data);
5692
+ if (present.length === 0)
5693
+ return;
5694
+ const scope = `${countRecords(data)} record(s)`;
5695
+ if (!present.includes(name)) {
5696
+ return {
5697
+ detail: `${notFieldsOn([name], scope)}. Available fields: ${nameList(present)}.`,
5698
+ instructions: "Use a field the records have; names are case-sensitive."
5699
+ };
5700
+ }
5701
+ const records = Array.isArray(data) ? data : [data];
5702
+ const unset = records.filter((r) => r?.[name] == null).length;
5703
+ const field = fieldExpression(name);
5704
+ let fallback;
5705
+ if (expected.split(",").includes("string")) {
5706
+ fallback = "''";
5707
+ } else if (expected.split(",").includes("array")) {
5708
+ fallback = "`[]`";
5709
+ }
5710
+ return {
5711
+ detail: `\`${name}\` is null or missing on ${unset} of the ${scope} it read.`,
5712
+ 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.`
5713
+ };
5714
+ }
5579
5715
  function buildFilterWarning(filter, data, outcome) {
5580
5716
  const present = availableFields(data);
5581
5717
  const refs = referencedFields(filter);
@@ -5583,7 +5719,7 @@ function buildFilterWarning(filter, data, outcome) {
5583
5719
  const unchecked = refs.nested.filter((name) => !present.includes(name));
5584
5720
  const count = countRecords(data);
5585
5721
  const scope = `${count} record(s)`;
5586
- const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
5722
+ const isNotAField = (names) => notFieldsOn(names, scope);
5587
5723
  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" : "";
5588
5724
  const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
5589
5725
  let detail;
@@ -5634,7 +5770,8 @@ function applyFilter(data, filter, onWarning) {
5634
5770
  try {
5635
5771
  result = codec.search(data, filter);
5636
5772
  } catch (err) {
5637
- throw new FilterEvaluationError(filter, err);
5773
+ const [, hint] = catchError(() => evaluationHint(codec, filter, data, err));
5774
+ throw new FilterEvaluationError(filter, err, hint);
5638
5775
  }
5639
5776
  const inputCount = countRecords(data);
5640
5777
  const warn = (outcome) => {
@@ -6525,7 +6662,7 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
6525
6662
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
6526
6663
  const typed = error;
6527
6664
  const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
6528
- const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
6665
+ const customResult = carriedResult(error);
6529
6666
  const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
6530
6667
  const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
6531
6668
  const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
@@ -6887,6 +7024,8 @@ var FAILURE_STATUSES = new Set([
6887
7024
  "canceled",
6888
7025
  "stopped"
6889
7026
  ]);
7027
+ // ../../common/src/relayed-output.ts
7028
+ var RELAYED_OUTPUT_SYMBOL = Symbol.for("@uipath/common/relayed-output");
6890
7029
  // ../../common/src/screen-logger.ts
6891
7030
  var ScreenLogger;
6892
7031
  ((ScreenLogger) => {
@@ -6934,6 +7073,8 @@ function settlePromiseLike2(thenable) {
6934
7073
  // ../../auth/src/constants.ts
6935
7074
  var UIPATH_HOME_DIR = ".uipath";
6936
7075
  var AUTH_FILENAME = ".auth";
7076
+ var AUTH_FILE_MODE = 384;
7077
+ var AUTH_DIR_MODE = 448;
6937
7078
  var DEFAULT_BASE_URL = "https://cloud.uipath.com";
6938
7079
  var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
6939
7080
 
@@ -7757,6 +7898,38 @@ var loadEnvFileAsync = async ({ envPath }) => {
7757
7898
  }
7758
7899
  return parseEnvContent(content);
7759
7900
  };
7901
+ var findAuthHomeDir = (fs, dir) => {
7902
+ let current = dir;
7903
+ for (;; ) {
7904
+ if (fs.path.basename(current) === UIPATH_HOME_DIR)
7905
+ return current;
7906
+ const parent = fs.path.dirname(current);
7907
+ if (parent === current)
7908
+ return;
7909
+ current = parent;
7910
+ }
7911
+ };
7912
+ var TEMP_FILE_ATTEMPTS = 5;
7913
+ var isFileExists = (error) => error instanceof Error && error.code === "EEXIST";
7914
+ var writeTempFile = async (fs, targetPath, content) => {
7915
+ for (let attempt = 1;; attempt++) {
7916
+ const tempPath = `${targetPath}.${crypto.randomUUID()}.tmp`;
7917
+ try {
7918
+ await fs.writeFile(tempPath, content, {
7919
+ mode: AUTH_FILE_MODE,
7920
+ exclusive: true
7921
+ });
7922
+ return tempPath;
7923
+ } catch (error) {
7924
+ if (!isFileExists(error)) {
7925
+ await fs.rm(tempPath).catch(() => {});
7926
+ throw error;
7927
+ }
7928
+ if (attempt === TEMP_FILE_ATTEMPTS)
7929
+ throw error;
7930
+ }
7931
+ }
7932
+ };
7760
7933
  var saveEnvFileAsync = async ({
7761
7934
  envPath,
7762
7935
  data,
@@ -7784,10 +7957,18 @@ var saveEnvFileAsync = async ({
7784
7957
  `)}
7785
7958
  `;
7786
7959
  const dir = fs.path.dirname(absolutePath);
7787
- await fs.mkdir(dir);
7788
- const tempPath = `${absolutePath}.tmp`;
7789
- await fs.writeFile(tempPath, content);
7790
- await fs.rename(tempPath, absolutePath);
7960
+ await fs.mkdir(dir, { mode: AUTH_DIR_MODE });
7961
+ const authHomeDir = findAuthHomeDir(fs, dir);
7962
+ if (authHomeDir !== undefined) {
7963
+ await fs.chmod?.(authHomeDir, AUTH_DIR_MODE);
7964
+ }
7965
+ const tempPath = await writeTempFile(fs, absolutePath, content);
7966
+ try {
7967
+ await fs.rename(tempPath, absolutePath);
7968
+ } catch (error) {
7969
+ await fs.rm(tempPath).catch(() => {});
7970
+ throw error;
7971
+ }
7791
7972
  };
7792
7973
 
7793
7974
  // ../../auth/src/loginStatus.ts
@@ -8418,11 +8599,10 @@ function buildUrl(baseUrl, path, query) {
8418
8599
  const qs = search.toString();
8419
8600
  return qs ? `${trimmed}${suffix}?${qs}` : `${trimmed}${suffix}`;
8420
8601
  }
8421
- async function readErrorBody(response) {
8602
+ async function httpError(response) {
8422
8603
  const text = await response.text().catch(() => "");
8423
- if (!text)
8424
- return `${response.status} ${response.statusText}`;
8425
- return `${response.status} ${response.statusText}: ${text.slice(0, 1000)}`;
8604
+ const reason = response.statusText || "Request failed";
8605
+ return Object.assign(new Error(text ? `${reason}: ${text.slice(0, 1000)}` : reason), { status: response.status });
8426
8606
  }
8427
8607
  async function createAiHttpContext(service, options) {
8428
8608
  const { auth, bearerToken } = await resolveAuth(options);
@@ -8460,10 +8640,11 @@ async function createAiHttpContext(service, options) {
8460
8640
  const response = await fetch(url, {
8461
8641
  method: req.method,
8462
8642
  headers,
8463
- body: req.body !== undefined ? JSON.stringify(req.body) : undefined
8643
+ body: req.body !== undefined ? JSON.stringify(req.body) : undefined,
8644
+ signal: options?.signal
8464
8645
  });
8465
8646
  if (!response.ok) {
8466
- throw new Error(await readErrorBody(response));
8647
+ throw await httpError(response);
8467
8648
  }
8468
8649
  if (response.status === 204) {
8469
8650
  return;
@@ -8485,10 +8666,11 @@ async function createAiHttpContext(service, options) {
8485
8666
  const response = await fetch(url, {
8486
8667
  method: req.method,
8487
8668
  headers,
8488
- body: req.body !== undefined ? JSON.stringify(req.body) : undefined
8669
+ body: req.body !== undefined ? JSON.stringify(req.body) : undefined,
8670
+ signal: options?.signal
8489
8671
  });
8490
8672
  if (!response.ok) {
8491
- throw new Error(await readErrorBody(response));
8673
+ throw await httpError(response);
8492
8674
  }
8493
8675
  };
8494
8676
  return {
@@ -8630,4 +8812,4 @@ export {
8630
8812
  registerCommands
8631
8813
  };
8632
8814
 
8633
- //# debugId=EDD380CA6641CED664756E2164756E21
8815
+ //# debugId=CC97A54FDA98209364756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/llm-gateway-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.206.0-preview.301",
5
+ "version": "1.207.0-preview.305",
6
6
  "description": "CLI plugin for UiPath LLM Gateway model discovery.",
7
7
  "private": false,
8
8
  "repository": {
@@ -24,5 +24,5 @@
24
24
  "files": [
25
25
  "dist"
26
26
  ],
27
- "gitHead": "078afc3ef7ebf4c38353ee0059e321acf16a350d"
27
+ "gitHead": "1600aa89255c37c1b8bc68d9882c3395c1d5bff4"
28
28
  }