@uipath/context-grounding-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 +1 -1
- package/dist/{tool-ead665dg.js → tool-bbr21k09.js} +411 -88
- package/dist/tool.js +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -2609,7 +2609,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
|
|
|
2609
2609
|
var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
2610
2610
|
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
2611
2611
|
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
2612
|
-
var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
2612
|
+
var PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
2613
2613
|
var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
|
|
2614
2614
|
var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
|
|
2615
2615
|
var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
|
|
@@ -2656,7 +2656,7 @@ var QUOTED_LITERAL_PATTERN = new RegExp([
|
|
|
2656
2656
|
`(?<![A-Za-z0-9])"(?:[^\\
|
|
2657
2657
|
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
|
|
2658
2658
|
].join("|"), "g");
|
|
2659
|
-
var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
|
|
2659
|
+
var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
|
|
2660
2660
|
var COLLAPSED_BODY = "{…}";
|
|
2661
2661
|
var COLLAPSED_BODY_MARKER = "\x01body\x01";
|
|
2662
2662
|
var MAX_BODY_NESTING = 8;
|
|
@@ -2671,10 +2671,13 @@ function collapseJsonBodies(text) {
|
|
|
2671
2671
|
}
|
|
2672
2672
|
return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
|
|
2673
2673
|
}
|
|
2674
|
-
var TRAILING_PROSE_PUNCT =
|
|
2674
|
+
var TRAILING_PROSE_PUNCT = `.,;:!?)]}>'"`;
|
|
2675
2675
|
function peelTrailingPunctuation(match) {
|
|
2676
|
-
|
|
2677
|
-
|
|
2676
|
+
let end = match.length;
|
|
2677
|
+
while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
|
|
2678
|
+
end -= 1;
|
|
2679
|
+
}
|
|
2680
|
+
return [match.slice(0, end), match.slice(end)];
|
|
2678
2681
|
}
|
|
2679
2682
|
function redactUrl(raw) {
|
|
2680
2683
|
try {
|
|
@@ -3379,7 +3382,8 @@ function readRegistryValue(keyPath, valueName) {
|
|
|
3379
3382
|
}
|
|
3380
3383
|
const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
|
|
3381
3384
|
encoding: "utf-8",
|
|
3382
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
3385
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
3386
|
+
windowsHide: true
|
|
3383
3387
|
}));
|
|
3384
3388
|
if (error) {
|
|
3385
3389
|
return "";
|
|
@@ -4061,28 +4065,32 @@ function isPlainRecord(value) {
|
|
|
4061
4065
|
const prototype = Object.getPrototypeOf(value);
|
|
4062
4066
|
return prototype === Object.prototype || prototype === null;
|
|
4063
4067
|
}
|
|
4064
|
-
function
|
|
4068
|
+
function splitPagedEnvelope(value) {
|
|
4065
4069
|
if (Array.isArray(value) || !isPlainRecord(value))
|
|
4066
4070
|
return null;
|
|
4067
|
-
const entries = Object.
|
|
4071
|
+
const entries = Object.entries(value);
|
|
4068
4072
|
if (entries.length === 0)
|
|
4069
4073
|
return null;
|
|
4070
|
-
let
|
|
4071
|
-
|
|
4072
|
-
for (const entry of entries) {
|
|
4074
|
+
let found = null;
|
|
4075
|
+
const meta = Object.create(null);
|
|
4076
|
+
for (const [key, entry] of entries) {
|
|
4073
4077
|
if (Array.isArray(entry)) {
|
|
4074
|
-
if (
|
|
4078
|
+
if (found !== null)
|
|
4075
4079
|
return null;
|
|
4076
|
-
|
|
4080
|
+
found = { key, rows: entry };
|
|
4077
4081
|
} else if (entry !== null && typeof entry === "object") {
|
|
4078
4082
|
return null;
|
|
4079
4083
|
} else {
|
|
4080
|
-
|
|
4084
|
+
meta[key] = entry;
|
|
4081
4085
|
}
|
|
4082
4086
|
}
|
|
4083
|
-
if (
|
|
4087
|
+
if (found === null || Object.keys(meta).length === 0)
|
|
4084
4088
|
return null;
|
|
4085
|
-
return
|
|
4089
|
+
return { ...found, meta };
|
|
4090
|
+
}
|
|
4091
|
+
function extractPagedRows(value) {
|
|
4092
|
+
const paged = splitPagedEnvelope(value);
|
|
4093
|
+
return paged === null ? null : paged.rows;
|
|
4086
4094
|
}
|
|
4087
4095
|
function toLowerCamelCaseKey(key) {
|
|
4088
4096
|
if (!key)
|
|
@@ -4186,6 +4194,9 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
|
|
|
4186
4194
|
}
|
|
4187
4195
|
break;
|
|
4188
4196
|
}
|
|
4197
|
+
case "markdown":
|
|
4198
|
+
logFn(renderMarkdown(data));
|
|
4199
|
+
break;
|
|
4189
4200
|
default: {
|
|
4190
4201
|
const hasData = "Data" in data && data.Data != null;
|
|
4191
4202
|
const pagedRows = hasData ? extractPagedRows(data.Data) : null;
|
|
@@ -4210,6 +4221,10 @@ function logOutput(data, format = "json", tableRowStyle) {
|
|
|
4210
4221
|
printOutput(data, format, (msg) => sink.writeOut(`${msg}
|
|
4211
4222
|
`), needsAsciiSafeJson(sink), styleFn);
|
|
4212
4223
|
}
|
|
4224
|
+
var PLUMBING_KEYS = new Set(["code", "log"]);
|
|
4225
|
+
function isPlumbingKey(key) {
|
|
4226
|
+
return PLUMBING_KEYS.has(key.toLowerCase());
|
|
4227
|
+
}
|
|
4213
4228
|
function cellToString(val) {
|
|
4214
4229
|
return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
|
|
4215
4230
|
}
|
|
@@ -4225,7 +4240,7 @@ function wrapText(text, width) {
|
|
|
4225
4240
|
function printTable(data, logFn, externalLogValue, tableRowStyle) {
|
|
4226
4241
|
if (data.length === 0)
|
|
4227
4242
|
return;
|
|
4228
|
-
const keys = Object.keys(data[0]).filter((key) => !
|
|
4243
|
+
const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
|
|
4229
4244
|
const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
|
|
4230
4245
|
const header = keys.map((key, i) => key.padEnd(maxWidths[i])).join(" | ");
|
|
4231
4246
|
logFn(header);
|
|
@@ -4247,7 +4262,7 @@ function isNonEmptyPlainObject(value) {
|
|
|
4247
4262
|
}
|
|
4248
4263
|
var NESTED_INDENT = " ";
|
|
4249
4264
|
function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
4250
|
-
const keys = Object.keys(data).filter((key) => !
|
|
4265
|
+
const keys = Object.keys(data).filter((key) => !isPlumbingKey(key));
|
|
4251
4266
|
if (keys.length === 0)
|
|
4252
4267
|
return;
|
|
4253
4268
|
const isBlockValue = (value) => isPlainObjectArray(value) || isNonEmptyPlainObject(value);
|
|
@@ -4278,7 +4293,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
|
4278
4293
|
function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
|
|
4279
4294
|
if (data.length === 0)
|
|
4280
4295
|
return;
|
|
4281
|
-
const keys = Object.keys(data[0]).filter((key) => !
|
|
4296
|
+
const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
|
|
4282
4297
|
if (keys.length === 0)
|
|
4283
4298
|
return;
|
|
4284
4299
|
if (!process.stdout.isTTY) {
|
|
@@ -4352,6 +4367,220 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
4352
4367
|
logFn(`Log: ${externalLogValue}`);
|
|
4353
4368
|
}
|
|
4354
4369
|
}
|
|
4370
|
+
var MARKDOWN_MAX_CELL = 200;
|
|
4371
|
+
var MARKDOWN_MAX_DEPTH = 3;
|
|
4372
|
+
function markdownHeading(depth) {
|
|
4373
|
+
return "#".repeat(Math.min(3 + depth, 6));
|
|
4374
|
+
}
|
|
4375
|
+
var BACKTICK_RUN = /`+/g;
|
|
4376
|
+
function fencedBlock(text) {
|
|
4377
|
+
const first = text.trimStart()[0];
|
|
4378
|
+
const language = first === "<" ? "xml" : first === "{" || first === "[" ? "json" : "";
|
|
4379
|
+
const longestRun = Math.max(0, ...Array.from(text.matchAll(BACKTICK_RUN), (match) => match[0].length));
|
|
4380
|
+
const fence = "`".repeat(Math.max(3, longestRun + 1));
|
|
4381
|
+
return `${fence}${language}
|
|
4382
|
+
${text}
|
|
4383
|
+
${fence}`;
|
|
4384
|
+
}
|
|
4385
|
+
function collapseNewlineRuns(text) {
|
|
4386
|
+
return text.split(/(\s+)/).map((part, index) => index % 2 === 1 && part.includes(`
|
|
4387
|
+
`) ? " " : part).join("");
|
|
4388
|
+
}
|
|
4389
|
+
function markdownCell(value) {
|
|
4390
|
+
const text = value instanceof Date ? value.toISOString() : cellToString(value);
|
|
4391
|
+
return collapseNewlineRuns(text).replace(/\|/g, "\\|");
|
|
4392
|
+
}
|
|
4393
|
+
function markdownLabel(key) {
|
|
4394
|
+
return collapseNewlineRuns(key).replace(/[\\`*|]/g, "\\$&");
|
|
4395
|
+
}
|
|
4396
|
+
function withoutPlumbing(record) {
|
|
4397
|
+
const kept = Object.create(null);
|
|
4398
|
+
for (const [key, value] of Object.entries(record)) {
|
|
4399
|
+
if (!isPlumbingKey(key))
|
|
4400
|
+
kept[key] = value;
|
|
4401
|
+
}
|
|
4402
|
+
return kept;
|
|
4403
|
+
}
|
|
4404
|
+
function rowsWithoutPlumbing(rows) {
|
|
4405
|
+
return rows.map((row) => isPlainRecord(row) ? withoutPlumbing(row) : row);
|
|
4406
|
+
}
|
|
4407
|
+
function markdownTable(rows) {
|
|
4408
|
+
const columns = [];
|
|
4409
|
+
const seen = new Set;
|
|
4410
|
+
for (const row of rows) {
|
|
4411
|
+
for (const key of Object.keys(row)) {
|
|
4412
|
+
if (!seen.has(key)) {
|
|
4413
|
+
seen.add(key);
|
|
4414
|
+
columns.push(key);
|
|
4415
|
+
}
|
|
4416
|
+
}
|
|
4417
|
+
}
|
|
4418
|
+
if (columns.length === 0)
|
|
4419
|
+
return null;
|
|
4420
|
+
const cells = rows.map((row) => columns.map((key) => markdownCell(row[key])));
|
|
4421
|
+
if (cells.some((row) => row.some((c) => c.length > MARKDOWN_MAX_CELL))) {
|
|
4422
|
+
return null;
|
|
4423
|
+
}
|
|
4424
|
+
return [
|
|
4425
|
+
`| ${columns.map(markdownLabel).join(" | ")} |`,
|
|
4426
|
+
`| ${columns.map(() => "---").join(" | ")} |`,
|
|
4427
|
+
...cells.map((row) => `| ${row.join(" | ")} |`)
|
|
4428
|
+
].join(`
|
|
4429
|
+
`);
|
|
4430
|
+
}
|
|
4431
|
+
function extractMessageSequence(rows) {
|
|
4432
|
+
const messages = [];
|
|
4433
|
+
for (const row of rows) {
|
|
4434
|
+
const message = extractSingleMessage(row);
|
|
4435
|
+
if (message === null)
|
|
4436
|
+
return null;
|
|
4437
|
+
messages.push(message);
|
|
4438
|
+
}
|
|
4439
|
+
return messages.join(`
|
|
4440
|
+
|
|
4441
|
+
`);
|
|
4442
|
+
}
|
|
4443
|
+
function markdownRows(rows, depth) {
|
|
4444
|
+
if (rows.length === 0)
|
|
4445
|
+
return "(none)";
|
|
4446
|
+
if (!isPlainObjectArray(rows)) {
|
|
4447
|
+
return rows.map((item) => `- ${markdownCell(item)}`).join(`
|
|
4448
|
+
`);
|
|
4449
|
+
}
|
|
4450
|
+
const prose = extractMessageSequence(rows);
|
|
4451
|
+
if (prose !== null)
|
|
4452
|
+
return prose;
|
|
4453
|
+
const table = markdownTable(rows);
|
|
4454
|
+
if (table !== null)
|
|
4455
|
+
return table;
|
|
4456
|
+
if (depth >= MARKDOWN_MAX_DEPTH) {
|
|
4457
|
+
return fencedBlock(JSON.stringify(rows, null, 2));
|
|
4458
|
+
}
|
|
4459
|
+
return rows.map((row, index) => [
|
|
4460
|
+
`${markdownHeading(depth)} ${index + 1}`,
|
|
4461
|
+
markdownObject(row, depth + 1)
|
|
4462
|
+
].join(`
|
|
4463
|
+
|
|
4464
|
+
`)).join(`
|
|
4465
|
+
|
|
4466
|
+
`);
|
|
4467
|
+
}
|
|
4468
|
+
function markdownObject(obj, depth) {
|
|
4469
|
+
const scalars = [];
|
|
4470
|
+
const blocks = [];
|
|
4471
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
4472
|
+
if (value === undefined)
|
|
4473
|
+
continue;
|
|
4474
|
+
const label = markdownLabel(key);
|
|
4475
|
+
if (Array.isArray(value)) {
|
|
4476
|
+
blocks.push(`${markdownHeading(depth)} ${label}
|
|
4477
|
+
|
|
4478
|
+
${markdownRows(value, depth + 1)}`);
|
|
4479
|
+
} else if (isNonEmptyPlainObject(value)) {
|
|
4480
|
+
const nested = depth < MARKDOWN_MAX_DEPTH ? markdownObject(value, depth + 1) : fencedBlock(JSON.stringify(value, null, 2));
|
|
4481
|
+
if (nested !== "") {
|
|
4482
|
+
blocks.push(`${markdownHeading(depth)} ${label}
|
|
4483
|
+
|
|
4484
|
+
${nested}`);
|
|
4485
|
+
}
|
|
4486
|
+
} else if (typeof value === "string" && value.includes(`
|
|
4487
|
+
`)) {
|
|
4488
|
+
blocks.push(`**${label}:**
|
|
4489
|
+
|
|
4490
|
+
${fencedBlock(value)}`);
|
|
4491
|
+
} else {
|
|
4492
|
+
scalars.push(`**${label}:** ${markdownCell(value)}`);
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
4495
|
+
const sections = scalars.length > 0 ? [scalars.join(`
|
|
4496
|
+
`)] : [];
|
|
4497
|
+
sections.push(...blocks);
|
|
4498
|
+
return sections.join(`
|
|
4499
|
+
|
|
4500
|
+
`);
|
|
4501
|
+
}
|
|
4502
|
+
function extractSingleMessage(payload) {
|
|
4503
|
+
if (!isPlainRecord(payload))
|
|
4504
|
+
return null;
|
|
4505
|
+
const keys = Object.keys(payload);
|
|
4506
|
+
if (keys.length !== 1 || keys[0].toLowerCase() !== "message")
|
|
4507
|
+
return null;
|
|
4508
|
+
const value = payload[keys[0]];
|
|
4509
|
+
return typeof value === "string" ? value : null;
|
|
4510
|
+
}
|
|
4511
|
+
function markdownPayload(payload) {
|
|
4512
|
+
const message = extractSingleMessage(payload);
|
|
4513
|
+
if (message !== null)
|
|
4514
|
+
return message;
|
|
4515
|
+
if (Array.isArray(payload)) {
|
|
4516
|
+
return markdownRows(rowsWithoutPlumbing(payload), 0);
|
|
4517
|
+
}
|
|
4518
|
+
const visible = withoutPlumbing(payload);
|
|
4519
|
+
const paged = splitPagedEnvelope(visible);
|
|
4520
|
+
if (paged !== null) {
|
|
4521
|
+
const meta = markdownObject(paged.meta, 0);
|
|
4522
|
+
const rows = `${markdownHeading(0)} ${markdownLabel(paged.key)}
|
|
4523
|
+
|
|
4524
|
+
${markdownRows(rowsWithoutPlumbing(paged.rows), 1)}`;
|
|
4525
|
+
return meta === "" ? rows : `${meta}
|
|
4526
|
+
|
|
4527
|
+
${rows}`;
|
|
4528
|
+
}
|
|
4529
|
+
return markdownObject(visible, 0);
|
|
4530
|
+
}
|
|
4531
|
+
function isPaginationWorthShowing(value) {
|
|
4532
|
+
if (typeof value !== "object" || value === null)
|
|
4533
|
+
return false;
|
|
4534
|
+
const page = value;
|
|
4535
|
+
return page.HasMore === true || typeof page.Offset === "number" && page.Offset > 0;
|
|
4536
|
+
}
|
|
4537
|
+
function markdownEnvelopeNotes(data) {
|
|
4538
|
+
const envelope = data;
|
|
4539
|
+
const notes = [];
|
|
4540
|
+
const warning = envelope.Warning;
|
|
4541
|
+
if (typeof warning === "string" && warning !== "") {
|
|
4542
|
+
notes.push(`> **Warning:** ${warning}`);
|
|
4543
|
+
}
|
|
4544
|
+
const instructions = envelope.Instructions;
|
|
4545
|
+
if (typeof instructions === "string" && instructions !== "") {
|
|
4546
|
+
notes.push(`> ${instructions}`);
|
|
4547
|
+
}
|
|
4548
|
+
const pagination = envelope.Pagination;
|
|
4549
|
+
if (isPaginationWorthShowing(pagination)) {
|
|
4550
|
+
const body = markdownObject(pagination, 1);
|
|
4551
|
+
if (body !== "") {
|
|
4552
|
+
notes.push(`${markdownHeading(0)} Pagination
|
|
4553
|
+
|
|
4554
|
+
${body}`);
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
const log = envelope.Log;
|
|
4558
|
+
if (typeof log === "string" && log !== "") {
|
|
4559
|
+
notes.push(`**Log:** ${log}`);
|
|
4560
|
+
}
|
|
4561
|
+
return notes;
|
|
4562
|
+
}
|
|
4563
|
+
function renderMarkdown(data) {
|
|
4564
|
+
if (data.Result !== RESULTS.Success) {
|
|
4565
|
+
const failure = data;
|
|
4566
|
+
const sections = [`**Failed:** ${failure.Message}`];
|
|
4567
|
+
if (failure.Data != null) {
|
|
4568
|
+
sections.push(markdownPayload(failure.Data));
|
|
4569
|
+
}
|
|
4570
|
+
if (failure.Instructions) {
|
|
4571
|
+
sections.push(`> ${failure.Instructions}`);
|
|
4572
|
+
}
|
|
4573
|
+
return sections.filter((section) => section !== "").join(`
|
|
4574
|
+
|
|
4575
|
+
`);
|
|
4576
|
+
}
|
|
4577
|
+
if (!("Data" in data) || data.Data == null) {
|
|
4578
|
+
return markdownObject(withoutPlumbing(data), 0);
|
|
4579
|
+
}
|
|
4580
|
+
return [markdownPayload(data.Data), ...markdownEnvelopeNotes(data)].filter((section) => section !== "").join(`
|
|
4581
|
+
|
|
4582
|
+
`);
|
|
4583
|
+
}
|
|
4355
4584
|
function toYaml(data) {
|
|
4356
4585
|
const codec = getYamlCodec();
|
|
4357
4586
|
if (!codec) {
|
|
@@ -6160,16 +6389,7 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
|
|
|
6160
6389
|
errorMessage: location.source === "absolute" ? `Environment file not found: ${envFilePath}` : `Unable to locate environment file: ${envFilePath}. Run 'uip login' to authenticate.`
|
|
6161
6390
|
};
|
|
6162
6391
|
};
|
|
6163
|
-
var
|
|
6164
|
-
const fs2 = getFileSystem();
|
|
6165
|
-
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
|
|
6166
|
-
if (!await fs2.exists(absolutePath)) {
|
|
6167
|
-
throw new Error(`Environment file not found: ${envPath}`);
|
|
6168
|
-
}
|
|
6169
|
-
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
6170
|
-
if (content === null) {
|
|
6171
|
-
throw new Error(`Environment file not found: ${envPath}`);
|
|
6172
|
-
}
|
|
6392
|
+
var parseEnvContent = (content) => {
|
|
6173
6393
|
const env = {};
|
|
6174
6394
|
for (const line of content.split(`
|
|
6175
6395
|
`)) {
|
|
@@ -6190,6 +6410,18 @@ var loadEnvFileAsync = async ({ envPath }) => {
|
|
|
6190
6410
|
}
|
|
6191
6411
|
return env;
|
|
6192
6412
|
};
|
|
6413
|
+
var loadEnvFileAsync = async ({ envPath }) => {
|
|
6414
|
+
const fs2 = getFileSystem();
|
|
6415
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
|
|
6416
|
+
if (!await fs2.exists(absolutePath)) {
|
|
6417
|
+
throw new Error(`Environment file not found: ${envPath}`);
|
|
6418
|
+
}
|
|
6419
|
+
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
6420
|
+
if (content === null) {
|
|
6421
|
+
throw new Error(`Environment file not found: ${envPath}`);
|
|
6422
|
+
}
|
|
6423
|
+
return parseEnvContent(content);
|
|
6424
|
+
};
|
|
6193
6425
|
var saveEnvFileAsync = async ({
|
|
6194
6426
|
envPath,
|
|
6195
6427
|
data,
|
|
@@ -6796,7 +7028,8 @@ var fail = (reason, message, instructions, extras = {}) => ({
|
|
|
6796
7028
|
async function runUipathPythonCommand(args, options = {}) {
|
|
6797
7029
|
const fs2 = getFileSystem();
|
|
6798
7030
|
const cacheFile = fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
|
|
6799
|
-
const
|
|
7031
|
+
const setupCommand = `uip ${options.commandPrefix ?? "codedagent"} setup`;
|
|
7032
|
+
const setupHint = `Run '${setupCommand}' first to configure the environment. ` + `Activate the project's virtual environment and run ${setupCommand} --force.`;
|
|
6800
7033
|
const cache = await readCache(cacheFile);
|
|
6801
7034
|
if (!cache?.uipathExePath) {
|
|
6802
7035
|
return fail("python_not_configured", "Python not configured.", setupHint);
|
|
@@ -6945,67 +7178,42 @@ class PythonService {
|
|
|
6945
7178
|
return result;
|
|
6946
7179
|
}
|
|
6947
7180
|
async _setupInternal(packageName, force) {
|
|
6948
|
-
const
|
|
6949
|
-
let pythonPath;
|
|
6950
|
-
let version;
|
|
7181
|
+
const virtualEnv = process.env.VIRTUAL_ENV || undefined;
|
|
6951
7182
|
if (!force) {
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
pythonPath = cached.pythonPath;
|
|
6956
|
-
version = cached.version;
|
|
6957
|
-
this.uipathExePath = cached.uipathExePath;
|
|
6958
|
-
logger.info(`Using cached uipath executable: ${this.uipathExePath}`);
|
|
6959
|
-
this.packageVersion = cached.packageVersion;
|
|
6960
|
-
if (!this.packageVersion) {
|
|
6961
|
-
const versionResult2 = await this.getUipathVersion(this.uipathExePath);
|
|
6962
|
-
if ("error" in versionResult2) {
|
|
6963
|
-
return {
|
|
6964
|
-
success: false,
|
|
6965
|
-
pythonPath,
|
|
6966
|
-
pythonVersion: version,
|
|
6967
|
-
packageInstalled: true,
|
|
6968
|
-
error: versionResult2.error
|
|
6969
|
-
};
|
|
6970
|
-
}
|
|
6971
|
-
this.packageVersion = versionResult2.version;
|
|
6972
|
-
}
|
|
6973
|
-
await this.saveCache({
|
|
6974
|
-
pythonPath,
|
|
6975
|
-
version,
|
|
6976
|
-
lastValidated: new Date().toISOString(),
|
|
6977
|
-
packageName,
|
|
6978
|
-
uipathExePath: this.uipathExePath,
|
|
6979
|
-
packageVersion: this.packageVersion
|
|
6980
|
-
});
|
|
6981
|
-
return {
|
|
6982
|
-
success: true,
|
|
6983
|
-
pythonPath,
|
|
6984
|
-
pythonVersion: version,
|
|
6985
|
-
packageInstalled: true,
|
|
6986
|
-
packageVersion: this.packageVersion
|
|
6987
|
-
};
|
|
6988
|
-
} else if (cached) {
|
|
6989
|
-
logger.warn("Cached Python path no longer exists, re-detecting...");
|
|
6990
|
-
}
|
|
7183
|
+
const reused = await this.reuseCache(packageName, virtualEnv);
|
|
7184
|
+
if (reused)
|
|
7185
|
+
return reused;
|
|
6991
7186
|
}
|
|
6992
7187
|
logger.info("Checking Python...");
|
|
6993
|
-
const detection = await this.detectPython();
|
|
7188
|
+
const detection = virtualEnv ? await this.detectVenvPython(virtualEnv) : await this.detectPython();
|
|
6994
7189
|
if (!detection.success || !detection.pythonPath || !detection.version) {
|
|
6995
7190
|
return {
|
|
6996
7191
|
success: false,
|
|
6997
7192
|
error: detection.error || "Failed to detect Python"
|
|
6998
7193
|
};
|
|
6999
7194
|
}
|
|
7000
|
-
pythonPath = detection.pythonPath;
|
|
7001
|
-
version = detection.version;
|
|
7195
|
+
const pythonPath = detection.pythonPath;
|
|
7196
|
+
const version = detection.version;
|
|
7197
|
+
const source = detection.source ?? "path";
|
|
7002
7198
|
this.uipathExePath = detection.uipathExePath;
|
|
7003
7199
|
if (!this.uipathExePath) {
|
|
7200
|
+
if (virtualEnv) {
|
|
7201
|
+
return {
|
|
7202
|
+
success: false,
|
|
7203
|
+
pythonPath,
|
|
7204
|
+
pythonVersion: version,
|
|
7205
|
+
packageInstalled: false,
|
|
7206
|
+
source,
|
|
7207
|
+
error: `Package '${packageName}' is not installed in the active virtual environment: ${virtualEnv}`,
|
|
7208
|
+
instructions: `Install it inside the active virtual environment (uv pip install ${packageName} or the framework package), then re-run uip codedagent setup --force.`
|
|
7209
|
+
};
|
|
7210
|
+
}
|
|
7004
7211
|
return {
|
|
7005
7212
|
success: false,
|
|
7006
7213
|
pythonPath,
|
|
7007
7214
|
pythonVersion: version,
|
|
7008
7215
|
packageInstalled: false,
|
|
7216
|
+
source,
|
|
7009
7217
|
error: `Package '${packageName}' is not installed.
|
|
7010
7218
|
|
|
7011
7219
|
To install the package, run:
|
|
@@ -7019,6 +7227,8 @@ To install the package, run:
|
|
|
7019
7227
|
pythonPath,
|
|
7020
7228
|
pythonVersion: version,
|
|
7021
7229
|
packageInstalled: true,
|
|
7230
|
+
uipathExePath: this.uipathExePath,
|
|
7231
|
+
source,
|
|
7022
7232
|
error: versionResult.error
|
|
7023
7233
|
};
|
|
7024
7234
|
}
|
|
@@ -7029,14 +7239,104 @@ To install the package, run:
|
|
|
7029
7239
|
lastValidated: new Date().toISOString(),
|
|
7030
7240
|
packageName,
|
|
7031
7241
|
uipathExePath: this.uipathExePath,
|
|
7032
|
-
packageVersion: this.packageVersion
|
|
7242
|
+
packageVersion: this.packageVersion,
|
|
7243
|
+
source
|
|
7244
|
+
});
|
|
7245
|
+
return {
|
|
7246
|
+
success: true,
|
|
7247
|
+
pythonPath,
|
|
7248
|
+
pythonVersion: version,
|
|
7249
|
+
packageInstalled: true,
|
|
7250
|
+
packageVersion: this.packageVersion,
|
|
7251
|
+
uipathExePath: this.uipathExePath,
|
|
7252
|
+
source
|
|
7253
|
+
};
|
|
7254
|
+
}
|
|
7255
|
+
async reuseCache(packageName, virtualEnv) {
|
|
7256
|
+
const fs2 = getFileSystem();
|
|
7257
|
+
logger.debug("Checking cache...");
|
|
7258
|
+
const cached = await this.loadCache();
|
|
7259
|
+
if (!cached)
|
|
7260
|
+
return null;
|
|
7261
|
+
if (!cached.uipathExePath || !await fs2.exists(cached.uipathExePath)) {
|
|
7262
|
+
logger.warn("Cached Python path no longer exists, re-detecting...");
|
|
7263
|
+
return null;
|
|
7264
|
+
}
|
|
7265
|
+
if (virtualEnv && !isPathInside(cached.uipathExePath, virtualEnv)) {
|
|
7266
|
+
logger.warn(`Cached uipath executable ${cached.uipathExePath} is outside the active virtual environment ${virtualEnv}, re-detecting...`);
|
|
7267
|
+
return null;
|
|
7268
|
+
}
|
|
7269
|
+
const pythonPath = cached.pythonPath;
|
|
7270
|
+
const version = cached.version;
|
|
7271
|
+
this.uipathExePath = cached.uipathExePath;
|
|
7272
|
+
const source = cached.source ?? (virtualEnv ? "venv" : "path");
|
|
7273
|
+
logger.info(`Using cached uipath executable: ${this.uipathExePath}`);
|
|
7274
|
+
this.packageVersion = cached.packageVersion;
|
|
7275
|
+
if (!this.packageVersion) {
|
|
7276
|
+
const versionResult = await this.getUipathVersion(this.uipathExePath);
|
|
7277
|
+
if ("error" in versionResult) {
|
|
7278
|
+
return {
|
|
7279
|
+
success: false,
|
|
7280
|
+
pythonPath,
|
|
7281
|
+
pythonVersion: version,
|
|
7282
|
+
packageInstalled: true,
|
|
7283
|
+
uipathExePath: this.uipathExePath,
|
|
7284
|
+
source,
|
|
7285
|
+
error: versionResult.error
|
|
7286
|
+
};
|
|
7287
|
+
}
|
|
7288
|
+
this.packageVersion = versionResult.version;
|
|
7289
|
+
}
|
|
7290
|
+
await this.saveCache({
|
|
7291
|
+
pythonPath,
|
|
7292
|
+
version,
|
|
7293
|
+
lastValidated: new Date().toISOString(),
|
|
7294
|
+
packageName,
|
|
7295
|
+
uipathExePath: this.uipathExePath,
|
|
7296
|
+
packageVersion: this.packageVersion,
|
|
7297
|
+
source
|
|
7033
7298
|
});
|
|
7034
7299
|
return {
|
|
7035
7300
|
success: true,
|
|
7036
7301
|
pythonPath,
|
|
7037
7302
|
pythonVersion: version,
|
|
7038
7303
|
packageInstalled: true,
|
|
7039
|
-
packageVersion: this.packageVersion
|
|
7304
|
+
packageVersion: this.packageVersion,
|
|
7305
|
+
uipathExePath: this.uipathExePath,
|
|
7306
|
+
source
|
|
7307
|
+
};
|
|
7308
|
+
}
|
|
7309
|
+
async detectVenvPython(virtualEnv) {
|
|
7310
|
+
const fs2 = getFileSystem();
|
|
7311
|
+
const isWindows = platform() === "win32";
|
|
7312
|
+
const command = isWindows ? fs2.path.join(virtualEnv, "Scripts", "python.exe") : fs2.path.join(virtualEnv, "bin", "python");
|
|
7313
|
+
const checkedVersions = [];
|
|
7314
|
+
const searchedCommands = [];
|
|
7315
|
+
const version = await this.checkPythonVersion(command, [], checkedVersions, searchedCommands);
|
|
7316
|
+
if (!version) {
|
|
7317
|
+
return {
|
|
7318
|
+
success: false,
|
|
7319
|
+
error: this.buildNotFoundError(checkedVersions, searchedCommands)
|
|
7320
|
+
};
|
|
7321
|
+
}
|
|
7322
|
+
const metadataPath = await this.findUipathExeFromMetadata(fs2, command, []);
|
|
7323
|
+
let uipathExePath = metadataPath;
|
|
7324
|
+
if (!uipathExePath) {
|
|
7325
|
+
const candidate = isWindows ? fs2.path.join(virtualEnv, "Scripts", "uipath.exe") : fs2.path.join(virtualEnv, "bin", "uipath");
|
|
7326
|
+
logger.debug(`Checking for uipath executable at: ${candidate}`);
|
|
7327
|
+
if (await fs2.exists(candidate)) {
|
|
7328
|
+
logger.info(`Found uipath executable at: ${candidate}`);
|
|
7329
|
+
uipathExePath = candidate;
|
|
7330
|
+
} else {
|
|
7331
|
+
logger.error(`uipath executable not found in virtual environment. Checked: ${candidate}`);
|
|
7332
|
+
}
|
|
7333
|
+
}
|
|
7334
|
+
return {
|
|
7335
|
+
success: true,
|
|
7336
|
+
pythonPath: command,
|
|
7337
|
+
version,
|
|
7338
|
+
uipathExePath,
|
|
7339
|
+
source: "venv"
|
|
7040
7340
|
};
|
|
7041
7341
|
}
|
|
7042
7342
|
async detectPython() {
|
|
@@ -7055,6 +7355,20 @@ To install the package, run:
|
|
|
7055
7355
|
}
|
|
7056
7356
|
async checkPythonCommand(command, args, checkedVersions, searchedCommands) {
|
|
7057
7357
|
const fs2 = getFileSystem();
|
|
7358
|
+
const version = await this.checkPythonVersion(command, args, checkedVersions, searchedCommands);
|
|
7359
|
+
if (!version)
|
|
7360
|
+
return null;
|
|
7361
|
+
const commandStr = args.length > 0 ? `${command} ${args.join(" ")}` : command;
|
|
7362
|
+
const uipathExePath = await this.findUipathExe(fs2, command, args);
|
|
7363
|
+
return {
|
|
7364
|
+
success: true,
|
|
7365
|
+
pythonPath: commandStr,
|
|
7366
|
+
version,
|
|
7367
|
+
uipathExePath,
|
|
7368
|
+
source: "path"
|
|
7369
|
+
};
|
|
7370
|
+
}
|
|
7371
|
+
async checkPythonVersion(command, args, checkedVersions, searchedCommands) {
|
|
7058
7372
|
const commandStr = args.length > 0 ? `${command} ${args.join(" ")}` : command;
|
|
7059
7373
|
searchedCommands.push(commandStr);
|
|
7060
7374
|
logger.debug(`Checking Python command: ${commandStr}`);
|
|
@@ -7092,13 +7406,7 @@ To install the package, run:
|
|
|
7092
7406
|
return null;
|
|
7093
7407
|
}
|
|
7094
7408
|
logger.info(`Found valid Python: ${commandStr} - ${version}`);
|
|
7095
|
-
|
|
7096
|
-
return {
|
|
7097
|
-
success: true,
|
|
7098
|
-
pythonPath: commandStr,
|
|
7099
|
-
version,
|
|
7100
|
-
uipathExePath
|
|
7101
|
-
};
|
|
7409
|
+
return version;
|
|
7102
7410
|
}
|
|
7103
7411
|
async findUipathExe(fs2, command, args) {
|
|
7104
7412
|
const metadataPath = await this.findUipathExeFromMetadata(fs2, command, args);
|
|
@@ -7136,6 +7444,7 @@ To install the package, run:
|
|
|
7136
7444
|
async findUipathExeFromMetadata(fs2, command, args) {
|
|
7137
7445
|
const script = `
|
|
7138
7446
|
from importlib.metadata import distribution, PackageNotFoundError
|
|
7447
|
+
import os
|
|
7139
7448
|
import sys
|
|
7140
7449
|
try:
|
|
7141
7450
|
d = distribution("uipath")
|
|
@@ -7143,7 +7452,7 @@ except PackageNotFoundError:
|
|
|
7143
7452
|
sys.exit(2)
|
|
7144
7453
|
for f in d.files or []:
|
|
7145
7454
|
if f.name.lower() in ("uipath", "uipath.exe"):
|
|
7146
|
-
print(str(f.locate()))
|
|
7455
|
+
print(os.path.normpath(str(f.locate())))
|
|
7147
7456
|
sys.exit(0)
|
|
7148
7457
|
sys.exit(3)
|
|
7149
7458
|
`;
|
|
@@ -7328,6 +7637,17 @@ Please install one of the required Python versions:
|
|
|
7328
7637
|
logger.info(`Cache saved to ${this.cacheFile}`);
|
|
7329
7638
|
}
|
|
7330
7639
|
}
|
|
7640
|
+
function isPathInside(target, root) {
|
|
7641
|
+
const normalize = (value) => {
|
|
7642
|
+
let normalized = value.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
7643
|
+
if (platform() === "win32")
|
|
7644
|
+
normalized = normalized.toLowerCase();
|
|
7645
|
+
return normalized;
|
|
7646
|
+
};
|
|
7647
|
+
const normalizedTarget = normalize(target);
|
|
7648
|
+
const normalizedRoot = normalize(root);
|
|
7649
|
+
return normalizedTarget === normalizedRoot || normalizedTarget.startsWith(`${normalizedRoot}/`);
|
|
7650
|
+
}
|
|
7331
7651
|
// ../uipath-python-bridge/src/register.ts
|
|
7332
7652
|
function createSetupCommand(config) {
|
|
7333
7653
|
return (program2) => {
|
|
@@ -7377,7 +7697,9 @@ Searching for Python installations: ${allowedVersions}`);
|
|
|
7377
7697
|
PythonPath: result.pythonPath,
|
|
7378
7698
|
Package: packageName,
|
|
7379
7699
|
PackageInstalled: result.packageInstalled ? "Yes" : "No",
|
|
7380
|
-
PackageVersion: result.packageVersion ?? "N/A"
|
|
7700
|
+
PackageVersion: result.packageVersion ?? "N/A",
|
|
7701
|
+
UipathPath: result.uipathExePath,
|
|
7702
|
+
Source: result.source
|
|
7381
7703
|
}
|
|
7382
7704
|
});
|
|
7383
7705
|
processContext.exit(0);
|
|
@@ -7416,8 +7738,9 @@ function createCommandForwarder(executeCommand) {
|
|
|
7416
7738
|
// package.json
|
|
7417
7739
|
var package_default = {
|
|
7418
7740
|
name: "@uipath/context-grounding-tool",
|
|
7741
|
+
author: "UiPath",
|
|
7419
7742
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
7420
|
-
version: "1.
|
|
7743
|
+
version: "1.203.0-preview.160",
|
|
7421
7744
|
description: "Tool for context grounding operations via the UiPath Python SDK",
|
|
7422
7745
|
keywords: [
|
|
7423
7746
|
"uipcli-tool",
|
|
@@ -7518,4 +7841,4 @@ var registerCommands = async (program2) => {
|
|
|
7518
7841
|
|
|
7519
7842
|
export { Command, metadata, registerCommands };
|
|
7520
7843
|
|
|
7521
|
-
//# debugId=
|
|
7844
|
+
//# debugId=3F2BC1EEC05449AD64756E2164756E21
|
package/dist/tool.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/context-grounding-tool",
|
|
3
|
+
"author": "UiPath",
|
|
3
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
4
|
-
"version": "1.
|
|
5
|
+
"version": "1.203.0-preview.160",
|
|
5
6
|
"description": "Tool for context grounding operations via the UiPath Python SDK",
|
|
6
7
|
"keywords": [
|
|
7
8
|
"uipcli-tool",
|
|
@@ -28,5 +29,5 @@
|
|
|
28
29
|
"publishConfig": {
|
|
29
30
|
"registry": "https://registry.npmjs.org/"
|
|
30
31
|
},
|
|
31
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "3a42062ba731afca4595ba9aa8a80afc9667528d"
|
|
32
33
|
}
|