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