@uipath/context-grounding-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-varnm1nd.js";
6
+ } from "./tool-1brgxhb9.js";
7
7
  import"./tool-1de529jm.js";
8
8
 
9
9
  // src/index.ts
@@ -4395,7 +4395,165 @@ class FilterImplicitLimitError extends Error {
4395
4395
  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).";
4396
4396
  }
4397
4397
  }
4398
- function applyFilter(data, filter) {
4398
+ function countRecords(data) {
4399
+ if (Array.isArray(data))
4400
+ return data.length;
4401
+ return data == null ? 0 : 1;
4402
+ }
4403
+ function availableFields(data) {
4404
+ const records = Array.isArray(data) ? data : [data];
4405
+ const keys = new Set;
4406
+ for (const record of records) {
4407
+ if (record && typeof record === "object" && !Array.isArray(record)) {
4408
+ for (const key of Object.keys(record))
4409
+ keys.add(key);
4410
+ }
4411
+ }
4412
+ return [...keys];
4413
+ }
4414
+ function decodeQuotedIdentifier(whole, inner) {
4415
+ const [error, decoded] = catchError(() => JSON.parse(whole));
4416
+ if (!error && typeof decoded === "string")
4417
+ return decoded;
4418
+ return inner.replace(/\\(.)/g, "$1");
4419
+ }
4420
+ function referencedFields(filter) {
4421
+ const top = new Set;
4422
+ const nested = new Set;
4423
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
4424
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
4425
+ const quoted = [];
4426
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
4427
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
4428
+ if (!isAlias) {
4429
+ quoted.push({
4430
+ name: decodeQuotedIdentifier(whole, name),
4431
+ index,
4432
+ tail: isPathTail(withoutValueLiterals, index)
4433
+ });
4434
+ }
4435
+ return `"${" ".repeat(whole.length - 2)}"`;
4436
+ });
4437
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
4438
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
4439
+ const place = (name, index, tail) => {
4440
+ if (tail || index >= rootEnd)
4441
+ nested.add(name);
4442
+ else
4443
+ top.add(name);
4444
+ };
4445
+ for (const entry of quoted)
4446
+ place(entry.name, entry.index, entry.tail);
4447
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
4448
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
4449
+ for (const match of identifiers) {
4450
+ const [, name, trailing] = match;
4451
+ if (trailing || reserved.has(name))
4452
+ continue;
4453
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
4454
+ }
4455
+ return {
4456
+ top: [...top],
4457
+ nested: [...nested].filter((name) => !top.has(name)),
4458
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
4459
+ };
4460
+ }
4461
+ function appearsBelowTopLevel(data, name) {
4462
+ let budget = 2000;
4463
+ const visit = (value, depth) => {
4464
+ if (budget-- <= 0 || depth > 4)
4465
+ return false;
4466
+ if (value === null || typeof value !== "object")
4467
+ return false;
4468
+ if (Array.isArray(value))
4469
+ return value.some((entry) => visit(entry, depth));
4470
+ const record = value;
4471
+ if (depth > 0 && Object.hasOwn(record, name))
4472
+ return true;
4473
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
4474
+ };
4475
+ return visit(data, 0);
4476
+ }
4477
+ function alwaysNullKeys(records) {
4478
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
4479
+ if (objects.length === 0 || objects.length !== records.length)
4480
+ return [];
4481
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
4482
+ if (keys.length === 0)
4483
+ return [];
4484
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
4485
+ return nullKeys.length === keys.length ? nullKeys : [];
4486
+ }
4487
+ function carriesOnlyNulls(value) {
4488
+ if (value === null)
4489
+ return true;
4490
+ if (Array.isArray(value)) {
4491
+ return value.length > 0 && value.every(carriesOnlyNulls);
4492
+ }
4493
+ if (typeof value === "object" && value !== undefined) {
4494
+ const values = Object.values(value);
4495
+ return values.length > 0 && values.every(carriesOnlyNulls);
4496
+ }
4497
+ return false;
4498
+ }
4499
+ function nameList(names, cap2 = 12) {
4500
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
4501
+ const rest = names.length - shown.length;
4502
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
4503
+ }
4504
+ function buildFilterWarning(filter, data, outcome) {
4505
+ const present = availableFields(data);
4506
+ const refs = referencedFields(filter);
4507
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
4508
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
4509
+ const count = countRecords(data);
4510
+ const scope = `${count} record(s)`;
4511
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
4512
+ 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" : "";
4513
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
4514
+ let detail;
4515
+ let lede;
4516
+ if (outcome.kind === "null-elements") {
4517
+ lede = "returned only null values";
4518
+ const projected = `all ${outcome.count} of the elements it projected are null`;
4519
+ if (unknown.length > 0) {
4520
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4521
+ } else if (unchecked.length > 0) {
4522
+ detail = withSoundness(projected);
4523
+ } else {
4524
+ 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`;
4525
+ }
4526
+ } else if (outcome.kind === "null-rows") {
4527
+ lede = "returned only null values";
4528
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
4529
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
4530
+ } else if (outcome.kind === "null-values") {
4531
+ lede = "returned only null values";
4532
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
4533
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
4534
+ if (sameSet) {
4535
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
4536
+ } else if (unknown.length > 0) {
4537
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4538
+ } else {
4539
+ detail = withSoundness(`${projected} on all ${scope}`);
4540
+ }
4541
+ } else {
4542
+ lede = "returned nothing";
4543
+ if (unknown.length > 0) {
4544
+ detail = isNotAField(unknown);
4545
+ } else {
4546
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
4547
+ detail = withSoundness(`${selection} — it read ${scope}`);
4548
+ }
4549
+ }
4550
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
4551
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
4552
+ }
4553
+ function appendWarning(existing, note) {
4554
+ return existing ? `${existing} ${note}` : note;
4555
+ }
4556
+ function applyFilter(data, filter, onWarning) {
4399
4557
  const codec = requireJmespath();
4400
4558
  let result;
4401
4559
  try {
@@ -4403,9 +4561,34 @@ function applyFilter(data, filter) {
4403
4561
  } catch (err) {
4404
4562
  throw new FilterEvaluationError(filter, err);
4405
4563
  }
4406
- if (result == null)
4564
+ const inputCount = countRecords(data);
4565
+ const warn = (outcome) => {
4566
+ if (inputCount === 0)
4567
+ return;
4568
+ const note = buildFilterWarning(filter, data, outcome);
4569
+ getOutputSink().writeErr(`[WARN] ${note}
4570
+ `);
4571
+ onWarning?.(note);
4572
+ };
4573
+ const warnIfAllNull = (records) => {
4574
+ const keys = alwaysNullKeys(records);
4575
+ if (keys.length > 0)
4576
+ warn({ kind: "null-values", keys });
4577
+ };
4578
+ if (result == null) {
4579
+ warn({ kind: "empty" });
4407
4580
  return [];
4581
+ }
4408
4582
  if (Array.isArray(result)) {
4583
+ if (result.length === 0) {
4584
+ warn({ kind: "empty" });
4585
+ } else if (result.every((entry) => entry === null)) {
4586
+ warn({ kind: "null-elements", count: result.length });
4587
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
4588
+ warn({ kind: "null-rows", count: result.length });
4589
+ } else {
4590
+ warnIfAllNull(result);
4591
+ }
4409
4592
  if (result.length > 0 && typeof result[0] !== "object") {
4410
4593
  const fieldMatch = filter.match(/\.(\w+)$/);
4411
4594
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -4413,10 +4596,30 @@ function applyFilter(data, filter) {
4413
4596
  }
4414
4597
  return result;
4415
4598
  }
4416
- if (typeof result === "object")
4599
+ if (typeof result === "object") {
4600
+ warnIfAllNull([result]);
4417
4601
  return result;
4602
+ }
4418
4603
  return { Value: result };
4419
4604
  }
4605
+ function filterFailureData(envelope) {
4606
+ const filter = getOutputFilter();
4607
+ const data = envelope.Data;
4608
+ if (!filter || data == null)
4609
+ return;
4610
+ let note;
4611
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
4612
+ note = n;
4613
+ }));
4614
+ if (filterError) {
4615
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
4616
+ return;
4617
+ }
4618
+ envelope.Data = filtered;
4619
+ if (note) {
4620
+ envelope.Warning = appendWarning(envelope.Warning, note);
4621
+ }
4622
+ }
4420
4623
  function defaultErrorCodeForResult(result) {
4421
4624
  switch (result) {
4422
4625
  case RESULTS.AuthenticationError:
@@ -4499,8 +4702,14 @@ var OutputFormatter;
4499
4702
  }
4500
4703
  const filter = getOutputFilter();
4501
4704
  if (filter) {
4502
- const filtered = applyFilter(data.Data, filter);
4705
+ let note;
4706
+ const filtered = applyFilter(data.Data, filter, (n) => {
4707
+ note = n;
4708
+ });
4503
4709
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
4710
+ if (note) {
4711
+ data.Warning = appendWarning(data.Warning, note);
4712
+ }
4504
4713
  }
4505
4714
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4506
4715
  }
@@ -4528,6 +4737,7 @@ var OutputFormatter;
4528
4737
  delete envelope.TelemetryErrorClass;
4529
4738
  delete envelope.TelemetryTerminalOutcome;
4530
4739
  delete envelope.TelemetryTerminalSignal;
4740
+ filterFailureData(envelope);
4531
4741
  if (!suppressTelemetry) {
4532
4742
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
4533
4743
  result: data.Result,
@@ -4576,13 +4786,20 @@ var OutputFormatter;
4576
4786
  OutputFormatter.log = log;
4577
4787
  function formatToString(data) {
4578
4788
  const filter = getOutputFilter();
4789
+ const envelope = data;
4579
4790
  if ("Data" in data && data.Data != null) {
4580
4791
  data.Data = normalizeDataKeys(data.Data);
4581
4792
  if (filter) {
4582
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
4793
+ let note;
4794
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
4795
+ note = n;
4796
+ }));
4797
+ if (note) {
4798
+ envelope.Warning = appendWarning(envelope.Warning, note);
4799
+ }
4583
4800
  }
4584
4801
  }
4585
- const output = normalizeOutputKeys(data);
4802
+ const output = normalizeOutputKeys(envelope);
4586
4803
  const lines = [];
4587
4804
  const sink = getOutputSink();
4588
4805
  printOutput(output, getOutputFormat(), (msg) => {
@@ -7417,7 +7634,7 @@ function createCommandForwarder(executeCommand) {
7417
7634
  var package_default = {
7418
7635
  name: "@uipath/context-grounding-tool",
7419
7636
  license: "SEE LICENSE IN LICENSE.txt",
7420
- version: "1.202.1-preview.220",
7637
+ version: "1.202.1-preview.238",
7421
7638
  description: "Tool for context grounding operations via the UiPath Python SDK",
7422
7639
  keywords: [
7423
7640
  "uipcli-tool",
@@ -7518,4 +7735,4 @@ var registerCommands = async (program2) => {
7518
7735
 
7519
7736
  export { Command, metadata, registerCommands };
7520
7737
 
7521
- //# debugId=B673AEBC09B3413D64756E2164756E21
7738
+ //# debugId=14466213DD567D8B64756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-varnm1nd.js";
4
+ } from "./tool-1brgxhb9.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/context-grounding-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": "Tool for context grounding operations via the UiPath Python SDK",
6
6
  "keywords": [
7
7
  "uipcli-tool",
@@ -28,5 +28,5 @@
28
28
  "publishConfig": {
29
29
  "registry": "https://registry.npmjs.org/"
30
30
  },
31
- "gitHead": "a09041733b628c3f6b658a1f58349ea0f40bb492"
31
+ "gitHead": "537e43df1d3583633cfd3a0b88634f9ce3ba9d6b"
32
32
  }