@uipath/llmgw-tool 1.203.0-preview.235 → 1.203.0-preview.237

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-dszmr7h6.js";
6
+ } from "./tool-f01adjjn.js";
7
7
  import"./tool-1de529jm.js";
8
8
 
9
9
  // src/index.ts
@@ -2101,7 +2101,7 @@ var package_default = {
2101
2101
  name: "@uipath/llmgw-tool",
2102
2102
  author: "UiPath",
2103
2103
  license: "SEE LICENSE IN LICENSE.txt",
2104
- version: "1.203.0-preview.235",
2104
+ version: "1.203.0-preview.237",
2105
2105
  description: "CLI plugin for UiPath AI Trust Layer Bring-Your-Own LLM connections.",
2106
2106
  private: false,
2107
2107
  repository: {
@@ -5034,7 +5034,165 @@ class FilterImplicitLimitError extends Error {
5034
5034
  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).";
5035
5035
  }
5036
5036
  }
5037
- function applyFilter(data, filter) {
5037
+ function countRecords(data) {
5038
+ if (Array.isArray(data))
5039
+ return data.length;
5040
+ return data == null ? 0 : 1;
5041
+ }
5042
+ function availableFields(data) {
5043
+ const records = Array.isArray(data) ? data : [data];
5044
+ const keys = new Set;
5045
+ for (const record of records) {
5046
+ if (record && typeof record === "object" && !Array.isArray(record)) {
5047
+ for (const key of Object.keys(record))
5048
+ keys.add(key);
5049
+ }
5050
+ }
5051
+ return [...keys];
5052
+ }
5053
+ function decodeQuotedIdentifier(whole, inner) {
5054
+ const [error, decoded] = catchError(() => JSON.parse(whole));
5055
+ if (!error && typeof decoded === "string")
5056
+ return decoded;
5057
+ return inner.replace(/\\(.)/g, "$1");
5058
+ }
5059
+ function referencedFields(filter) {
5060
+ const top = new Set;
5061
+ const nested = new Set;
5062
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
5063
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
5064
+ const quoted = [];
5065
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
5066
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
5067
+ if (!isAlias) {
5068
+ quoted.push({
5069
+ name: decodeQuotedIdentifier(whole, name),
5070
+ index,
5071
+ tail: isPathTail(withoutValueLiterals, index)
5072
+ });
5073
+ }
5074
+ return `"${" ".repeat(whole.length - 2)}"`;
5075
+ });
5076
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
5077
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
5078
+ const place = (name, index, tail) => {
5079
+ if (tail || index >= rootEnd)
5080
+ nested.add(name);
5081
+ else
5082
+ top.add(name);
5083
+ };
5084
+ for (const entry of quoted)
5085
+ place(entry.name, entry.index, entry.tail);
5086
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
5087
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
5088
+ for (const match of identifiers) {
5089
+ const [, name, trailing] = match;
5090
+ if (trailing || reserved.has(name))
5091
+ continue;
5092
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
5093
+ }
5094
+ return {
5095
+ top: [...top],
5096
+ nested: [...nested].filter((name) => !top.has(name)),
5097
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
5098
+ };
5099
+ }
5100
+ function appearsBelowTopLevel(data, name) {
5101
+ let budget = 2000;
5102
+ const visit = (value, depth) => {
5103
+ if (budget-- <= 0 || depth > 4)
5104
+ return false;
5105
+ if (value === null || typeof value !== "object")
5106
+ return false;
5107
+ if (Array.isArray(value))
5108
+ return value.some((entry) => visit(entry, depth));
5109
+ const record = value;
5110
+ if (depth > 0 && Object.hasOwn(record, name))
5111
+ return true;
5112
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
5113
+ };
5114
+ return visit(data, 0);
5115
+ }
5116
+ function alwaysNullKeys(records) {
5117
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
5118
+ if (objects.length === 0 || objects.length !== records.length)
5119
+ return [];
5120
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
5121
+ if (keys.length === 0)
5122
+ return [];
5123
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
5124
+ return nullKeys.length === keys.length ? nullKeys : [];
5125
+ }
5126
+ function carriesOnlyNulls(value) {
5127
+ if (value === null)
5128
+ return true;
5129
+ if (Array.isArray(value)) {
5130
+ return value.length > 0 && value.every(carriesOnlyNulls);
5131
+ }
5132
+ if (typeof value === "object" && value !== undefined) {
5133
+ const values = Object.values(value);
5134
+ return values.length > 0 && values.every(carriesOnlyNulls);
5135
+ }
5136
+ return false;
5137
+ }
5138
+ function nameList(names, cap2 = 12) {
5139
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
5140
+ const rest = names.length - shown.length;
5141
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
5142
+ }
5143
+ function buildFilterWarning(filter, data, outcome) {
5144
+ const present = availableFields(data);
5145
+ const refs = referencedFields(filter);
5146
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
5147
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
5148
+ const count = countRecords(data);
5149
+ const scope = `${count} record(s)`;
5150
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
5151
+ 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" : "";
5152
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
5153
+ let detail;
5154
+ let lede;
5155
+ if (outcome.kind === "null-elements") {
5156
+ lede = "returned only null values";
5157
+ const projected = `all ${outcome.count} of the elements it projected are null`;
5158
+ if (unknown.length > 0) {
5159
+ detail = `${projected}, because ${isNotAField(unknown)}`;
5160
+ } else if (unchecked.length > 0) {
5161
+ detail = withSoundness(projected);
5162
+ } else {
5163
+ 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`;
5164
+ }
5165
+ } else if (outcome.kind === "null-rows") {
5166
+ lede = "returned only null values";
5167
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
5168
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
5169
+ } else if (outcome.kind === "null-values") {
5170
+ lede = "returned only null values";
5171
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
5172
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
5173
+ if (sameSet) {
5174
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
5175
+ } else if (unknown.length > 0) {
5176
+ detail = `${projected}, because ${isNotAField(unknown)}`;
5177
+ } else {
5178
+ detail = withSoundness(`${projected} on all ${scope}`);
5179
+ }
5180
+ } else {
5181
+ lede = "returned nothing";
5182
+ if (unknown.length > 0) {
5183
+ detail = isNotAField(unknown);
5184
+ } else {
5185
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
5186
+ detail = withSoundness(`${selection} — it read ${scope}`);
5187
+ }
5188
+ }
5189
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
5190
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
5191
+ }
5192
+ function appendWarning(existing, note) {
5193
+ return existing ? `${existing} ${note}` : note;
5194
+ }
5195
+ function applyFilter(data, filter, onWarning) {
5038
5196
  const codec = requireJmespath();
5039
5197
  let result;
5040
5198
  try {
@@ -5042,9 +5200,34 @@ function applyFilter(data, filter) {
5042
5200
  } catch (err) {
5043
5201
  throw new FilterEvaluationError(filter, err);
5044
5202
  }
5045
- if (result == null)
5203
+ const inputCount = countRecords(data);
5204
+ const warn = (outcome) => {
5205
+ if (inputCount === 0)
5206
+ return;
5207
+ const note = buildFilterWarning(filter, data, outcome);
5208
+ getOutputSink().writeErr(`[WARN] ${note}
5209
+ `);
5210
+ onWarning?.(note);
5211
+ };
5212
+ const warnIfAllNull = (records) => {
5213
+ const keys = alwaysNullKeys(records);
5214
+ if (keys.length > 0)
5215
+ warn({ kind: "null-values", keys });
5216
+ };
5217
+ if (result == null) {
5218
+ warn({ kind: "empty" });
5046
5219
  return [];
5220
+ }
5047
5221
  if (Array.isArray(result)) {
5222
+ if (result.length === 0) {
5223
+ warn({ kind: "empty" });
5224
+ } else if (result.every((entry) => entry === null)) {
5225
+ warn({ kind: "null-elements", count: result.length });
5226
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
5227
+ warn({ kind: "null-rows", count: result.length });
5228
+ } else {
5229
+ warnIfAllNull(result);
5230
+ }
5048
5231
  if (result.length > 0 && typeof result[0] !== "object") {
5049
5232
  const fieldMatch = filter.match(/\.(\w+)$/);
5050
5233
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -5052,10 +5235,30 @@ function applyFilter(data, filter) {
5052
5235
  }
5053
5236
  return result;
5054
5237
  }
5055
- if (typeof result === "object")
5238
+ if (typeof result === "object") {
5239
+ warnIfAllNull([result]);
5056
5240
  return result;
5241
+ }
5057
5242
  return { Value: result };
5058
5243
  }
5244
+ function filterFailureData(envelope) {
5245
+ const filter = getOutputFilter();
5246
+ const data = envelope.Data;
5247
+ if (!filter || data == null)
5248
+ return;
5249
+ let note;
5250
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
5251
+ note = n;
5252
+ }));
5253
+ if (filterError) {
5254
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
5255
+ return;
5256
+ }
5257
+ envelope.Data = filtered;
5258
+ if (note) {
5259
+ envelope.Warning = appendWarning(envelope.Warning, note);
5260
+ }
5261
+ }
5059
5262
  function defaultErrorCodeForResult(result) {
5060
5263
  switch (result) {
5061
5264
  case RESULTS.AuthenticationError:
@@ -5138,8 +5341,14 @@ var OutputFormatter;
5138
5341
  }
5139
5342
  const filter = getOutputFilter();
5140
5343
  if (filter) {
5141
- const filtered = applyFilter(data.Data, filter);
5344
+ let note;
5345
+ const filtered = applyFilter(data.Data, filter, (n) => {
5346
+ note = n;
5347
+ });
5142
5348
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
5349
+ if (note) {
5350
+ data.Warning = appendWarning(data.Warning, note);
5351
+ }
5143
5352
  }
5144
5353
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
5145
5354
  }
@@ -5167,6 +5376,7 @@ var OutputFormatter;
5167
5376
  delete envelope.TelemetryErrorClass;
5168
5377
  delete envelope.TelemetryTerminalOutcome;
5169
5378
  delete envelope.TelemetryTerminalSignal;
5379
+ filterFailureData(envelope);
5170
5380
  if (!suppressTelemetry) {
5171
5381
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
5172
5382
  result: data.Result,
@@ -5215,13 +5425,20 @@ var OutputFormatter;
5215
5425
  OutputFormatter.log = log;
5216
5426
  function formatToString(data) {
5217
5427
  const filter = getOutputFilter();
5428
+ const envelope = data;
5218
5429
  if ("Data" in data && data.Data != null) {
5219
5430
  data.Data = normalizeDataKeys(data.Data);
5220
5431
  if (filter) {
5221
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
5432
+ let note;
5433
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
5434
+ note = n;
5435
+ }));
5436
+ if (note) {
5437
+ envelope.Warning = appendWarning(envelope.Warning, note);
5438
+ }
5222
5439
  }
5223
5440
  }
5224
- const output = normalizeOutputKeys(data);
5441
+ const output = normalizeOutputKeys(envelope);
5225
5442
  const lines = [];
5226
5443
  const sink = getOutputSink();
5227
5444
  printOutput(output, getOutputFormat(), (msg) => {
@@ -9517,4 +9734,4 @@ var registerCommands = async (program2) => {
9517
9734
 
9518
9735
  export { Command, metadata, registerCommands };
9519
9736
 
9520
- //# debugId=53A343E8162152B164756E2164756E21
9737
+ //# debugId=C0F765785761E45164756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-dszmr7h6.js";
4
+ } from "./tool-f01adjjn.js";
5
5
  import"./tool-1de529jm.js";
6
6
  export {
7
7
  metadata,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/llmgw-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.203.0-preview.235",
5
+ "version": "1.203.0-preview.237",
6
6
  "description": "CLI plugin for UiPath AI Trust Layer Bring-Your-Own LLM connections.",
7
7
  "private": false,
8
8
  "repository": {
@@ -24,5 +24,5 @@
24
24
  "files": [
25
25
  "dist"
26
26
  ],
27
- "gitHead": "4788b04c17a4429e5a994af2c3eba3898d1c4b13"
27
+ "gitHead": "4ad3e17a66f2c7fb7fe1f0e3e04a5b6175a0a9a3"
28
28
  }