@uipath/docsai-tool 1.202.0 → 1.203.0-preview.160

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-xrkfnz4j.js";
6
+ } from "./tool-fqjn81ft.js";
7
7
  import"./tool-1yh8g550.js";
8
8
 
9
9
  // src/index.ts
@@ -8986,8 +8986,9 @@ var require_dist = __commonJS(function(exports, module) {
8986
8986
  // package.json
8987
8987
  var package_default = {
8988
8988
  name: "@uipath/docsai-tool",
8989
+ author: "UiPath",
8989
8990
  license: "SEE LICENSE IN LICENSE.txt",
8990
- version: "1.202.0",
8991
+ version: "1.203.0-preview.160",
8991
8992
  description: "Search UiPath documentation with AI-powered answers.",
8992
8993
  private: false,
8993
8994
  repository: {
@@ -9542,7 +9543,7 @@ var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{1
9542
9543
  var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
9543
9544
  var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
9544
9545
  var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
9545
- var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
9546
+ var PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
9546
9547
  var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
9547
9548
  var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
9548
9549
  var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
@@ -9589,7 +9590,7 @@ var QUOTED_LITERAL_PATTERN = new RegExp([
9589
9590
  `(?<![A-Za-z0-9])"(?:[^\\
9590
9591
  ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
9591
9592
  ].join("|"), "g");
9592
- var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
9593
+ var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
9593
9594
  var COLLAPSED_BODY = "{…}";
9594
9595
  var COLLAPSED_BODY_MARKER = "\x01body\x01";
9595
9596
  var MAX_BODY_NESTING = 8;
@@ -9604,10 +9605,13 @@ function collapseJsonBodies(text) {
9604
9605
  }
9605
9606
  return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
9606
9607
  }
9607
- var TRAILING_PROSE_PUNCT = /[.,;:!?)\]}>'"]+$/;
9608
+ var TRAILING_PROSE_PUNCT = `.,;:!?)]}>'"`;
9608
9609
  function peelTrailingPunctuation(match) {
9609
- const trailing = match.match(TRAILING_PROSE_PUNCT)?.[0] ?? "";
9610
- return trailing ? [match.slice(0, -trailing.length), trailing] : [match, ""];
9610
+ let end = match.length;
9611
+ while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
9612
+ end -= 1;
9613
+ }
9614
+ return [match.slice(0, end), match.slice(end)];
9611
9615
  }
9612
9616
  function redactUrl(raw) {
9613
9617
  try {
@@ -10324,7 +10328,8 @@ function readRegistryValue(keyPath, valueName) {
10324
10328
  }
10325
10329
  const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
10326
10330
  encoding: "utf-8",
10327
- stdio: ["pipe", "pipe", "pipe"]
10331
+ stdio: ["pipe", "pipe", "pipe"],
10332
+ windowsHide: true
10328
10333
  }));
10329
10334
  if (error) {
10330
10335
  return "";
@@ -11006,28 +11011,32 @@ function isPlainRecord(value) {
11006
11011
  const prototype = Object.getPrototypeOf(value);
11007
11012
  return prototype === Object.prototype || prototype === null;
11008
11013
  }
11009
- function extractPagedRows(value) {
11014
+ function splitPagedEnvelope(value) {
11010
11015
  if (Array.isArray(value) || !isPlainRecord(value))
11011
11016
  return null;
11012
- const entries = Object.values(value);
11017
+ const entries = Object.entries(value);
11013
11018
  if (entries.length === 0)
11014
11019
  return null;
11015
- let rows = null;
11016
- let hasScalarSibling = false;
11017
- for (const entry of entries) {
11020
+ let found = null;
11021
+ const meta = Object.create(null);
11022
+ for (const [key, entry] of entries) {
11018
11023
  if (Array.isArray(entry)) {
11019
- if (rows !== null)
11024
+ if (found !== null)
11020
11025
  return null;
11021
- rows = entry;
11026
+ found = { key, rows: entry };
11022
11027
  } else if (entry !== null && typeof entry === "object") {
11023
11028
  return null;
11024
11029
  } else {
11025
- hasScalarSibling = true;
11030
+ meta[key] = entry;
11026
11031
  }
11027
11032
  }
11028
- if (rows === null || !hasScalarSibling)
11033
+ if (found === null || Object.keys(meta).length === 0)
11029
11034
  return null;
11030
- return rows;
11035
+ return { ...found, meta };
11036
+ }
11037
+ function extractPagedRows(value) {
11038
+ const paged = splitPagedEnvelope(value);
11039
+ return paged === null ? null : paged.rows;
11031
11040
  }
11032
11041
  function toLowerCamelCaseKey(key) {
11033
11042
  if (!key)
@@ -11131,6 +11140,9 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
11131
11140
  }
11132
11141
  break;
11133
11142
  }
11143
+ case "markdown":
11144
+ logFn(renderMarkdown(data));
11145
+ break;
11134
11146
  default: {
11135
11147
  const hasData = "Data" in data && data.Data != null;
11136
11148
  const pagedRows = hasData ? extractPagedRows(data.Data) : null;
@@ -11155,6 +11167,10 @@ function logOutput(data, format = "json", tableRowStyle) {
11155
11167
  printOutput(data, format, (msg) => sink.writeOut(`${msg}
11156
11168
  `), needsAsciiSafeJson(sink), styleFn);
11157
11169
  }
11170
+ var PLUMBING_KEYS = new Set(["code", "log"]);
11171
+ function isPlumbingKey(key) {
11172
+ return PLUMBING_KEYS.has(key.toLowerCase());
11173
+ }
11158
11174
  function cellToString(val) {
11159
11175
  return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
11160
11176
  }
@@ -11170,7 +11186,7 @@ function wrapText(text, width) {
11170
11186
  function printTable(data, logFn, externalLogValue, tableRowStyle) {
11171
11187
  if (data.length === 0)
11172
11188
  return;
11173
- const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
11189
+ const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
11174
11190
  const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
11175
11191
  const header = keys.map((key, i) => key.padEnd(maxWidths[i])).join(" | ");
11176
11192
  logFn(header);
@@ -11192,7 +11208,7 @@ function isNonEmptyPlainObject(value) {
11192
11208
  }
11193
11209
  var NESTED_INDENT = " ";
11194
11210
  function printVerticalTable(data, logFn = console.log, externalLogValue) {
11195
- const keys = Object.keys(data).filter((key) => !["code", "log"].includes(key.toLowerCase()));
11211
+ const keys = Object.keys(data).filter((key) => !isPlumbingKey(key));
11196
11212
  if (keys.length === 0)
11197
11213
  return;
11198
11214
  const isBlockValue = (value) => isPlainObjectArray(value) || isNonEmptyPlainObject(value);
@@ -11223,7 +11239,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
11223
11239
  function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
11224
11240
  if (data.length === 0)
11225
11241
  return;
11226
- const keys = Object.keys(data[0]).filter((key) => !["code", "log"].includes(key.toLowerCase()));
11242
+ const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
11227
11243
  if (keys.length === 0)
11228
11244
  return;
11229
11245
  if (!process.stdout.isTTY) {
@@ -11297,6 +11313,220 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
11297
11313
  logFn(`Log: ${externalLogValue}`);
11298
11314
  }
11299
11315
  }
11316
+ var MARKDOWN_MAX_CELL = 200;
11317
+ var MARKDOWN_MAX_DEPTH = 3;
11318
+ function markdownHeading(depth) {
11319
+ return "#".repeat(Math.min(3 + depth, 6));
11320
+ }
11321
+ var BACKTICK_RUN = /`+/g;
11322
+ function fencedBlock(text) {
11323
+ const first = text.trimStart()[0];
11324
+ const language = first === "<" ? "xml" : first === "{" || first === "[" ? "json" : "";
11325
+ const longestRun = Math.max(0, ...Array.from(text.matchAll(BACKTICK_RUN), (match) => match[0].length));
11326
+ const fence = "`".repeat(Math.max(3, longestRun + 1));
11327
+ return `${fence}${language}
11328
+ ${text}
11329
+ ${fence}`;
11330
+ }
11331
+ function collapseNewlineRuns(text) {
11332
+ return text.split(/(\s+)/).map((part, index) => index % 2 === 1 && part.includes(`
11333
+ `) ? " " : part).join("");
11334
+ }
11335
+ function markdownCell(value) {
11336
+ const text = value instanceof Date ? value.toISOString() : cellToString(value);
11337
+ return collapseNewlineRuns(text).replace(/\|/g, "\\|");
11338
+ }
11339
+ function markdownLabel(key) {
11340
+ return collapseNewlineRuns(key).replace(/[\\`*|]/g, "\\$&");
11341
+ }
11342
+ function withoutPlumbing(record) {
11343
+ const kept = Object.create(null);
11344
+ for (const [key, value] of Object.entries(record)) {
11345
+ if (!isPlumbingKey(key))
11346
+ kept[key] = value;
11347
+ }
11348
+ return kept;
11349
+ }
11350
+ function rowsWithoutPlumbing(rows) {
11351
+ return rows.map((row) => isPlainRecord(row) ? withoutPlumbing(row) : row);
11352
+ }
11353
+ function markdownTable(rows) {
11354
+ const columns = [];
11355
+ const seen = new Set;
11356
+ for (const row of rows) {
11357
+ for (const key of Object.keys(row)) {
11358
+ if (!seen.has(key)) {
11359
+ seen.add(key);
11360
+ columns.push(key);
11361
+ }
11362
+ }
11363
+ }
11364
+ if (columns.length === 0)
11365
+ return null;
11366
+ const cells = rows.map((row) => columns.map((key) => markdownCell(row[key])));
11367
+ if (cells.some((row) => row.some((c) => c.length > MARKDOWN_MAX_CELL))) {
11368
+ return null;
11369
+ }
11370
+ return [
11371
+ `| ${columns.map(markdownLabel).join(" | ")} |`,
11372
+ `| ${columns.map(() => "---").join(" | ")} |`,
11373
+ ...cells.map((row) => `| ${row.join(" | ")} |`)
11374
+ ].join(`
11375
+ `);
11376
+ }
11377
+ function extractMessageSequence(rows) {
11378
+ const messages = [];
11379
+ for (const row of rows) {
11380
+ const message = extractSingleMessage(row);
11381
+ if (message === null)
11382
+ return null;
11383
+ messages.push(message);
11384
+ }
11385
+ return messages.join(`
11386
+
11387
+ `);
11388
+ }
11389
+ function markdownRows(rows, depth) {
11390
+ if (rows.length === 0)
11391
+ return "(none)";
11392
+ if (!isPlainObjectArray(rows)) {
11393
+ return rows.map((item) => `- ${markdownCell(item)}`).join(`
11394
+ `);
11395
+ }
11396
+ const prose = extractMessageSequence(rows);
11397
+ if (prose !== null)
11398
+ return prose;
11399
+ const table = markdownTable(rows);
11400
+ if (table !== null)
11401
+ return table;
11402
+ if (depth >= MARKDOWN_MAX_DEPTH) {
11403
+ return fencedBlock(JSON.stringify(rows, null, 2));
11404
+ }
11405
+ return rows.map((row, index) => [
11406
+ `${markdownHeading(depth)} ${index + 1}`,
11407
+ markdownObject(row, depth + 1)
11408
+ ].join(`
11409
+
11410
+ `)).join(`
11411
+
11412
+ `);
11413
+ }
11414
+ function markdownObject(obj, depth) {
11415
+ const scalars = [];
11416
+ const blocks = [];
11417
+ for (const [key, value] of Object.entries(obj)) {
11418
+ if (value === undefined)
11419
+ continue;
11420
+ const label = markdownLabel(key);
11421
+ if (Array.isArray(value)) {
11422
+ blocks.push(`${markdownHeading(depth)} ${label}
11423
+
11424
+ ${markdownRows(value, depth + 1)}`);
11425
+ } else if (isNonEmptyPlainObject(value)) {
11426
+ const nested = depth < MARKDOWN_MAX_DEPTH ? markdownObject(value, depth + 1) : fencedBlock(JSON.stringify(value, null, 2));
11427
+ if (nested !== "") {
11428
+ blocks.push(`${markdownHeading(depth)} ${label}
11429
+
11430
+ ${nested}`);
11431
+ }
11432
+ } else if (typeof value === "string" && value.includes(`
11433
+ `)) {
11434
+ blocks.push(`**${label}:**
11435
+
11436
+ ${fencedBlock(value)}`);
11437
+ } else {
11438
+ scalars.push(`**${label}:** ${markdownCell(value)}`);
11439
+ }
11440
+ }
11441
+ const sections = scalars.length > 0 ? [scalars.join(`
11442
+ `)] : [];
11443
+ sections.push(...blocks);
11444
+ return sections.join(`
11445
+
11446
+ `);
11447
+ }
11448
+ function extractSingleMessage(payload) {
11449
+ if (!isPlainRecord(payload))
11450
+ return null;
11451
+ const keys = Object.keys(payload);
11452
+ if (keys.length !== 1 || keys[0].toLowerCase() !== "message")
11453
+ return null;
11454
+ const value = payload[keys[0]];
11455
+ return typeof value === "string" ? value : null;
11456
+ }
11457
+ function markdownPayload(payload) {
11458
+ const message = extractSingleMessage(payload);
11459
+ if (message !== null)
11460
+ return message;
11461
+ if (Array.isArray(payload)) {
11462
+ return markdownRows(rowsWithoutPlumbing(payload), 0);
11463
+ }
11464
+ const visible = withoutPlumbing(payload);
11465
+ const paged = splitPagedEnvelope(visible);
11466
+ if (paged !== null) {
11467
+ const meta = markdownObject(paged.meta, 0);
11468
+ const rows = `${markdownHeading(0)} ${markdownLabel(paged.key)}
11469
+
11470
+ ${markdownRows(rowsWithoutPlumbing(paged.rows), 1)}`;
11471
+ return meta === "" ? rows : `${meta}
11472
+
11473
+ ${rows}`;
11474
+ }
11475
+ return markdownObject(visible, 0);
11476
+ }
11477
+ function isPaginationWorthShowing(value) {
11478
+ if (typeof value !== "object" || value === null)
11479
+ return false;
11480
+ const page = value;
11481
+ return page.HasMore === true || typeof page.Offset === "number" && page.Offset > 0;
11482
+ }
11483
+ function markdownEnvelopeNotes(data) {
11484
+ const envelope = data;
11485
+ const notes = [];
11486
+ const warning = envelope.Warning;
11487
+ if (typeof warning === "string" && warning !== "") {
11488
+ notes.push(`> **Warning:** ${warning}`);
11489
+ }
11490
+ const instructions = envelope.Instructions;
11491
+ if (typeof instructions === "string" && instructions !== "") {
11492
+ notes.push(`> ${instructions}`);
11493
+ }
11494
+ const pagination = envelope.Pagination;
11495
+ if (isPaginationWorthShowing(pagination)) {
11496
+ const body = markdownObject(pagination, 1);
11497
+ if (body !== "") {
11498
+ notes.push(`${markdownHeading(0)} Pagination
11499
+
11500
+ ${body}`);
11501
+ }
11502
+ }
11503
+ const log = envelope.Log;
11504
+ if (typeof log === "string" && log !== "") {
11505
+ notes.push(`**Log:** ${log}`);
11506
+ }
11507
+ return notes;
11508
+ }
11509
+ function renderMarkdown(data) {
11510
+ if (data.Result !== RESULTS.Success) {
11511
+ const failure = data;
11512
+ const sections = [`**Failed:** ${failure.Message}`];
11513
+ if (failure.Data != null) {
11514
+ sections.push(markdownPayload(failure.Data));
11515
+ }
11516
+ if (failure.Instructions) {
11517
+ sections.push(`> ${failure.Instructions}`);
11518
+ }
11519
+ return sections.filter((section) => section !== "").join(`
11520
+
11521
+ `);
11522
+ }
11523
+ if (!("Data" in data) || data.Data == null) {
11524
+ return markdownObject(withoutPlumbing(data), 0);
11525
+ }
11526
+ return [markdownPayload(data.Data), ...markdownEnvelopeNotes(data)].filter((section) => section !== "").join(`
11527
+
11528
+ `);
11529
+ }
11300
11530
  function toYaml(data) {
11301
11531
  const codec = getYamlCodec();
11302
11532
  if (!codec) {
@@ -13027,16 +13257,7 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
13027
13257
  errorMessage: location.source === "absolute" ? `Environment file not found: ${envFilePath}` : `Unable to locate environment file: ${envFilePath}. Run 'uip login' to authenticate.`
13028
13258
  };
13029
13259
  };
13030
- var loadEnvFileAsync = async ({ envPath }) => {
13031
- const fs2 = getFileSystem();
13032
- const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
13033
- if (!await fs2.exists(absolutePath)) {
13034
- throw new Error(`Environment file not found: ${envPath}`);
13035
- }
13036
- const content = await fs2.readFile(absolutePath, "utf-8");
13037
- if (content === null) {
13038
- throw new Error(`Environment file not found: ${envPath}`);
13039
- }
13260
+ var parseEnvContent = (content) => {
13040
13261
  const env = {};
13041
13262
  for (const line of content.split(`
13042
13263
  `)) {
@@ -13057,6 +13278,18 @@ var loadEnvFileAsync = async ({ envPath }) => {
13057
13278
  }
13058
13279
  return env;
13059
13280
  };
13281
+ var loadEnvFileAsync = async ({ envPath }) => {
13282
+ const fs2 = getFileSystem();
13283
+ const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
13284
+ if (!await fs2.exists(absolutePath)) {
13285
+ throw new Error(`Environment file not found: ${envPath}`);
13286
+ }
13287
+ const content = await fs2.readFile(absolutePath, "utf-8");
13288
+ if (content === null) {
13289
+ throw new Error(`Environment file not found: ${envPath}`);
13290
+ }
13291
+ return parseEnvContent(content);
13292
+ };
13060
13293
  var saveEnvFileAsync = async ({
13061
13294
  envPath,
13062
13295
  data,
@@ -22866,4 +23099,4 @@ var registerCommands = async (program2) => {
22866
23099
 
22867
23100
  export { Command, metadata, registerCommands };
22868
23101
 
22869
- //# debugId=20D6E8FA720599BB64756E2164756E21
23102
+ //# debugId=565B27783E2143F564756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-xrkfnz4j.js";
4
+ } from "./tool-fqjn81ft.js";
5
5
  import"./tool-1yh8g550.js";
6
6
  export {
7
7
  metadata,
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@uipath/docsai-tool",
3
+ "author": "UiPath",
3
4
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "1.202.0",
5
+ "version": "1.203.0-preview.160",
5
6
  "description": "Search UiPath documentation with AI-powered answers.",
6
7
  "private": false,
7
8
  "repository": {
@@ -26,5 +27,5 @@
26
27
  "files": [
27
28
  "dist"
28
29
  ],
29
- "gitHead": "23b5a7038ead7264439af18f8b807c7cc99a29d5"
30
+ "gitHead": "3a42062ba731afca4595ba9aa8a80afc9667528d"
30
31
  }