@uipath/llmgw-tool 1.202.1-preview.220 → 1.202.1-preview.238

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
  metadata,
5
5
  registerCommands
6
- } from "./tool-9sdprwfc.js";
6
+ } from "./tool-j1kf6hps.js";
7
7
  import"./tool-1de529jm.js";
8
8
 
9
9
  // src/index.ts
@@ -2100,7 +2100,7 @@ var require_commander = __commonJS(function(exports) {
2100
2100
  var package_default = {
2101
2101
  name: "@uipath/llmgw-tool",
2102
2102
  license: "SEE LICENSE IN LICENSE.txt",
2103
- version: "1.202.1-preview.220",
2103
+ version: "1.202.1-preview.238",
2104
2104
  description: "CLI plugin for UiPath AI Trust Layer Bring-Your-Own LLM connections.",
2105
2105
  private: false,
2106
2106
  repository: {
@@ -4787,7 +4787,165 @@ class FilterImplicitLimitError extends Error {
4787
4787
  this.instructions = "Pass --limit <n> to choose how many records the filter applies to. " + "To filter over all records, pass the command's maximum accepted --limit (see the option's description in --help).";
4788
4788
  }
4789
4789
  }
4790
- function applyFilter(data, filter) {
4790
+ function countRecords(data) {
4791
+ if (Array.isArray(data))
4792
+ return data.length;
4793
+ return data == null ? 0 : 1;
4794
+ }
4795
+ function availableFields(data) {
4796
+ const records = Array.isArray(data) ? data : [data];
4797
+ const keys = new Set;
4798
+ for (const record of records) {
4799
+ if (record && typeof record === "object" && !Array.isArray(record)) {
4800
+ for (const key of Object.keys(record))
4801
+ keys.add(key);
4802
+ }
4803
+ }
4804
+ return [...keys];
4805
+ }
4806
+ function decodeQuotedIdentifier(whole, inner) {
4807
+ const [error, decoded] = catchError(() => JSON.parse(whole));
4808
+ if (!error && typeof decoded === "string")
4809
+ return decoded;
4810
+ return inner.replace(/\\(.)/g, "$1");
4811
+ }
4812
+ function referencedFields(filter) {
4813
+ const top = new Set;
4814
+ const nested = new Set;
4815
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
4816
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
4817
+ const quoted = [];
4818
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
4819
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
4820
+ if (!isAlias) {
4821
+ quoted.push({
4822
+ name: decodeQuotedIdentifier(whole, name),
4823
+ index,
4824
+ tail: isPathTail(withoutValueLiterals, index)
4825
+ });
4826
+ }
4827
+ return `"${" ".repeat(whole.length - 2)}"`;
4828
+ });
4829
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
4830
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
4831
+ const place = (name, index, tail) => {
4832
+ if (tail || index >= rootEnd)
4833
+ nested.add(name);
4834
+ else
4835
+ top.add(name);
4836
+ };
4837
+ for (const entry of quoted)
4838
+ place(entry.name, entry.index, entry.tail);
4839
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
4840
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
4841
+ for (const match of identifiers) {
4842
+ const [, name, trailing] = match;
4843
+ if (trailing || reserved.has(name))
4844
+ continue;
4845
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
4846
+ }
4847
+ return {
4848
+ top: [...top],
4849
+ nested: [...nested].filter((name) => !top.has(name)),
4850
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
4851
+ };
4852
+ }
4853
+ function appearsBelowTopLevel(data, name) {
4854
+ let budget = 2000;
4855
+ const visit = (value, depth) => {
4856
+ if (budget-- <= 0 || depth > 4)
4857
+ return false;
4858
+ if (value === null || typeof value !== "object")
4859
+ return false;
4860
+ if (Array.isArray(value))
4861
+ return value.some((entry) => visit(entry, depth));
4862
+ const record = value;
4863
+ if (depth > 0 && Object.hasOwn(record, name))
4864
+ return true;
4865
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
4866
+ };
4867
+ return visit(data, 0);
4868
+ }
4869
+ function alwaysNullKeys(records) {
4870
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
4871
+ if (objects.length === 0 || objects.length !== records.length)
4872
+ return [];
4873
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
4874
+ if (keys.length === 0)
4875
+ return [];
4876
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
4877
+ return nullKeys.length === keys.length ? nullKeys : [];
4878
+ }
4879
+ function carriesOnlyNulls(value) {
4880
+ if (value === null)
4881
+ return true;
4882
+ if (Array.isArray(value)) {
4883
+ return value.length > 0 && value.every(carriesOnlyNulls);
4884
+ }
4885
+ if (typeof value === "object" && value !== undefined) {
4886
+ const values = Object.values(value);
4887
+ return values.length > 0 && values.every(carriesOnlyNulls);
4888
+ }
4889
+ return false;
4890
+ }
4891
+ function nameList(names, cap2 = 12) {
4892
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
4893
+ const rest = names.length - shown.length;
4894
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
4895
+ }
4896
+ function buildFilterWarning(filter, data, outcome) {
4897
+ const present = availableFields(data);
4898
+ const refs = referencedFields(filter);
4899
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
4900
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
4901
+ const count = countRecords(data);
4902
+ const scope = `${count} record(s)`;
4903
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
4904
+ 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" : "";
4905
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
4906
+ let detail;
4907
+ let lede;
4908
+ if (outcome.kind === "null-elements") {
4909
+ lede = "returned only null values";
4910
+ const projected = `all ${outcome.count} of the elements it projected are null`;
4911
+ if (unknown.length > 0) {
4912
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4913
+ } else if (unchecked.length > 0) {
4914
+ detail = withSoundness(projected);
4915
+ } else {
4916
+ detail = `${projected}, and every field it names exists — a multi-select list ` + `(\`[A, B]\`) reads each entry against \`Data\` itself, so on a list ` + `result use \`[].[A, B]\` or \`[].{a: A, b: B}\` to read the records`;
4917
+ }
4918
+ } else if (outcome.kind === "null-rows") {
4919
+ lede = "returned only null values";
4920
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
4921
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
4922
+ } else if (outcome.kind === "null-values") {
4923
+ lede = "returned only null values";
4924
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
4925
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
4926
+ if (sameSet) {
4927
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
4928
+ } else if (unknown.length > 0) {
4929
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4930
+ } else {
4931
+ detail = withSoundness(`${projected} on all ${scope}`);
4932
+ }
4933
+ } else {
4934
+ lede = "returned nothing";
4935
+ if (unknown.length > 0) {
4936
+ detail = isNotAField(unknown);
4937
+ } else {
4938
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
4939
+ detail = withSoundness(`${selection} — it read ${scope}`);
4940
+ }
4941
+ }
4942
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
4943
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
4944
+ }
4945
+ function appendWarning(existing, note) {
4946
+ return existing ? `${existing} ${note}` : note;
4947
+ }
4948
+ function applyFilter(data, filter, onWarning) {
4791
4949
  const codec = requireJmespath();
4792
4950
  let result;
4793
4951
  try {
@@ -4795,9 +4953,34 @@ function applyFilter(data, filter) {
4795
4953
  } catch (err) {
4796
4954
  throw new FilterEvaluationError(filter, err);
4797
4955
  }
4798
- if (result == null)
4956
+ const inputCount = countRecords(data);
4957
+ const warn = (outcome) => {
4958
+ if (inputCount === 0)
4959
+ return;
4960
+ const note = buildFilterWarning(filter, data, outcome);
4961
+ getOutputSink().writeErr(`[WARN] ${note}
4962
+ `);
4963
+ onWarning?.(note);
4964
+ };
4965
+ const warnIfAllNull = (records) => {
4966
+ const keys = alwaysNullKeys(records);
4967
+ if (keys.length > 0)
4968
+ warn({ kind: "null-values", keys });
4969
+ };
4970
+ if (result == null) {
4971
+ warn({ kind: "empty" });
4799
4972
  return [];
4973
+ }
4800
4974
  if (Array.isArray(result)) {
4975
+ if (result.length === 0) {
4976
+ warn({ kind: "empty" });
4977
+ } else if (result.every((entry) => entry === null)) {
4978
+ warn({ kind: "null-elements", count: result.length });
4979
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
4980
+ warn({ kind: "null-rows", count: result.length });
4981
+ } else {
4982
+ warnIfAllNull(result);
4983
+ }
4801
4984
  if (result.length > 0 && typeof result[0] !== "object") {
4802
4985
  const fieldMatch = filter.match(/\.(\w+)$/);
4803
4986
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -4805,10 +4988,30 @@ function applyFilter(data, filter) {
4805
4988
  }
4806
4989
  return result;
4807
4990
  }
4808
- if (typeof result === "object")
4991
+ if (typeof result === "object") {
4992
+ warnIfAllNull([result]);
4809
4993
  return result;
4994
+ }
4810
4995
  return { Value: result };
4811
4996
  }
4997
+ function filterFailureData(envelope) {
4998
+ const filter = getOutputFilter();
4999
+ const data = envelope.Data;
5000
+ if (!filter || data == null)
5001
+ return;
5002
+ let note;
5003
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
5004
+ note = n;
5005
+ }));
5006
+ if (filterError) {
5007
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
5008
+ return;
5009
+ }
5010
+ envelope.Data = filtered;
5011
+ if (note) {
5012
+ envelope.Warning = appendWarning(envelope.Warning, note);
5013
+ }
5014
+ }
4812
5015
  function defaultErrorCodeForResult(result) {
4813
5016
  switch (result) {
4814
5017
  case RESULTS.AuthenticationError:
@@ -4891,8 +5094,14 @@ var OutputFormatter;
4891
5094
  }
4892
5095
  const filter = getOutputFilter();
4893
5096
  if (filter) {
4894
- const filtered = applyFilter(data.Data, filter);
5097
+ let note;
5098
+ const filtered = applyFilter(data.Data, filter, (n) => {
5099
+ note = n;
5100
+ });
4895
5101
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
5102
+ if (note) {
5103
+ data.Warning = appendWarning(data.Warning, note);
5104
+ }
4896
5105
  }
4897
5106
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4898
5107
  }
@@ -4920,6 +5129,7 @@ var OutputFormatter;
4920
5129
  delete envelope.TelemetryErrorClass;
4921
5130
  delete envelope.TelemetryTerminalOutcome;
4922
5131
  delete envelope.TelemetryTerminalSignal;
5132
+ filterFailureData(envelope);
4923
5133
  if (!suppressTelemetry) {
4924
5134
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
4925
5135
  result: data.Result,
@@ -4968,13 +5178,20 @@ var OutputFormatter;
4968
5178
  OutputFormatter.log = log;
4969
5179
  function formatToString(data) {
4970
5180
  const filter = getOutputFilter();
5181
+ const envelope = data;
4971
5182
  if ("Data" in data && data.Data != null) {
4972
5183
  data.Data = normalizeDataKeys(data.Data);
4973
5184
  if (filter) {
4974
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
5185
+ let note;
5186
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
5187
+ note = n;
5188
+ }));
5189
+ if (note) {
5190
+ envelope.Warning = appendWarning(envelope.Warning, note);
5191
+ }
4975
5192
  }
4976
5193
  }
