@uipath/llm-gateway-tool 1.202.0 → 1.203.0-preview.160

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 +285 -34
  2. package/package.json +3 -2
package/dist/tool.js CHANGED
@@ -2099,8 +2099,9 @@ var require_commander = __commonJS(function(exports) {
2099
2099
  // package.json
2100
2100
  var package_default = {
2101
2101
  name: "@uipath/llm-gateway-tool",
2102
+ author: "UiPath",
2102
2103
  license: "SEE LICENSE IN LICENSE.txt",
2103
- version: "1.202.0",
2104
+ version: "1.203.0-preview.160",
2104
2105
  description: "CLI plugin for UiPath LLM Gateway model discovery.",
2105
2106
  private: false,
2106
2107
  repository: {
@@ -2650,7 +2651,7 @@ var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{1
2650
2651
  var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
2651
2652
  var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
2652
2653
  var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
2653
- var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
2654
+ var PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
2654
2655
  var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
2655
2656
  var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
2656
2657
  var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
@@ -2697,7 +2698,7 @@ var QUOTED_LITERAL_PATTERN = new RegExp([
2697
2698
  `(?<![A-Za-z0-9])"(?:[^\\
2698
2699
  ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
2699
2700
  ].join("|"), "g");
2700
- var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
2701
+ var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
2701
2702
  var COLLAPSED_BODY = "{…}";
2702
2703
  var COLLAPSED_BODY_MARKER = "\x01body\x01";
2703
2704
  var MAX_BODY_NESTING = 8;
@@ -2712,10 +2713,13 @@ function collapseJsonBodies(text) {
2712
2713
  }
2713
2714
  return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
2714
2715
  }
2715
- var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
2716
+ var TRAILING_PROSE_PUNCT = `.,;:!?)]}>'"`;
2716
2717
  function peelTrailingPunctuation(match) {
2717
- const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
2718
- return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
2718
+ let end = match.length;
2719
+ while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
2720
+ end -= 1;
2721
+ }
2722
+ return [match.slice(0, end), match.slice(end)];
2719
2723
  }
2720
2724
  function redactUrl(raw) {
2721
2725
  try {
@@ -3018,6 +3022,22 @@ function parseHttpStatusFromMessage(message) {
3018
3022
  const status = Number(match[1]);
3019
3023
  return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
3020
3024
  }
3025
+ function findHttpStatusInGraph(error) {
3026
+ for (const node of walkErrorGraph(error)) {
3027
+ const response = node.response;
3028
+ const explicit = typeof node.status === "number" ? node.status : response?.status;
3029
+ if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
3030
+ return explicit;
3031
+ }
3032
+ if (typeof node.message === "string") {
3033
+ const parsed = parseHttpStatusFromMessage(node.message);
3034
+ if (parsed !== undefined && parsed >= 400) {
3035
+ return parsed;
3036
+ }
3037
+ }
3038
+ }
3039
+ return;
3040
+ }
3021
3041
  function isHtmlDocument(body) {
3022
3042
  return /^\s*(<!doctype html|<html\b)/i.test(body);
3023
3043
  }
@@ -3131,7 +3151,8 @@ async function extractErrorDetails(error, options) {
3131
3151
  }
3132
3152
  let message;
3133
3153
  let result = "Failure";
3134
- const classification = classifyError(status, error);
3154
+ const classificationStatus = status ?? findHttpStatusInGraph(error);
3155
+ const classification = classifyError(classificationStatus, error);
3135
3156
  let retry = classification.retry;
3136
3157
  if (status === 401) {
3137
3158
  message = DEFAULT_401;
@@ -3207,8 +3228,8 @@ async function extractErrorDetails(error, options) {
3207
3228
  details = describeThrownValue(error);
3208
3229
  }
3209
3230
  const context = {};
3210
- if (status) {
3211
- context.httpStatus = status;
3231
+ if (classificationStatus) {
3232
+ context.httpStatus = classificationStatus;
3212
3233
  }
3213
3234
  if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
3214
3235
  context.errorCode = parsedBody.errorCode;
@@ -3770,7 +3791,8 @@ function readRegistryValue(keyPath, valueName) {
3770
3791
  }
3771
3792
  const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
3772
3793
  encoding: "utf-8",
3773
- stdio: ["pipe", "pipe", "pipe"]
3794
+ stdio: ["pipe", "pipe", "pipe"],
3795
+ windowsHide: true
3774
3796
  }));
3775
3797
  if (error) {
3776
3798
  return "";
@@ -4452,28 +4474,32 @@ function isPlainRecord(value) {
4452
4474
  const prototype = Object.getPrototypeOf(value);
4453
4475
  return prototype === Object.prototype || prototype === null;
4454
4476
  }
4455
- function extractPagedRows(value) {
4477
+ function splitPagedEnvelope(value) {
4456
4478
  if (Array.isArray(value) || !isPlainRecord(value))
4457
4479
  return null;
4458
- const entries = Object.values(value);
4480
+ const entries = Object.entries(value);
4459
4481
  if (entries.length === 0)
4460
4482
  return null;
4461
- let rows = null;
4462
- let hasScalarSibling = false;
4463
- for (const entry of entries) {
4483
+ let found = null;
4484
+ const meta = Object.create(null);
4485
+ for (const [key, entry] of entries) {
4464
4486
  if (Array.isArray(entry)) {
4465
- if (rows !== null)
4487
+ if (found !== null)
4466
4488
  return null;
4467
- rows = entry;
4489
+ found = { key, rows: entry };
4468
4490
  } else if (entry !== null && typeof entry === "object") {
4469
4491
  return null;
4470
4492
  } else {
4471
- hasScalarSibling = true;
4493
+ meta[key] = entry;
4472
4494
  }
4473
4495
  }
4474
- if (rows === null || !hasScalarSibling)
4496
+ if (found === null || Object.keys(meta).length === 0)
4475
4497
  return null;
4476
- return rows;
4498
+ return { ...found, meta };
4499
+ }
4500
+ function extractPagedRows(value) {
4501
+ const paged = splitPagedEnvelope(value);
4502
+ return paged === null ? null : paged.rows;
4477
4503
  }
4478
4504
  function toLowerCamelCaseKey(key) {
4479
4505
  if (!key)
@@ -4577,6 +4603,9 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
4577
4603
  }
4578
4604
  break;
4579
4605
  }
4606
+ case "markdown":
4607
+ logFn(renderMarkdown(data));
4608
+ break;
4580
4609
  default: {
4581
4610
  const hasData = "Data" in data && data.Data != null;
4582
4611
  const pagedRows = hasData ? extractPagedRows(data.Data) : null;
@@ -4601,6 +4630,10 @@ function logOutput(data, format = "json", tableRowStyle) {
4601
4630
  printOutput(data, format, (msg) => sink.writeOut(`${msg}
4602
4631
  `), needsAsciiSafeJson(sink), styleFn);
4603
4632
  }
4633
+ var PLUMBING_KEYS = new Set(["code", "log"]);
4634
+ function isPlumbingKey(key) {
4635
+ return PLUMBING_KEYS.has(key.toLowerCase());
4636
+ }
4604
4637
  function cellToString(val) {
4605
4638
  return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
4606
4639
  }
@@ -4616,7 +4649,7 @@ function wrapText(text, width) {
4616
4649
  function printTable(data, logFn, externalLogValue, tableRowStyle) {
4617
4650
  if (data.length === 0)
4618
4651
  return;
4619
- const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
4652
+ const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
4620
4653
  const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
4621
4654
  const header = keys.map((key, i) => key.padEnd(maxWidths[i])).join(" | ");
4622
4655
  logFn(header);
@@ -4638,7 +4671,7 @@ function isNonEmptyPlainObject(value) {
4638
4671
  }
4639
4672
  var NESTED_INDENT = " ";
4640
4673
  function printVerticalTable(data, logFn = console.log, externalLogValue) {
4641
- const keys = Object.keys(data).filter((key) => !["code", "log"].includes(key.toLowerCase()));
4674
+ const keys = Object.keys(data).filter((key) => !isPlumbingKey(key));
4642
4675
  if (keys.length === 0)
4643
4676
  return;
4644
4677
  const isBlockValue = (value) => isPlainObjectArray(value) || isNonEmptyPlainObject(value);
@@ -4669,7 +4702,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
4669
4702
  function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
4670
4703
  if (data.length === 0)
4671
4704
  return;
4672
- const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
4705
+ const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
4673
4706
  if (keys.length === 0)
4674
4707
  return;
4675
4708
  if (!process.stdout.isTTY) {
@@ -4743,6 +4776,220 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
4743
4776
  logFn(`Log: ${externalLogValue}`);
4744
4777
  }
4745
4778
  }
4779
+ var MARKDOWN_MAX_CELL = 200;
4780
+ var MARKDOWN_MAX_DEPTH = 3;
4781
+ function markdownHeading(depth) {
4782
+ return "#".repeat(Math.min(3 + depth, 6));
4783
+ }
4784
+ var BACKTICK_RUN = /`+/g;
4785
+ function fencedBlock(text) {
4786
+ const first = text.trimStart()[0];
4787
+ const language = first === "<" ? "xml" : first === "{" || first === "[" ? "json" : "";
4788
+ const longestRun = Math.max(0, ...Array.from(text.matchAll(BACKTICK_RUN), (match) => match[0].length));
4789
+ const fence = "`".repeat(Math.max(3, longestRun + 1));
4790
+ return `${fence}${language}
4791
+ ${text}
4792
+ ${fence}`;
4793
+ }
4794
+ function collapseNewlineRuns(text) {
4795
+ return text.split(/(\s+)/).map((part, index) => index % 2 === 1 && part.includes(`
4796
+ `) ? " " : part).join("");
4797
+ }
4798
+ function markdownCell(value) {
4799
+ const text = value instanceof Date ? value.toISOString() : cellToString(value);
4800
+ return collapseNewlineRuns(text).replace(/\|/g, "\\|");
4801
+ }
4802
+ function markdownLabel(key) {
4803
+ return collapseNewlineRuns(key).replace(/[\\`*|]/g, "\\$&");
4804
+ }
4805
+ function withoutPlumbing(record) {
4806
+ const kept = Object.create(null);
4807
+ for (const [key, value] of Object.entries(record)) {
4808
+ if (!isPlumbingKey(key))
4809
+ kept[key] = value;
4810
+ }
4811
+ return kept;
4812
+ }
4813
+ function rowsWithoutPlumbing(rows) {
4814
+ return rows.map((row) => isPlainRecord(row) ? withoutPlumbing(row) : row);
4815
+ }
4816
+ function markdownTable(rows) {
4817
+ const columns = [];
4818
+ const seen = new Set;
4819
+ for (const row of rows) {
4820
+ for (const key of Object.keys(row)) {
4821
+ if (!seen.has(key)) {
4822
+ seen.add(key);
4823
+ columns.push(key);
4824
+ }
4825
+ }
4826
+ }
4827
+ if (columns.length === 0)
4828
+ return null;
4829
+ const cells = rows.map((row) => columns.map((key) => markdownCell(row[key])));
4830
+ if (cells.some((row) => row.some((c) => c.length > MARKDOWN_MAX_CELL))) {
4831
+ return null;
4832
+ }
4833
+ return [
4834
+ `| ${columns.map(markdownLabel).join(" | ")} |`,
4835
+ `| ${columns.map(() => "---").join(" | ")} |`,
4836
+ ...cells.map((row) => `| ${row.join(" | ")} |`)
4837
+ ].join(`
4838
+ `);
4839
+ }
4840
+ function extractMessageSequence(rows) {
4841
+ const messages = [];
4842
+ for (const row of rows) {
4843
+ const message = extractSingleMessage(row);
4844
+ if (message === null)
4845
+ return null;
4846
+ messages.push(message);
4847
+ }
4848
+ return messages.join(`
4849
+
4850
+ `);
4851
+ }
4852
+ function markdownRows(rows, depth) {
4853
+ if (rows.length === 0)
4854
+ return "(none)";
4855
+ if (!isPlainObjectArray(rows)) {
4856
+ return rows.map((item) => `- ${markdownCell(item)}`).join(`
4857
+ `);
4858
+ }
4859
+ const prose = extractMessageSequence(rows);
4860
+ if (prose !== null)
4861
+ return prose;
4862
+ const table = markdownTable(rows);
4863
+ if (table !== null)
4864
+ return table;
4865
+ if (depth >= MARKDOWN_MAX_DEPTH) {
4866
+ return fencedBlock(JSON.stringify(rows, null, 2));
4867
+ }
4868
+ return rows.map((row, index) => [
4869
+ `${markdownHeading(depth)} ${index + 1}`,
4870
+ markdownObject(row, depth + 1)
4871
+ ].join(`
4872
+
4873
+ `)).join(`
4874
+
4875
+ `);
4876
+ }
4877
+ function markdownObject(obj, depth) {
4878
+ const scalars = [];
4879
+ const blocks = [];
4880
+ for (const [key, value] of Object.entries(obj)) {
4881
+ if (value === undefined)
4882
+ continue;
4883
+ const label = markdownLabel(key);
4884
+ if (Array.isArray(value)) {
4885
+ blocks.push(`${markdownHeading(depth)} ${label}
4886
+
4887
+ ${markdownRows(value, depth + 1)}`);
4888
+ } else if (isNonEmptyPlainObject(value)) {
4889
+ const nested = depth < MARKDOWN_MAX_DEPTH ? markdownObject(value, depth + 1) : fencedBlock(JSON.stringify(value, null, 2));
4890
+ if (nested !== "") {
4891
+ blocks.push(`${markdownHeading(depth)} ${label}
4892
+
4893
+ ${nested}`);
4894
+ }
4895
+ } else if (typeof value === "string" && value.includes(`
4896
+ `)) {
4897
+ blocks.push(`**${label}:**
4898
+
4899
+ ${fencedBlock(value)}`);
4900
+ } else {
4901
+ scalars.push(`**${label}:** ${markdownCell(value)}`);
4902
+ }
4903
+ }
4904
+ const sections = scalars.length > 0 ? [scalars.join(`
4905
+ `)] : [];
4906
+ sections.push(...blocks);
4907
+ return sections.join(`
4908
+
4909
+ `);
4910
+ }
4911
+ function extractSingleMessage(payload) {
4912
+ if (!isPlainRecord(payload))
4913
+ return null;
4914
+ const keys = Object.keys(payload);
4915
+ if (keys.length !== 1 || keys[0].toLowerCase() !== "message")
4916
+ return null;
4917
+ const value = payload[keys[0]];
4918
+ return typeof value === "string" ? value : null;
4919
+ }
4920
+ function markdownPayload(payload) {
4921
+ const message = extractSingleMessage(payload);
4922
+ if (message !== null)
4923
+ return message;
4924
+ if (Array.isArray(payload)) {
4925
+ return markdownRows(rowsWithoutPlumbing(payload), 0);
4926
+ }
4927
+ const visible = withoutPlumbing(payload);
4928
+ const paged = splitPagedEnvelope(visible);
4929
+ if (paged !== null) {
4930
+ const meta = markdownObject(paged.meta, 0);
4931
+ const rows = `${markdownHeading(0)} ${markdownLabel(paged.key)}
4932
+
4933
+ ${markdownRows(rowsWithoutPlumbing(paged.rows), 1)}`;
4934
+ return meta === "" ? rows : `${meta}
4935
+
4936
+ ${rows}`;
4937
+ }
4938
+ return markdownObject(visible, 0);
4939
+ }
4940
+ function isPaginationWorthShowing(value) {
4941
+ if (typeof value !== "object" || value === null)
4942
+ return false;
4943
+ const page = value;
4944
+ return page.HasMore === true || typeof page.Offset === "number" && page.Offset > 0;
4945
+ }
4946
+ function markdownEnvelopeNotes(data) {
4947
+ const envelope = data;
4948
+ const notes = [];
4949
+ const warning = envelope.Warning;
4950
+ if (typeof warning === "string" && warning !== "") {
4951
+ notes.push(`> **Warning:** ${warning}`);
4952
+ }
4953
+ const instructions = envelope.Instructions;
4954
+ if (typeof instructions === "string" && instructions !== "") {
4955
+ notes.push(`> ${instructions}`);
4956
+ }
4957
+ const pagination = envelope.Pagination;
4958
+ if (isPaginationWorthShowing(pagination)) {
4959
+ const body = markdownObject(pagination, 1);
4960
+ if (body !== "") {
4961
+ notes.push(`${markdownHeading(0)} Pagination
4962
+
4963
+ ${body}`);
4964
+ }
4965
+ }
4966
+ const log = envelope.Log;
4967
+ if (typeof log === "string" && log !== "") {
4968
+ notes.push(`**Log:** ${log}`);
4969
+ }
4970
+ return notes;
4971
+ }
4972
+ function renderMarkdown(data) {
4973
+ if (data.Result !== RESULTS.Success) {
4974
+ const failure = data;
4975
+ const sections = [`**Failed:** ${failure.Message}`];
4976
+ if (failure.Data != null) {
4977
+ sections.push(markdownPayload(failure.Data));
4978
+ }
4979
+ if (failure.Instructions) {
4980
+ sections.push(`> ${failure.Instructions}`);
4981
+ }
4982
+ return sections.filter((section) => section !== "").join(`
4983
+
4984
+ `);
4985
+ }
4986
+ if (!("Data" in data) || data.Data == null) {
4987
+ return markdownObject(withoutPlumbing(data), 0);
4988
+ }
4989
+ return [markdownPayload(data.Data), ...markdownEnvelopeNotes(data)].filter((section) => section !== "").join(`
4990
+
4991
+ `);
4992
+ }
4746
4993
  function toYaml(data) {
4747
4994
  const codec = getYamlCodec();
4748
4995
  if (!codec) {
@@ -7346,16 +7593,7 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
7346
7593
  errorMessage: location.source === "absolute" ? `Environment file not found: ${envFilePath}` : `Unable to locate environment file: ${envFilePath}. Run 'uip login' to authenticate.`
7347
7594
  };
7348
7595
  };
7349
- var loadEnvFileAsync = async ({ envPath }) => {
7350
- const fs7 = getFileSystem2();
7351
- const absolutePath = fs7.path.isAbsolute(envPath) ? envPath : fs7.path.join(fs7.env.cwd(), envPath);
7352
- if (!await fs7.exists(absolutePath)) {
7353
- throw new Error(`Environment file not found: ${envPath}`);
7354
- }
7355
- const content = await fs7.readFile(absolutePath, "utf-8");
7356
- if (content === null) {
7357
- throw new Error(`Environment file not found: ${envPath}`);
7358
- }
7596
+ var parseEnvContent = (content) => {
7359
7597
  const env = {};
7360
7598
  for (const line of content.split(`
7361
7599
  `)) {
@@ -7376,6 +7614,18 @@ var loadEnvFileAsync = async ({ envPath }) => {
7376
7614
  }
7377
7615
  return env;
7378
7616
  };
7617
+ var loadEnvFileAsync = async ({ envPath }) => {
7618
+ const fs7 = getFileSystem2();
7619
+ const absolutePath = fs7.path.isAbsolute(envPath) ? envPath : fs7.path.join(fs7.env.cwd(), envPath);
7620
+ if (!await fs7.exists(absolutePath)) {
7621
+ throw new Error(`Environment file not found: ${envPath}`);
7622
+ }
7623
+ const content = await fs7.readFile(absolutePath, "utf-8");
7624
+ if (content === null) {
7625
+ throw new Error(`Environment file not found: ${envPath}`);
7626
+ }
7627
+ return parseEnvContent(content);
7628
+ };
7379
7629
  var saveEnvFileAsync = async ({
7380
7630
  envPath,
7381
7631
  data,
@@ -7882,6 +8132,7 @@ function normalizeTokenRefreshUnavailableFailure() {
7882
8132
  function errorMessage(error) {
7883
8133
  return error instanceof Error ? error.message : String(error);
7884
8134
  }
8135
+ init_src();
7885
8136
  init_constants();
7886
8137
  init_src();
7887
8138
  init_constants();
@@ -8147,4 +8398,4 @@ export {
8147
8398
  registerCommands
8148
8399
  };
8149
8400
 
8150
- //# debugId=3338808DD81E1EE864756E2164756E21
8401
+ //# debugId=C9C8CFCB9484B92C64756E2164756E21
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@uipath/llm-gateway-tool",
3
+ "author": "UiPath",
3
4
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "1.202.0",
5
+ "version": "1.203.0-preview.160",
5
6
  "description": "CLI plugin for UiPath LLM Gateway model discovery.",
6
7
  "private": false,
7
8
  "repository": {
@@ -23,5 +24,5 @@
23
24
  "files": [
24
25
  "dist"
25
26
  ],
26
- "gitHead": "23b5a7038ead7264439af18f8b807c7cc99a29d5"
27
+ "gitHead": "3a42062ba731afca4595ba9aa8a80afc9667528d"
27
28
  }