@uipath/context-grounding-tool 1.203.0-preview.233 → 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 +1 -1
- package/dist/{tool-6tcw11ap.js → tool-8w2xvzpp.js} +225 -8
- package/dist/tool.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4624,7 +4624,165 @@ class FilterImplicitLimitError extends Error {
|
|
|
4624
4624
|
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).";
|
|
4625
4625
|
}
|
|
4626
4626
|
}
|
|
4627
|
-
function
|
|
4627
|
+
function countRecords(data) {
|
|
4628
|
+
if (Array.isArray(data))
|
|
4629
|
+
return data.length;
|
|
4630
|
+
return data == null ? 0 : 1;
|
|
4631
|
+
}
|
|
4632
|
+
function availableFields(data) {
|
|
4633
|
+
const records = Array.isArray(data) ? data : [data];
|
|
4634
|
+
const keys = new Set;
|
|
4635
|
+
for (const record of records) {
|
|
4636
|
+
if (record && typeof record === "object" && !Array.isArray(record)) {
|
|
4637
|
+
for (const key of Object.keys(record))
|
|
4638
|
+
keys.add(key);
|
|
4639
|
+
}
|
|
4640
|
+
}
|
|
4641
|
+
return [...keys];
|
|
4642
|
+
}
|
|
4643
|
+
function decodeQuotedIdentifier(whole, inner) {
|
|
4644
|
+
const [error, decoded] = catchError(() => JSON.parse(whole));
|
|
4645
|
+
if (!error && typeof decoded === "string")
|
|
4646
|
+
return decoded;
|
|
4647
|
+
return inner.replace(/\\(.)/g, "$1");
|
|
4648
|
+
}
|
|
4649
|
+
function referencedFields(filter) {
|
|
4650
|
+
const top = new Set;
|
|
4651
|
+
const nested = new Set;
|
|
4652
|
+
const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
|
|
4653
|
+
const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
|
|
4654
|
+
const quoted = [];
|
|
4655
|
+
const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
|
|
4656
|
+
const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
|
|
4657
|
+
if (!isAlias) {
|
|
4658
|
+
quoted.push({
|
|
4659
|
+
name: decodeQuotedIdentifier(whole, name),
|
|
4660
|
+
index,
|
|
4661
|
+
tail: isPathTail(withoutValueLiterals, index)
|
|
4662
|
+
});
|
|
4663
|
+
}
|
|
4664
|
+
return `"${" ".repeat(whole.length - 2)}"`;
|
|
4665
|
+
});
|
|
4666
|
+
const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
|
|
4667
|
+
const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
|
|
4668
|
+
const place = (name, index, tail) => {
|
|
4669
|
+
if (tail || index >= rootEnd)
|
|
4670
|
+
nested.add(name);
|
|
4671
|
+
else
|
|
4672
|
+
top.add(name);
|
|
4673
|
+
};
|
|
4674
|
+
for (const entry of quoted)
|
|
4675
|
+
place(entry.name, entry.index, entry.tail);
|
|
4676
|
+
const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
|
|
4677
|
+
const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
|
|
4678
|
+
for (const match of identifiers) {
|
|
4679
|
+
const [, name, trailing] = match;
|
|
4680
|
+
if (trailing || reserved.has(name))
|
|
4681
|
+
continue;
|
|
4682
|
+
place(name, match.index, isPathTail(withoutLiterals, match.index));
|
|
4683
|
+
}
|
|
4684
|
+
return {
|
|
4685
|
+
top: [...top],
|
|
4686
|
+
nested: [...nested].filter((name) => !top.has(name)),
|
|
4687
|
+
hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
|
|
4688
|
+
};
|
|
4689
|
+
}
|
|
4690
|
+
function appearsBelowTopLevel(data, name) {
|
|
4691
|
+
let budget = 2000;
|
|
4692
|
+
const visit = (value, depth) => {
|
|
4693
|
+
if (budget-- <= 0 || depth > 4)
|
|
4694
|
+
return false;
|
|
4695
|
+
if (value === null || typeof value !== "object")
|
|
4696
|
+
return false;
|
|
4697
|
+
if (Array.isArray(value))
|
|
4698
|
+
return value.some((entry) => visit(entry, depth));
|
|
4699
|
+
const record = value;
|
|
4700
|
+
if (depth > 0 && Object.hasOwn(record, name))
|
|
4701
|
+
return true;
|
|
4702
|
+
return Object.values(record).some((entry) => visit(entry, depth + 1));
|
|
4703
|
+
};
|
|
4704
|
+
return visit(data, 0);
|
|
4705
|
+
}
|
|
4706
|
+
function alwaysNullKeys(records) {
|
|
4707
|
+
const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
|
|
4708
|
+
if (objects.length === 0 || objects.length !== records.length)
|
|
4709
|
+
return [];
|
|
4710
|
+
const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
|
|
4711
|
+
if (keys.length === 0)
|
|
4712
|
+
return [];
|
|
4713
|
+
const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
|
|
4714
|
+
return nullKeys.length === keys.length ? nullKeys : [];
|
|
4715
|
+
}
|
|
4716
|
+
function carriesOnlyNulls(value) {
|
|
4717
|
+
if (value === null)
|
|
4718
|
+
return true;
|
|
4719
|
+
if (Array.isArray(value)) {
|
|
4720
|
+
return value.length > 0 && value.every(carriesOnlyNulls);
|
|
4721
|
+
}
|
|
4722
|
+
if (typeof value === "object" && value !== undefined) {
|
|
4723
|
+
const values = Object.values(value);
|
|
4724
|
+
return values.length > 0 && values.every(carriesOnlyNulls);
|
|
4725
|
+
}
|
|
4726
|
+
return false;
|
|
4727
|
+
}
|
|
4728
|
+
function nameList(names, cap2 = 12) {
|
|
4729
|
+
const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
|
|
4730
|
+
const rest = names.length - shown.length;
|
|
4731
|
+
return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
|
|
4732
|
+
}
|
|
4733
|
+
function buildFilterWarning(filter, data, outcome) {
|
|
4734
|
+
const present = availableFields(data);
|
|
4735
|
+
const refs = referencedFields(filter);
|
|
4736
|
+
const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
|
|
4737
|
+
const unchecked = refs.nested.filter((name) => !present.includes(name));
|
|
4738
|
+
const count = countRecords(data);
|
|
4739
|
+
const scope = `${count} record(s)`;
|
|
4740
|
+
const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
|
|
4741
|
+
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" : "";
|
|
4742
|
+
const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
|
|
4743
|
+
let detail;
|
|
4744
|
+
let lede;
|
|
4745
|
+
if (outcome.kind === "null-elements") {
|
|
4746
|
+
lede = "returned only null values";
|
|
4747
|
+
const projected = `all ${outcome.count} of the elements it projected are null`;
|
|
4748
|
+
if (unknown.length > 0) {
|
|
4749
|
+
detail = `${projected}, because ${isNotAField(unknown)}`;
|
|
4750
|
+
} else if (unchecked.length > 0) {
|
|
4751
|
+
detail = withSoundness(projected);
|
|
4752
|
+
} else {
|
|
4753
|
+
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`;
|
|
4754
|
+
}
|
|
4755
|
+
} else if (outcome.kind === "null-rows") {
|
|
4756
|
+
lede = "returned only null values";
|
|
4757
|
+
const projected = `every value it projected is null on all ${outcome.count} row(s)`;
|
|
4758
|
+
detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
|
|
4759
|
+
} else if (outcome.kind === "null-values") {
|
|
4760
|
+
lede = "returned only null values";
|
|
4761
|
+
const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
|
|
4762
|
+
const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
|
|
4763
|
+
if (sameSet) {
|
|
4764
|
+
detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
|
|
4765
|
+
} else if (unknown.length > 0) {
|
|
4766
|
+
detail = `${projected}, because ${isNotAField(unknown)}`;
|
|
4767
|
+
} else {
|
|
4768
|
+
detail = withSoundness(`${projected} on all ${scope}`);
|
|
4769
|
+
}
|
|
4770
|
+
} else {
|
|
4771
|
+
lede = "returned nothing";
|
|
4772
|
+
if (unknown.length > 0) {
|
|
4773
|
+
detail = isNotAField(unknown);
|
|
4774
|
+
} else {
|
|
4775
|
+
const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
|
|
4776
|
+
detail = withSoundness(`${selection} — it read ${scope}`);
|
|
4777
|
+
}
|
|
4778
|
+
}
|
|
4779
|
+
const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
|
|
4780
|
+
return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
|
|
4781
|
+
}
|
|
4782
|
+
function appendWarning(existing, note) {
|
|
4783
|
+
return existing ? `${existing} ${note}` : note;
|
|
4784
|
+
}
|
|
4785
|
+
function applyFilter(data, filter, onWarning) {
|
|
4628
4786
|
const codec = requireJmespath();
|
|
4629
4787
|
let result;
|
|
4630
4788
|
try {
|
|
@@ -4632,9 +4790,34 @@ function applyFilter(data, filter) {
|
|
|
4632
4790
|
} catch (err) {
|
|
4633
4791
|
throw new FilterEvaluationError(filter, err);
|
|
4634
4792
|
}
|
|
4635
|
-
|
|
4793
|
+
const inputCount = countRecords(data);
|
|
4794
|
+
const warn = (outcome) => {
|
|
4795
|
+
if (inputCount === 0)
|
|
4796
|
+
return;
|
|
4797
|
+
const note = buildFilterWarning(filter, data, outcome);
|
|
4798
|
+
getOutputSink().writeErr(`[WARN] ${note}
|
|
4799
|
+
`);
|
|
4800
|
+
onWarning?.(note);
|
|
4801
|
+
};
|
|
4802
|
+
const warnIfAllNull = (records) => {
|
|
4803
|
+
const keys = alwaysNullKeys(records);
|
|
4804
|
+
if (keys.length > 0)
|
|
4805
|
+
warn({ kind: "null-values", keys });
|
|
4806
|
+
};
|
|
4807
|
+
if (result == null) {
|
|
4808
|
+
warn({ kind: "empty" });
|
|
4636
4809
|
return [];
|
|
4810
|
+
}
|
|
4637
4811
|
if (Array.isArray(result)) {
|
|
4812
|
+
if (result.length === 0) {
|
|
4813
|
+
warn({ kind: "empty" });
|
|
4814
|
+
} else if (result.every((entry) => entry === null)) {
|
|
4815
|
+
warn({ kind: "null-elements", count: result.length });
|
|
4816
|
+
} else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
|
|
4817
|
+
warn({ kind: "null-rows", count: result.length });
|
|
4818
|
+
} else {
|
|
4819
|
+
warnIfAllNull(result);
|
|
4820
|
+
}
|
|
4638
4821
|
if (result.length > 0 && typeof result[0] !== "object") {
|
|
4639
4822
|
const fieldMatch = filter.match(/\.(\w+)$/);
|
|
4640
4823
|
const key = fieldMatch ? fieldMatch[1] : "Value";
|
|
@@ -4642,10 +4825,30 @@ function applyFilter(data, filter) {
|
|
|
4642
4825
|
}
|
|
4643
4826
|
return result;
|
|
4644
4827
|
}
|
|
4645
|
-
if (typeof result === "object")
|
|
4828
|
+
if (typeof result === "object") {
|
|
4829
|
+
warnIfAllNull([result]);
|
|
4646
4830
|
return result;
|
|
4831
|
+
}
|
|
4647
4832
|
return { Value: result };
|
|
4648
4833
|
}
|
|
4834
|
+
function filterFailureData(envelope) {
|
|
4835
|
+
const filter = getOutputFilter();
|
|
4836
|
+
const data = envelope.Data;
|
|
4837
|
+
if (!filter || data == null)
|
|
4838
|
+
return;
|
|
4839
|
+
let note;
|
|
4840
|
+
const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
|
|
4841
|
+
note = n;
|
|
4842
|
+
}));
|
|
4843
|
+
if (filterError) {
|
|
4844
|
+
envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
|
|
4845
|
+
return;
|
|
4846
|
+
}
|
|
4847
|
+
envelope.Data = filtered;
|
|
4848
|
+
if (note) {
|
|
4849
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
4850
|
+
}
|
|
4851
|
+
}
|
|
4649
4852
|
function defaultErrorCodeForResult(result) {
|
|
4650
4853
|
switch (result) {
|
|
4651
4854
|
case RESULTS.AuthenticationError:
|
|
@@ -4728,8 +4931,14 @@ var OutputFormatter;
|
|
|
4728
4931
|
}
|
|
4729
4932
|
const filter = getOutputFilter();
|
|
4730
4933
|
if (filter) {
|
|
4731
|
-
|
|
4934
|
+
let note;
|
|
4935
|
+
const filtered = applyFilter(data.Data, filter, (n) => {
|
|
4936
|
+
note = n;
|
|
4937
|
+
});
|
|
4732
4938
|
data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
|
|
4939
|
+
if (note) {
|
|
4940
|
+
data.Warning = appendWarning(data.Warning, note);
|
|
4941
|
+
}
|
|
4733
4942
|
}
|
|
4734
4943
|
logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
|
|
4735
4944
|
}
|
|
@@ -4757,6 +4966,7 @@ var OutputFormatter;
|
|
|
4757
4966
|
delete envelope.TelemetryErrorClass;
|
|
4758
4967
|
delete envelope.TelemetryTerminalOutcome;
|
|
4759
4968
|
delete envelope.TelemetryTerminalSignal;
|
|
4969
|
+
filterFailureData(envelope);
|
|
4760
4970
|
if (!suppressTelemetry) {
|
|
4761
4971
|
telemetry.trackEvent(CommonTelemetryEvents.Error, {
|
|
4762
4972
|
result: data.Result,
|
|
@@ -4805,13 +5015,20 @@ var OutputFormatter;
|
|
|
4805
5015
|
OutputFormatter.log = log;
|
|
4806
5016
|
function formatToString(data) {
|
|
4807
5017
|
const filter = getOutputFilter();
|
|
5018
|
+
const envelope = data;
|
|
4808
5019
|
if ("Data" in data && data.Data != null) {
|
|
4809
5020
|
data.Data = normalizeDataKeys(data.Data);
|
|
4810
5021
|
if (filter) {
|
|
4811
|
-
|
|
5022
|
+
let note;
|
|
5023
|
+
data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
|
|
5024
|
+
note = n;
|
|
5025
|
+
}));
|
|
5026
|
+
if (note) {
|
|
5027
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
5028
|
+
}
|
|
4812
5029
|
}
|
|
4813
5030
|
}
|
|
4814
|
-
const output = normalizeOutputKeys(
|
|
5031
|
+
const output = normalizeOutputKeys(envelope);
|
|
4815
5032
|
const lines = [];
|
|
4816
5033
|
const sink = getOutputSink();
|
|
4817
5034
|
printOutput(output, getOutputFormat(), (msg) => {
|
|
@@ -7740,7 +7957,7 @@ var package_default = {
|
|
|
7740
7957
|
name: "@uipath/context-grounding-tool",
|
|
7741
7958
|
author: "UiPath",
|
|
7742
7959
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
7743
|
-
version: "1.203.0-preview.
|
|
7960
|
+
version: "1.203.0-preview.237",
|
|
7744
7961
|
description: "Tool for context grounding operations via the UiPath Python SDK",
|
|
7745
7962
|
keywords: [
|
|
7746
7963
|
"uipcli-tool",
|
|
@@ -7841,4 +8058,4 @@ var registerCommands = async (program2) => {
|
|
|
7841
8058
|
|
|
7842
8059
|
export { Command, metadata, registerCommands };
|
|
7843
8060
|
|
|
7844
|
-
//# debugId=
|
|
8061
|
+
//# debugId=8F0D4132241F53CC64756E2164756E21
|
package/dist/tool.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@uipath/context-grounding-tool",
|
|
3
3
|
"author": "UiPath",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
-
"version": "1.203.0-preview.
|
|
5
|
+
"version": "1.203.0-preview.237",
|
|
6
6
|
"description": "Tool for context grounding operations via the UiPath Python SDK",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"uipcli-tool",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"registry": "https://registry.npmjs.org/"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "4ad3e17a66f2c7fb7fe1f0e3e04a5b6175a0a9a3"
|
|
33
33
|
}
|