4977
- const output = normalizeOutputKeys(data);
5194
+ const output = normalizeOutputKeys(envelope);
4978
5195
  const lines = [];
4979
5196
  const sink = getOutputSink();
4980
5197
  printOutput(output, getOutputFormat(), (msg) => {
@@ -9266,4 +9483,4 @@ var registerCommands = async (program2) => {
9266
9483
 
9267
9484
  export { Command, metadata, registerCommands };
9268
9485
 
9269
- //# debugId=781BF23D91918D1764756E2164756E21
9486
+ //# debugId=0DF775D94DD469AA64756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-9sdprwfc.js";
4
+ } from "./tool-j1kf6hps.js";
5
5
  import"./tool-1de529jm.js";
6
6
  export {
7
7
  metadata,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/llmgw-tool",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "1.202.1-preview.220",
4
+ "version": "1.202.1-preview.238",
5
5
  "description": "CLI plugin for UiPath AI Trust Layer Bring-Your-Own LLM connections.",
6
6
  "private": false,
7
7
  "repository": {
@@ -23,5 +23,5 @@
23
23
  "files": [
24
24
  "dist"
25
25
  ],
26
- "gitHead": "a09041733b628c3f6b658a1f58349ea0f40bb492"
26
+ "gitHead": "537e43df1d3583633cfd3a0b88634f9ce3ba9d6b"
27
27
  }