@uipath/codedagent-tool 1.202.0-preview.159 → 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 +2 -2
- package/dist/init.js +1 -1
- package/dist/{tool-73f5y4x8.js → tool-etst5h2w.js} +409 -87
- package/dist/{tool-zsdzq4nj.js → tool-g1mphjyy.js} +18 -13
- package/dist/tool.js +2 -2
- package/package.json +3 -2
package/dist/index.js
CHANGED
package/dist/init.js
CHANGED
|
@@ -2395,7 +2395,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
|
|
|
2395
2395
|
var EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
2396
2396
|
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
2397
2397
|
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
2398
|
-
var PADDED_BASE64_PATTERN = /[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
2398
|
+
var PADDED_BASE64_PATTERN = /(?<![A-Za-z0-9+/])[A-Za-z0-9+/]{16,}={1,2}(?![A-Za-z0-9+/=])/g;
|
|
2399
2399
|
var BASE64_WITH_PLUS_PATTERN = /[A-Za-z0-9+/]{40,}/g;
|
|
2400
2400
|
var USER_HOME_PATTERN = /(?<![A-Za-z0-9._-])([/\\])(Users|home|Profiles)([/\\])([^/\\]+)/gi;
|
|
2401
2401
|
var UNC_PATH_PATTERN = /(^|[\s"'<>|=,;([{])(\\\\[^\s"'<>|]+)/g;
|
|
@@ -2442,7 +2442,7 @@ var QUOTED_LITERAL_PATTERN = new RegExp([
|
|
|
2442
2442
|
`(?<![A-Za-z0-9])"(?:[^\\
|
|
2443
2443
|
]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
|
|
2444
2444
|
].join("|"), "g");
|
|
2445
|
-
var JSON_BODY_PATTERN = /[{[][^{}[\]]*[:,][^{}[\]]*[\]}]/g;
|
|
2445
|
+
var JSON_BODY_PATTERN = /[{[][^{}[\]:,]*[:,][^{}[\]]*[\]}]/g;
|
|
2446
2446
|
var COLLAPSED_BODY = "{…}";
|
|
2447
2447
|
var COLLAPSED_BODY_MARKER = "\x01body\x01";
|
|
2448
2448
|
var MAX_BODY_NESTING = 8;
|
|
@@ -2457,10 +2457,13 @@ function collapseJsonBodies(text) {
|
|
|
2457
2457
|
}
|
|
2458
2458
|
return out.split(COLLAPSED_BODY_MARKER).join(COLLAPSED_BODY);
|
|
2459
2459
|
}
|
|
2460
|
-
var TRAILING_PROSE_PUNCT =
|
|
2460
|
+
var TRAILING_PROSE_PUNCT = `.,;:!?)]}>'"`;
|
|
2461
2461
|
function peelTrailingPunctuation(match) {
|
|
2462
|
-
|
|
2463
|
-
|
|
2462
|
+
let end = match.length;
|
|
2463
|
+
while (end > 0 && TRAILING_PROSE_PUNCT.includes(match[end - 1])) {
|
|
2464
|
+
end -= 1;
|
|
2465
|
+
}
|
|
2466
|
+
return [match.slice(0, end), match.slice(end)];
|
|
2464
2467
|
}
|
|
2465
2468
|
function redactUrl(raw) {
|
|
2466
2469
|
try {
|
|
@@ -3370,7 +3373,8 @@ function readRegistryValue(keyPath, valueName) {
|
|
|
3370
3373
|
}
|
|
3371
3374
|
const [error, output] = catchError(() => execFileSync("reg", ["query", keyPath, "/v", valueName], {
|
|
3372
3375
|
encoding: "utf-8",
|
|
3373
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
3376
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
3377
|
+
windowsHide: true
|
|
3374
3378
|
}));
|
|
3375
3379
|
if (error) {
|
|
3376
3380
|
return "";
|
|
@@ -4052,28 +4056,32 @@ function isPlainRecord(value) {
|
|
|
4052
4056
|
const prototype = Object.getPrototypeOf(value);
|
|
4053
4057
|
return prototype === Object.prototype || prototype === null;
|
|
4054
4058
|
}
|
|
4055
|
-
function
|
|
4059
|
+
function splitPagedEnvelope(value) {
|
|
4056
4060
|
if (Array.isArray(value) || !isPlainRecord(value))
|
|
4057
4061
|
return null;
|
|
4058
|
-
const entries = Object.
|
|
4062
|
+
const entries = Object.entries(value);
|
|
4059
4063
|
if (entries.length === 0)
|
|
4060
4064
|
return null;
|
|
4061
|
-
let
|
|
4062
|
-
|
|
4063
|
-
for (const entry of entries) {
|
|
4065
|
+
let found = null;
|
|
4066
|
+
const meta = Object.create(null);
|
|
4067
|
+
for (const [key, entry] of entries) {
|
|
4064
4068
|
if (Array.isArray(entry)) {
|
|
4065
|
-
if (
|
|
4069
|
+
if (found !== null)
|
|
4066
4070
|
return null;
|
|
4067
|
-
|
|
4071
|
+
found = { key, rows: entry };
|
|
4068
4072
|
} else if (entry !== null && typeof entry === "object") {
|
|
4069
4073
|
return null;
|
|
4070
4074
|
} else {
|
|
4071
|
-
|
|
4075
|
+
meta[key] = entry;
|
|
4072
4076
|
}
|
|
4073
4077
|
}
|
|
4074
|
-
if (
|
|
4078
|
+
if (found === null || Object.keys(meta).length === 0)
|
|
4075
4079
|
return null;
|
|
4076
|
-
return
|
|
4080
|
+
return { ...found, meta };
|
|
4081
|
+
}
|
|
4082
|
+
function extractPagedRows(value) {
|
|
4083
|
+
const paged = splitPagedEnvelope(value);
|
|
4084
|
+
return paged === null ? null : paged.rows;
|
|
4077
4085
|
}
|
|
4078
4086
|
function toLowerCamelCaseKey(key) {
|
|
4079
4087
|
if (!key)
|
|
@@ -4177,6 +4185,9 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
|
|
|
4177
4185
|
}
|
|
4178
4186
|
break;
|
|
4179
4187
|
}
|
|
4188
|
+
case "markdown":
|
|
4189
|
+
logFn(renderMarkdown(data));
|
|
4190
|
+
break;
|
|
4180
4191
|
default: {
|
|
4181
4192
|
const hasData = "Data" in data && data.Data != null;
|
|
4182
4193
|
const pagedRows = hasData ? extractPagedRows(data.Data) : null;
|
|
@@ -4201,6 +4212,10 @@ function logOutput(data, format = "json", tableRowStyle) {
|
|
|
4201
4212
|
printOutput(data, format, (msg) => sink.writeOut(`${msg}
|
|
4202
4213
|
`), needsAsciiSafeJson(sink), styleFn);
|
|
4203
4214
|
}
|
|
4215
|
+
var PLUMBING_KEYS = new Set(["code", "log"]);
|
|
4216
|
+
function isPlumbingKey(key) {
|
|
4217
|
+
return PLUMBING_KEYS.has(key.toLowerCase());
|
|
4218
|
+
}
|
|
4204
4219
|
function cellToString(val) {
|
|
4205
4220
|
return val != null && typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
|
|
4206
4221
|
}
|
|
@@ -4216,7 +4231,7 @@ function wrapText(text, width) {
|
|
|
4216
4231
|
function printTable(data, logFn, externalLogValue, tableRowStyle) {
|
|
4217
4232
|
if (data.length === 0)
|
|
4218
4233
|
return;
|
|
4219
|
-
const keys = Object.keys(data[0]).filter((key) => !
|
|
4234
|
+
const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
|
|
4220
4235
|
const maxWidths = keys.map((key) => Math.max(key.length, ...data.map((item) => cellToString(item[key]).length)));
|
|
4221
4236
|
const header = keys.map((key, i) => key.padEnd(maxWidths[i])).join(" | ");
|
|
4222
4237
|
logFn(header);
|
|
@@ -4238,7 +4253,7 @@ function isNonEmptyPlainObject(value) {
|
|
|
4238
4253
|
}
|
|
4239
4254
|
var NESTED_INDENT = " ";
|
|
4240
4255
|
function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
4241
|
-
const keys = Object.keys(data).filter((key) => !
|
|
4256
|
+
const keys = Object.keys(data).filter((key) => !isPlumbingKey(key));
|
|
4242
4257
|
if (keys.length === 0)
|
|
4243
4258
|
return;
|
|
4244
4259
|
const isBlockValue = (value) => isPlainObjectArray(value) || isNonEmptyPlainObject(value);
|
|
@@ -4269,7 +4284,7 @@ function printVerticalTable(data, logFn = console.log, externalLogValue) {
|
|
|
4269
4284
|
function printResizableTable(data, logFn = console.log, externalLogValue, availableWidth, tableRowStyle) {
|
|
4270
4285
|
if (data.length === 0)
|
|
4271
4286
|
return;
|
|
4272
|
-
const keys = Object.keys(data[0]).filter((key) => !
|
|
4287
|
+
const keys = Object.keys(data[0]).filter((key) => !isPlumbingKey(key));
|
|
4273
4288
|
if (keys.length === 0)
|
|
4274
4289
|
return;
|
|
4275
4290
|
if (!process.stdout.isTTY) {
|
|
@@ -4343,6 +4358,220 @@ function printResizableTable(data, logFn = console.log, externalLogValue, availa
|
|
|
4343
4358
|
logFn(`Log: ${externalLogValue}`);
|
|
4344
4359
|
}
|
|
4345
4360
|
}
|
|
4361
|
+
var MARKDOWN_MAX_CELL = 200;
|
|
4362
|
+
var MARKDOWN_MAX_DEPTH = 3;
|
|
4363
|
+
function markdownHeading(depth) {
|
|
4364
|
+
return "#".repeat(Math.min(3 + depth, 6));
|
|
4365
|
+
}
|
|
4366
|
+
var BACKTICK_RUN = /`+/g;
|
|
4367
|
+
function fencedBlock(text) {
|
|
4368
|
+
const first = text.trimStart()[0];
|
|
4369
|
+
const language = first === "<" ? "xml" : first === "{" || first === "[" ? "json" : "";
|
|
4370
|
+
const longestRun = Math.max(0, ...Array.from(text.matchAll(BACKTICK_RUN), (match) => match[0].length));
|
|
4371
|
+
const fence = "`".repeat(Math.max(3, longestRun + 1));
|
|
4372
|
+
return `${fence}${language}
|
|
4373
|
+
${text}
|
|
4374
|
+
${fence}`;
|
|
4375
|
+
}
|
|
4376
|
+
function collapseNewlineRuns(text) {
|
|
4377
|
+
return text.split(/(\s+)/).map((part, index) => index % 2 === 1 && part.includes(`
|
|
4378
|
+
`) ? " " : part).join("");
|
|
4379
|
+
}
|
|
4380
|
+
function markdownCell(value) {
|
|
4381
|
+
const text = value instanceof Date ? value.toISOString() : cellToString(value);
|
|
4382
|
+
return collapseNewlineRuns(text).replace(/\|/g, "\\|");
|
|
4383
|
+
}
|
|
4384
|
+
function markdownLabel(key) {
|
|
4385
|
+
return collapseNewlineRuns(key).replace(/[\\`*|]/g, "\\$&");
|
|
4386
|
+
}
|
|
4387
|
+
function withoutPlumbing(record) {
|
|
4388
|
+
const kept = Object.create(null);
|
|
4389
|
+
for (const [key, value] of Object.entries(record)) {
|
|
4390
|
+
if (!isPlumbingKey(key))
|
|
4391
|
+
kept[key] = value;
|
|
4392
|
+
}
|
|
4393
|
+
return kept;
|
|
4394
|
+
}
|
|
4395
|
+
function rowsWithoutPlumbing(rows) {
|
|
4396
|
+
return rows.map((row) => isPlainRecord(row) ? withoutPlumbing(row) : row);
|
|
4397
|
+
}
|
|
4398
|
+
function markdownTable(rows) {
|
|
4399
|
+
const columns = [];
|
|
4400
|
+
const seen = new Set;
|
|
4401
|
+
for (const row of rows) {
|
|
4402
|
+
for (const key of Object.keys(row)) {
|
|
4403
|
+
if (!seen.has(key)) {
|
|
4404
|
+
seen.add(key);
|
|
4405
|
+
columns.push(key);
|
|
4406
|
+
}
|
|
4407
|
+
}
|
|
4408
|
+
}
|
|
4409
|
+
if (columns.length === 0)
|
|
4410
|
+
return null;
|
|
4411
|
+
const cells = rows.map((row) => columns.map((key) => markdownCell(row[key])));
|
|
4412
|
+
if (cells.some((row) => row.some((c) => c.length > MARKDOWN_MAX_CELL))) {
|
|
4413
|
+
return null;
|
|
4414
|
+
}
|
|
4415
|
+
return [
|
|
4416
|
+
`| ${columns.map(markdownLabel).join(" | ")} |`,
|
|
4417
|
+
`| ${columns.map(() => "---").join(" | ")} |`,
|
|
4418
|
+
...cells.map((row) => `| ${row.join(" | ")} |`)
|
|
4419
|
+
].join(`
|
|
4420
|
+
`);
|
|
4421
|
+
}
|
|
4422
|
+
function extractMessageSequence(rows) {
|
|
4423
|
+
const messages = [];
|
|
4424
|
+
for (const row of rows) {
|
|
4425
|
+
const message = extractSingleMessage(row);
|
|
4426
|
+
if (message === null)
|
|
4427
|
+
return null;
|
|
4428
|
+
messages.push(message);
|
|
4429
|
+
}
|
|
4430
|
+
return messages.join(`
|
|
4431
|
+
|
|
4432
|
+
`);
|
|
4433
|
+
}
|
|
4434
|
+
function markdownRows(rows, depth) {
|
|
4435
|
+
if (rows.length === 0)
|
|
4436
|
+
return "(none)";
|
|
4437
|
+
if (!isPlainObjectArray(rows)) {
|
|
4438
|
+
return rows.map((item) => `- ${markdownCell(item)}`).join(`
|
|
4439
|
+
`);
|
|
4440
|
+
}
|
|
4441
|
+
const prose = extractMessageSequence(rows);
|
|
4442
|
+
if (prose !== null)
|
|
4443
|
+
return prose;
|
|
4444
|
+
const table = markdownTable(rows);
|
|
4445
|
+
if (table !== null)
|
|
4446
|
+
return table;
|
|
4447
|
+
if (depth >= MARKDOWN_MAX_DEPTH) {
|
|
4448
|
+
return fencedBlock(JSON.stringify(rows, null, 2));
|
|
4449
|
+
}
|
|
4450
|
+
return rows.map((row, index) => [
|
|
4451
|
+
`${markdownHeading(depth)} ${index + 1}`,
|
|
4452
|
+
markdownObject(row, depth + 1)
|
|
4453
|
+
].join(`
|
|
4454
|
+
|
|
4455
|
+
`)).join(`
|
|
4456
|
+
|
|
4457
|
+
`);
|
|
4458
|
+
}
|
|
4459
|
+
function markdownObject(obj, depth) {
|
|
4460
|
+
const scalars = [];
|
|
4461
|
+
const blocks = [];
|
|
4462
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
4463
|
+
if (value === undefined)
|
|
4464
|
+
continue;
|
|
4465
|
+
const label = markdownLabel(key);
|
|
4466
|
+
if (Array.isArray(value)) {
|
|
4467
|
+
blocks.push(`${markdownHeading(depth)} ${label}
|
|
4468
|
+
|
|
4469
|
+
${markdownRows(value, depth + 1)}`);
|
|
4470
|
+
} else if (isNonEmptyPlainObject(value)) {
|
|
4471
|
+
const nested = depth < MARKDOWN_MAX_DEPTH ? markdownObject(value, depth + 1) : fencedBlock(JSON.stringify(value, null, 2));
|
|
4472
|
+
if (nested !== "") {
|
|
4473
|
+
blocks.push(`${markdownHeading(depth)} ${label}
|
|
4474
|
+
|
|
4475
|
+
${nested}`);
|
|
4476
|
+
}
|
|
4477
|
+
} else if (typeof value === "string" && value.includes(`
|
|
4478
|
+
`)) {
|
|
4479
|
+
blocks.push(`**${label}:**
|
|
4480
|
+
|
|
4481
|
+
${fencedBlock(value)}`);
|
|
4482
|
+
} else {
|
|
4483
|
+
scalars.push(`**${label}:** ${markdownCell(value)}`);
|
|
4484
|
+
}
|
|
4485
|
+
}
|
|
4486
|
+
const sections = scalars.length > 0 ? [scalars.join(`
|
|
4487
|
+
`)] : [];
|
|
4488
|
+
sections.push(...blocks);
|
|
4489
|
+
return sections.join(`
|
|
4490
|
+
|
|
4491
|
+
`);
|
|
4492
|
+
}
|
|
4493
|
+
function extractSingleMessage(payload) {
|
|
4494
|
+
if (!isPlainRecord(payload))
|
|
4495
|
+
return null;
|
|
4496
|
+
const keys = Object.keys(payload);
|
|
4497
|
+
if (keys.length !== 1 || keys[0].toLowerCase() !== "message")
|
|
4498
|
+
return null;
|
|
4499
|
+
const value = payload[keys[0]];
|
|
4500
|
+
return typeof value === "string" ? value : null;
|
|
4501
|
+
}
|
|
4502
|
+
function markdownPayload(payload) {
|
|
4503
|
+
const message = extractSingleMessage(payload);
|
|
4504
|
+
if (message !== null)
|
|
4505
|
+
return message;
|
|
4506
|
+
if (Array.isArray(payload)) {
|
|
4507
|
+
return markdownRows(rowsWithoutPlumbing(payload), 0);
|
|
4508
|
+
}
|
|
4509
|
+
const visible = withoutPlumbing(payload);
|
|
4510
|
+
const paged = splitPagedEnvelope(visible);
|
|
4511
|
+
if (paged !== null) {
|
|
4512
|
+
const meta = markdownObject(paged.meta, 0);
|
|
4513
|
+
const rows = `${markdownHeading(0)} ${markdownLabel(paged.key)}
|
|
4514
|
+
|
|
4515
|
+
${markdownRows(rowsWithoutPlumbing(paged.rows), 1)}`;
|
|
4516
|
+
return meta === "" ? rows : `${meta}
|
|
4517
|
+
|
|
4518
|
+
${rows}`;
|
|
4519
|
+
}
|
|
4520
|
+
return markdownObject(visible, 0);
|
|
4521
|
+
}
|
|
4522
|
+
function isPaginationWorthShowing(value) {
|
|
4523
|
+
if (typeof value !== "object" || value === null)
|
|
4524
|
+
return false;
|
|
4525
|
+
const page = value;
|
|
4526
|
+
return page.HasMore === true || typeof page.Offset === "number" && page.Offset > 0;
|
|
4527
|
+
}
|
|
4528
|
+
function markdownEnvelopeNotes(data) {
|
|
4529
|
+
const envelope = data;
|
|
4530
|
+
const notes = [];
|
|
4531
|
+
const warning = envelope.Warning;
|
|
4532
|
+
if (typeof warning === "string" && warning !== "") {
|
|
4533
|
+
notes.push(`> **Warning:** ${warning}`);
|
|
4534
|
+
}
|
|
4535
|
+
const instructions = envelope.Instructions;
|
|
4536
|
+
if (typeof instructions === "string" && instructions !== "") {
|
|
4537
|
+
notes.push(`> ${instructions}`);
|
|
4538
|
+
}
|
|
4539
|
+
const pagination = envelope.Pagination;
|
|
4540
|
+
if (isPaginationWorthShowing(pagination)) {
|
|
4541
|
+
const body = markdownObject(pagination, 1);
|
|
4542
|
+
if (body !== "") {
|
|
4543
|
+
notes.push(`${markdownHeading(0)} Pagination
|
|
4544
|
+
|
|
4545
|
+
${body}`);
|
|
4546
|
+
}
|
|
4547
|
+
}
|
|
4548
|
+
const log = envelope.Log;
|
|
4549
|
+
if (typeof log === "string" && log !== "") {
|
|
4550
|
+
notes.push(`**Log:** ${log}`);
|
|
4551
|
+
}
|
|
4552
|
+
return notes;
|
|
4553
|
+
}
|
|
4554
|
+
function renderMarkdown(data) {
|
|
4555
|
+
if (data.Result !== RESULTS.Success) {
|
|
4556
|
+
const failure = data;
|
|
4557
|
+
const sections = [`**Failed:** ${failure.Message}`];
|
|
4558
|
+
if (failure.Data != null) {
|
|
4559
|
+
sections.push(markdownPayload(failure.Data));
|
|
4560
|
+
}
|
|
4561
|
+
if (failure.Instructions) {
|
|
4562
|
+
sections.push(`> ${failure.Instructions}`);
|
|
4563
|
+
}
|
|
4564
|
+
return sections.filter((section) => section !== "").join(`
|
|
4565
|
+
|
|
4566
|
+
`);
|
|
4567
|
+
}
|
|
4568
|
+
if (!("Data" in data) || data.Data == null) {
|
|
4569
|
+
return markdownObject(withoutPlumbing(data), 0);
|
|
4570
|
+
}
|
|
4571
|
+
return [markdownPayload(data.Data), ...markdownEnvelopeNotes(data)].filter((section) => section !== "").join(`
|
|
4572
|
+
|
|
4573
|
+
`);
|
|
4574
|
+
}
|
|
4346
4575
|
function toYaml(data) {
|
|
4347
4576
|
const codec = getYamlCodec();
|
|
4348
4577
|
if (!codec) {
|
|
@@ -6125,16 +6354,7 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
|
|
|
6125
6354
|
errorMessage: location.source === "absolute" ? `Environment file not found: ${envFilePath}` : `Unable to locate environment file: ${envFilePath}. Run 'uip login' to authenticate.`
|
|
6126
6355
|
};
|
|
6127
6356
|
};
|
|
6128
|
-
var
|
|
6129
|
-
const fs2 = getFileSystem();
|
|
6130
|
-
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
|
|
6131
|
-
if (!await fs2.exists(absolutePath)) {
|
|
6132
|
-
throw new Error(`Environment file not found: ${envPath}`);
|
|
6133
|
-
}
|
|
6134
|
-
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
6135
|
-
if (content === null) {
|
|
6136
|
-
throw new Error(`Environment file not found: ${envPath}`);
|
|
6137
|
-
}
|
|
6357
|
+
var parseEnvContent = (content) => {
|
|
6138
6358
|
const env = {};
|
|
6139
6359
|
for (const line of content.split(`
|
|
6140
6360
|
`)) {
|
|
@@ -6155,6 +6375,18 @@ var loadEnvFileAsync = async ({ envPath }) => {
|
|
|
6155
6375
|
}
|
|
6156
6376
|
return env;
|
|
6157
6377
|
};
|
|
6378
|
+
var loadEnvFileAsync = async ({ envPath }) => {
|
|
6379
|
+
const fs2 = getFileSystem();
|
|
6380
|
+
const absolutePath = fs2.path.isAbsolute(envPath) ? envPath : fs2.path.join(fs2.env.cwd(), envPath);
|
|
6381
|
+
if (!await fs2.exists(absolutePath)) {
|
|
6382
|
+
throw new Error(`Environment file not found: ${envPath}`);
|
|
6383
|
+
}
|
|
6384
|
+
const content = await fs2.readFile(absolutePath, "utf-8");
|
|
6385
|
+
if (content === null) {
|
|
6386
|
+
throw new Error(`Environment file not found: ${envPath}`);
|
|
6387
|
+
}
|
|
6388
|
+
return parseEnvContent(content);
|
|
6389
|
+
};
|
|
6158
6390
|
var saveEnvFileAsync = async ({
|
|
6159
6391
|
envPath,
|
|
6160
6392
|
data,
|
|
@@ -6854,7 +7086,8 @@ var fail = (reason, message, instructions, extras = {}) => ({
|
|
|
6854
7086
|
async function runUipathPythonCommand(args, options = {}) {
|
|
6855
7087
|
const fs2 = getFileSystem();
|
|
6856
7088
|
const cacheFile = fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
|
|
6857
|
-
const
|
|
7089
|
+
const setupCommand = `uip ${options.commandPrefix ?? "codedagent"} setup`;
|
|
7090
|
+
const setupHint = `Run '${setupCommand}' first to configure the environment. ` + `Activate the project's virtual environment and run ${setupCommand} --force.`;
|
|
6858
7091
|
const cache = await readCache(cacheFile);
|
|
6859
7092
|
if (!cache?.uipathExePath) {
|
|
6860
7093
|
return fail("python_not_configured", "Python not configured.", setupHint);
|
|
@@ -7004,67 +7237,42 @@ class PythonService {
|
|
|
7004
7237
|
return result;
|
|
7005
7238
|
}
|
|
7006
7239
|
async _setupInternal(packageName, force) {
|
|
7007
|
-
const
|
|
7008
|
-
let pythonPath;
|
|
7009
|
-
let version;
|
|
7240
|
+
const virtualEnv = process.env.VIRTUAL_ENV || undefined;
|
|
7010
7241
|
if (!force) {
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
pythonPath = cached.pythonPath;
|
|
7015
|
-
version = cached.version;
|
|
7016
|
-
this.uipathExePath = cached.uipathExePath;
|
|
7017
|
-
logger.info(`Using cached uipath executable: ${this.uipathExePath}`);
|
|
7018
|
-
this.packageVersion = cached.packageVersion;
|
|
7019
|
-
if (!this.packageVersion) {
|
|
7020
|
-
const versionResult2 = await this.getUipathVersion(this.uipathExePath);
|
|
7021
|
-
if ("error" in versionResult2) {
|
|
7022
|
-
return {
|
|
7023
|
-
success: false,
|
|
7024
|
-
pythonPath,
|
|
7025
|
-
pythonVersion: version,
|
|
7026
|
-
packageInstalled: true,
|
|
7027
|
-
error: versionResult2.error
|
|
7028
|
-
};
|
|
7029
|
-
}
|
|
7030
|
-
this.packageVersion = versionResult2.version;
|
|
7031
|
-
}
|
|
7032
|
-
await this.saveCache({
|
|
7033
|
-
pythonPath,
|
|
7034
|
-
version,
|
|
7035
|
-
lastValidated: new Date().toISOString(),
|
|
7036
|
-
packageName,
|
|
7037
|
-
uipathExePath: this.uipathExePath,
|
|
7038
|
-
packageVersion: this.packageVersion
|
|
7039
|
-
});
|
|
7040
|
-
return {
|
|
7041
|
-
success: true,
|
|
7042
|
-
pythonPath,
|
|
7043
|
-
pythonVersion: version,
|
|
7044
|
-
packageInstalled: true,
|
|
7045
|
-
packageVersion: this.packageVersion
|
|
7046
|
-
};
|
|
7047
|
-
} else if (cached) {
|
|
7048
|
-
logger.warn("Cached Python path no longer exists, re-detecting...");
|
|
7049
|
-
}
|
|
7242
|
+
const reused = await this.reuseCache(packageName, virtualEnv);
|
|
7243
|
+
if (reused)
|
|
7244
|
+
return reused;
|
|
7050
7245
|
}
|
|
7051
7246
|
logger.info("Checking Python...");
|
|
7052
|
-
const detection = await this.detectPython();
|
|
7247
|
+
const detection = virtualEnv ? await this.detectVenvPython(virtualEnv) : await this.detectPython();
|
|
7053
7248
|
if (!detection.success || !detection.pythonPath || !detection.version) {
|
|
7054
7249
|
return {
|
|
7055
7250
|
success: false,
|
|
7056
7251
|
error: detection.error || "Failed to detect Python"
|
|
7057
7252
|
};
|
|
7058
7253
|
}
|
|
7059
|
-
pythonPath = detection.pythonPath;
|
|
7060
|
-
version = detection.version;
|
|
7254
|
+
const pythonPath = detection.pythonPath;
|
|
7255
|
+
const version = detection.version;
|
|
7256
|
+
const source = detection.source ?? "path";
|
|
7061
7257
|
this.uipathExePath = detection.uipathExePath;
|
|
7062
7258
|
if (!this.uipathExePath) {
|
|
7259
|
+
if (virtualEnv) {
|
|
7260
|
+
return {
|
|
7261
|
+
success: false,
|
|
7262
|
+
pythonPath,
|
|
7263
|
+
pythonVersion: version,
|
|
7264
|
+
packageInstalled: false,
|
|
7265
|
+
source,
|
|
7266
|
+
error: `Package '${packageName}' is not installed in the active virtual environment: ${virtualEnv}`,
|
|
7267
|
+
instructions: `Install it inside the active virtual environment (uv pip install ${packageName} or the framework package), then re-run uip codedagent setup --force.`
|
|
7268
|
+
};
|
|
7269
|
+
}
|
|
7063
7270
|
return {
|
|
7064
7271
|
success: false,
|
|
7065
7272
|
pythonPath,
|
|
7066
7273
|
pythonVersion: version,
|
|
7067
7274
|
packageInstalled: false,
|
|
7275
|
+
source,
|
|
7068
7276
|
error: `Package '${packageName}' is not installed.
|
|
7069
7277
|
|
|
7070
7278
|
To install the package, run:
|
|
@@ -7078,6 +7286,8 @@ To install the package, run:
|
|
|
7078
7286
|
pythonPath,
|
|
7079
7287
|
pythonVersion: version,
|
|
7080
7288
|
packageInstalled: true,
|
|
7289
|
+
uipathExePath: this.uipathExePath,
|
|
7290
|
+
source,
|
|
7081
7291
|
error: versionResult.error
|
|
7082
7292
|
};
|
|
7083
7293
|
}
|
|
@@ -7088,14 +7298,104 @@ To install the package, run:
|
|
|
7088
7298
|
lastValidated: new Date().toISOString(),
|
|
7089
7299
|
packageName,
|
|
7090
7300
|
uipathExePath: this.uipathExePath,
|
|
7091
|
-
packageVersion: this.packageVersion
|
|
7301
|
+
packageVersion: this.packageVersion,
|
|
7302
|
+
source
|
|
7092
7303
|
});
|
|
7093
7304
|
return {
|
|
7094
7305
|
success: true,
|
|
7095
7306
|
pythonPath,
|
|
7096
7307
|
pythonVersion: version,
|
|
7097
7308
|
packageInstalled: true,
|
|
7098
|
-
packageVersion: this.packageVersion
|
|
7309
|
+
packageVersion: this.packageVersion,
|
|
7310
|
+
uipathExePath: this.uipathExePath,
|
|
7311
|
+
source
|
|
7312
|
+
};
|
|
7313
|
+
}
|
|
7314
|
+
async reuseCache(packageName, virtualEnv) {
|
|
7315
|
+
const fs2 = getFileSystem();
|
|
7316
|
+
logger.debug("Checking cache...");
|
|
7317
|
+
const cached = await this.loadCache();
|
|
7318
|
+
if (!cached)
|
|
7319
|
+
return null;
|
|
7320
|
+
if (!cached.uipathExePath || !await fs2.exists(cached.uipathExePath)) {
|
|
7321
|
+
logger.warn("Cached Python path no longer exists, re-detecting...");
|
|
7322
|
+
return null;
|
|
7323
|
+
}
|
|
7324
|
+
if (virtualEnv && !isPathInside(cached.uipathExePath, virtualEnv)) {
|
|
7325
|
+
logger.warn(`Cached uipath executable ${cached.uipathExePath} is outside the active virtual environment ${virtualEnv}, re-detecting...`);
|
|
7326
|
+
return null;
|
|
7327
|
+
}
|
|
7328
|
+
const pythonPath = cached.pythonPath;
|
|
7329
|
+
const version = cached.version;
|
|
7330
|
+
this.uipathExePath = cached.uipathExePath;
|
|
7331
|
+
const source = cached.source ?? (virtualEnv ? "venv" : "path");
|
|
7332
|
+
logger.info(`Using cached uipath executable: ${this.uipathExePath}`);
|
|
7333
|
+
this.packageVersion = cached.packageVersion;
|
|
7334
|
+
if (!this.packageVersion) {
|
|
7335
|
+
const versionResult = await this.getUipathVersion(this.uipathExePath);
|
|
7336
|
+
if ("error" in versionResult) {
|
|
7337
|
+
return {
|
|
7338
|
+
success: false,
|
|
7339
|
+
pythonPath,
|
|
7340
|
+
pythonVersion: version,
|
|
7341
|
+
packageInstalled: true,
|
|
7342
|
+
uipathExePath: this.uipathExePath,
|
|
7343
|
+
source,
|
|
7344
|
+
error: versionResult.error
|
|
7345
|
+
};
|
|
7346
|
+
}
|
|
7347
|
+
this.packageVersion = versionResult.version;
|
|
7348
|
+
}
|
|
7349
|
+
await this.saveCache({
|
|
7350
|
+
pythonPath,
|
|
7351
|
+
version,
|
|
7352
|
+
lastValidated: new Date().toISOString(),
|
|
7353
|
+
packageName,
|
|
7354
|
+
uipathExePath: this.uipathExePath,
|
|
7355
|
+
packageVersion: this.packageVersion,
|
|
7356
|
+
source
|
|
7357
|
+
});
|
|
7358
|
+
return {
|
|
7359
|
+
success: true,
|
|
7360
|
+
pythonPath,
|
|
7361
|
+
pythonVersion: version,
|
|
7362
|
+
packageInstalled: true,
|
|
7363
|
+
packageVersion: this.packageVersion,
|
|
7364
|
+
uipathExePath: this.uipathExePath,
|
|
7365
|
+
source
|
|
7366
|
+
};
|
|
7367
|
+
}
|
|
7368
|
+
async detectVenvPython(virtualEnv) {
|
|
7369
|
+
const fs2 = getFileSystem();
|
|
7370
|
+
const isWindows = platform() === "win32";
|
|
7371
|
+
const command = isWindows ? fs2.path.join(virtualEnv, "Scripts", "python.exe") : fs2.path.join(virtualEnv, "bin", "python");
|
|
7372
|
+
const checkedVersions = [];
|
|
7373
|
+
const searchedCommands = [];
|
|
7374
|
+
const version = await this.checkPythonVersion(command, [], checkedVersions, searchedCommands);
|
|
7375
|
+
if (!version) {
|
|
7376
|
+
return {
|
|
7377
|
+
success: false,
|
|
7378
|
+
error: this.buildNotFoundError(checkedVersions, searchedCommands)
|
|
7379
|
+
};
|
|
7380
|
+
}
|
|
7381
|
+
const metadataPath = await this.findUipathExeFromMetadata(fs2, command, []);
|
|
7382
|
+
let uipathExePath = metadataPath;
|
|
7383
|
+
if (!uipathExePath) {
|
|
7384
|
+
const candidate = isWindows ? fs2.path.join(virtualEnv, "Scripts", "uipath.exe") : fs2.path.join(virtualEnv, "bin", "uipath");
|
|
7385
|
+
logger.debug(`Checking for uipath executable at: ${candidate}`);
|
|
7386
|
+
if (await fs2.exists(candidate)) {
|
|
7387
|
+
logger.info(`Found uipath executable at: ${candidate}`);
|
|
7388
|
+
uipathExePath = candidate;
|
|
7389
|
+
} else {
|
|
7390
|
+
logger.error(`uipath executable not found in virtual environment. Checked: ${candidate}`);
|
|
7391
|
+
}
|
|
7392
|
+
}
|
|
7393
|
+
return {
|
|
7394
|
+
success: true,
|
|
7395
|
+
pythonPath: command,
|
|
7396
|
+
version,
|
|
7397
|
+
uipathExePath,
|
|
7398
|
+
source: "venv"
|
|
7099
7399
|
};
|
|
7100
7400
|
}
|
|
7101
7401
|
async detectPython() {
|
|
@@ -7114,6 +7414,20 @@ To install the package, run:
|
|
|
7114
7414
|
}
|
|
7115
7415
|
async checkPythonCommand(command, args, checkedVersions, searchedCommands) {
|
|
7116
7416
|
const fs2 = getFileSystem();
|
|
7417
|
+
const version = await this.checkPythonVersion(command, args, checkedVersions, searchedCommands);
|
|
7418
|
+
if (!version)
|
|
7419
|
+
return null;
|
|
7420
|
+
const commandStr = args.length > 0 ? `${command} ${args.join(" ")}` : command;
|
|
7421
|
+
const uipathExePath = await this.findUipathExe(fs2, command, args);
|
|
7422
|
+
return {
|
|
7423
|
+
success: true,
|
|
7424
|
+
pythonPath: commandStr,
|
|
7425
|
+
version,
|
|
7426
|
+
uipathExePath,
|
|
7427
|
+
source: "path"
|
|
7428
|
+
};
|
|
7429
|
+
}
|
|
7430
|
+
async checkPythonVersion(command, args, checkedVersions, searchedCommands) {
|
|
7117
7431
|
const commandStr = args.length > 0 ? `${command} ${args.join(" ")}` : command;
|
|
7118
7432
|
searchedCommands.push(commandStr);
|
|
7119
7433
|
logger.debug(`Checking Python command: ${commandStr}`);
|
|
@@ -7151,13 +7465,7 @@ To install the package, run:
|
|
|
7151
7465
|
return null;
|
|
7152
7466
|
}
|
|
7153
7467
|
logger.info(`Found valid Python: ${commandStr} - ${version}`);
|
|
7154
|
-
|
|
7155
|
-
return {
|
|
7156
|
-
success: true,
|
|
7157
|
-
pythonPath: commandStr,
|
|
7158
|
-
version,
|
|
7159
|
-
uipathExePath
|
|
7160
|
-
};
|
|
7468
|
+
return version;
|
|
7161
7469
|
}
|
|
7162
7470
|
async findUipathExe(fs2, command, args) {
|
|
7163
7471
|
const metadataPath = await this.findUipathExeFromMetadata(fs2, command, args);
|
|
@@ -7195,6 +7503,7 @@ To install the package, run:
|
|
|
7195
7503
|
async findUipathExeFromMetadata(fs2, command, args) {
|
|
7196
7504
|
const script = `
|
|
7197
7505
|
from importlib.metadata import distribution, PackageNotFoundError
|
|
7506
|
+
import os
|
|
7198
7507
|
import sys
|
|
7199
7508
|
try:
|
|
7200
7509
|
d = distribution("uipath")
|
|
@@ -7202,7 +7511,7 @@ except PackageNotFoundError:
|
|
|
7202
7511
|
sys.exit(2)
|
|
7203
7512
|
for f in d.files or []:
|
|
7204
7513
|
if f.name.lower() in ("uipath", "uipath.exe"):
|
|
7205
|
-
print(str(f.locate()))
|
|
7514
|
+
print(os.path.normpath(str(f.locate())))
|
|
7206
7515
|
sys.exit(0)
|
|
7207
7516
|
sys.exit(3)
|
|
7208
7517
|
`;
|
|
@@ -7387,6 +7696,17 @@ Please install one of the required Python versions:
|
|
|
7387
7696
|
logger.info(`Cache saved to ${this.cacheFile}`);
|
|
7388
7697
|
}
|
|
7389
7698
|
}
|
|
7699
|
+
function isPathInside(target, root) {
|
|
7700
|
+
const normalize = (value) => {
|
|
7701
|
+
let normalized = value.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
7702
|
+
if (platform() === "win32")
|
|
7703
|
+
normalized = normalized.toLowerCase();
|
|
7704
|
+
return normalized;
|
|
7705
|
+
};
|
|
7706
|
+
const normalizedTarget = normalize(target);
|
|
7707
|
+
const normalizedRoot = normalize(root);
|
|
7708
|
+
return normalizedTarget === normalizedRoot || normalizedTarget.startsWith(`${normalizedRoot}/`);
|
|
7709
|
+
}
|
|
7390
7710
|
|
|
7391
7711
|
// ../uipath-python-bridge/src/register.ts
|
|
7392
7712
|
function createSetupCommand(config) {
|
|
@@ -7437,7 +7757,9 @@ Searching for Python installations: ${allowedVersions}`);
|
|
|
7437
7757
|
PythonPath: result.pythonPath,
|
|
7438
7758
|
Package: packageName,
|
|
7439
7759
|
PackageInstalled: result.packageInstalled ? "Yes" : "No",
|
|
7440
|
-
PackageVersion: result.packageVersion ?? "N/A"
|
|
7760
|
+
PackageVersion: result.packageVersion ?? "N/A",
|
|
7761
|
+
UipathPath: result.uipathExePath,
|
|
7762
|
+
Source: result.source
|
|
7441
7763
|
}
|
|
7442
7764
|
});
|
|
7443
7765
|
processContext.exit(0);
|
|
@@ -7523,4 +7845,4 @@ var codedAgentCommandPreflight = ({
|
|
|
7523
7845
|
|
|
7524
7846
|
export { getFileSystem, catchError, extractErrorMessageSync, RESULTS, OutputFormatter, Command, processContext, trackShipSucceeded, runUipathPythonCommand, createExecuteCommand, createSetupCommand, WHITELISTED_COMMANDS, COMMAND_RULES, codedAgentCommandPreflight };
|
|
7525
7847
|
|
|
7526
|
-
//# debugId=
|
|
7848
|
+
//# debugId=56087E0307A4B44B64756E2164756E21
|
|
@@ -11,15 +11,16 @@ import {
|
|
|
11
11
|
getFileSystem,
|
|
12
12
|
processContext,
|
|
13
13
|
trackShipSucceeded
|
|
14
|
-
} from "./tool-
|
|
14
|
+
} from "./tool-etst5h2w.js";
|
|
15
15
|
import {
|
|
16
16
|
__require
|
|
17
17
|
} from "./tool-1de529jm.js";
|
|
18
18
|
// package.json
|
|
19
19
|
var package_default = {
|
|
20
20
|
name: "@uipath/codedagent-tool",
|
|
21
|
+
author: "UiPath",
|
|
21
22
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
22
|
-
version: "1.
|
|
23
|
+
version: "1.203.0-preview.160",
|
|
23
24
|
description: "Build, run, deploy, and manage AI Agents.",
|
|
24
25
|
keywords: [
|
|
25
26
|
"cli-tool",
|
|
@@ -2258,16 +2259,7 @@ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) =
|
|
|
2258
2259
|
errorMessage: location.source === "absolute" ? `Environment file not found: ${envFilePath}` : `Unable to locate environment file: ${envFilePath}. Run 'uip login' to authenticate.`
|
|
2259
2260
|
};
|
|
2260
2261
|
};
|
|
2261
|
-
var
|
|
2262
|
-
const fs7 = getFileSystem2();
|
|
2263
|
-
const absolutePath = fs7.path.isAbsolute(envPath) ? envPath : fs7.path.join(fs7.env.cwd(), envPath);
|
|
2264
|
-
if (!await fs7.exists(absolutePath)) {
|
|
2265
|
-
throw new Error(`Environment file not found: ${envPath}`);
|
|
2266
|
-
}
|
|
2267
|
-
const content = await fs7.readFile(absolutePath, "utf-8");
|
|
2268
|
-
if (content === null) {
|
|
2269
|
-
throw new Error(`Environment file not found: ${envPath}`);
|
|
2270
|
-
}
|
|
2262
|
+
var parseEnvContent = (content) => {
|
|
2271
2263
|
const env = {};
|
|
2272
2264
|
for (const line of content.split(`
|
|
2273
2265
|
`)) {
|
|
@@ -2288,6 +2280,18 @@ var loadEnvFileAsync = async ({ envPath }) => {
|
|
|
2288
2280
|
}
|
|
2289
2281
|
return env;
|
|
2290
2282
|
};
|
|
2283
|
+
var loadEnvFileAsync = async ({ envPath }) => {
|
|
2284
|
+
const fs7 = getFileSystem2();
|
|
2285
|
+
const absolutePath = fs7.path.isAbsolute(envPath) ? envPath : fs7.path.join(fs7.env.cwd(), envPath);
|
|
2286
|
+
if (!await fs7.exists(absolutePath)) {
|
|
2287
|
+
throw new Error(`Environment file not found: ${envPath}`);
|
|
2288
|
+
}
|
|
2289
|
+
const content = await fs7.readFile(absolutePath, "utf-8");
|
|
2290
|
+
if (content === null) {
|
|
2291
|
+
throw new Error(`Environment file not found: ${envPath}`);
|
|
2292
|
+
}
|
|
2293
|
+
return parseEnvContent(content);
|
|
2294
|
+
};
|
|
2291
2295
|
var saveEnvFileAsync = async ({
|
|
2292
2296
|
envPath,
|
|
2293
2297
|
data,
|
|
@@ -2794,6 +2798,7 @@ function normalizeTokenRefreshUnavailableFailure() {
|
|
|
2794
2798
|
function errorMessage(error) {
|
|
2795
2799
|
return error instanceof Error ? error.message : String(error);
|
|
2796
2800
|
}
|
|
2801
|
+
init_src();
|
|
2797
2802
|
init_constants();
|
|
2798
2803
|
init_src();
|
|
2799
2804
|
init_constants();
|
|
@@ -3208,4 +3213,4 @@ var registerCommands = async (program) => {
|
|
|
3208
3213
|
|
|
3209
3214
|
export { metadata, registerCommands };
|
|
3210
3215
|
|
|
3211
|
-
//# debugId=
|
|
3216
|
+
//# debugId=92A5ABBC34D4A2FB64756E2164756E21
|
package/dist/tool.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/codedagent-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": "Build, run, deploy, and manage AI Agents.",
|
|
6
7
|
"keywords": [
|
|
7
8
|
"cli-tool",
|
|
@@ -32,5 +33,5 @@
|
|
|
32
33
|
"publishConfig": {
|
|
33
34
|
"registry": "https://registry.npmjs.org/"
|
|
34
35
|
},
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "3a42062ba731afca4595ba9aa8a80afc9667528d"
|
|
36
37
|
}
|