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