@uipath/cli 0.1.11 → 0.1.16

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +3048 -604
  3. package/package.json +8 -6
package/dist/index.js CHANGED
@@ -52,11 +52,11 @@ var package_default;
52
52
  var init_package = __esm(() => {
53
53
  package_default = {
54
54
  name: "@uipath/cli",
55
- version: "0.1.11",
55
+ version: "0.1.16",
56
56
  description: "Cross platform CLI for UiPath",
57
57
  repository: {
58
58
  type: "git",
59
- url: "https://github.com/UiPath/uipcli.git",
59
+ url: "https://github.com/UiPath/cli.git",
60
60
  directory: "packages/cli"
61
61
  },
62
62
  publishConfig: {
@@ -84,12 +84,14 @@ var init_package = __esm(() => {
84
84
  ],
85
85
  scripts: {
86
86
  build: "bun build ./index.ts --outdir dist --format esm --target node --external commander --external @uipath/common --external @uipath/auth --external @uipath/filesystem",
87
+ typecheck: "tsc --noEmit",
87
88
  "browser:build": "bun run build-browser.ts",
88
89
  lint: "biome check ."
89
90
  },
90
91
  devDependencies: {
91
- "@types/bun": "latest",
92
- "@types/node": "^25.2.3",
92
+ "@inquirer/prompts": "^8.3.2",
93
+ "@types/bun": "^1.3.9",
94
+ "@types/node": "^25.5.0",
93
95
  esbuild: "^0.27.3",
94
96
  typescript: "^5"
95
97
  },
@@ -101,8 +103,8 @@ var init_package = __esm(() => {
101
103
  },
102
104
  peerDependencies: {
103
105
  commander: "^14.0.3",
104
- "@uipath/common": "^0.1.7",
105
- "@uipath/auth": "^0.1.6",
106
+ "@uipath/common": "^0.1.12",
107
+ "@uipath/auth": "^0.1.9",
106
108
  "@uipath/filesystem": "^0.1.6"
107
109
  }
108
110
  };
@@ -176,12 +178,12 @@ var init_auth = __esm(() => {
176
178
  });
177
179
 
178
180
  // src/commands/login.ts
179
- import path from "node:path";
180
181
  import { DEFAULT_AUTH_FILENAME, DEFAULT_ENV_FILENAME } from "@uipath/auth";
181
182
  import { catchError, OutputFormatter } from "@uipath/common";
183
+ import { getFileSystem } from "@uipath/filesystem";
182
184
  function resolveAuthFilePath(folder) {
183
185
  if (folder) {
184
- return path.join(folder, DEFAULT_AUTH_FILENAME);
186
+ return getFileSystem().path.join(folder, DEFAULT_AUTH_FILENAME);
185
187
  }
186
188
  return DEFAULT_ENV_FILENAME;
187
189
  }
@@ -353,12 +355,12 @@ var init_login = __esm(() => {
353
355
  });
354
356
 
355
357
  // src/commands/logout.ts
356
- import path2 from "node:path";
357
358
  import { DEFAULT_AUTH_FILENAME as DEFAULT_AUTH_FILENAME2, logout } from "@uipath/auth";
358
359
  import { catchError as catchError2, OutputFormatter as OutputFormatter2 } from "@uipath/common";
360
+ import { getFileSystem as getFileSystem2 } from "@uipath/filesystem";
359
361
  function registerLogoutCommand(program, context) {
360
362
  program.command("logout").description("Logout from UiPath Cloud by removing credentials").option("-f, --file <folder>", "Path to credentials folder").trackedAction(context, async (options) => {
361
- const file = options.file ? path2.join(options.file, DEFAULT_AUTH_FILENAME2) : undefined;
363
+ const file = options.file ? getFileSystem2().path.join(options.file, DEFAULT_AUTH_FILENAME2) : undefined;
362
364
  const [logoutError, result] = await catchError2(logout({ file }));
363
365
  if (logoutError) {
364
366
  OutputFormatter2.error({
@@ -623,10 +625,10 @@ function mergeDefs(...defs) {
623
625
  function cloneDef(schema) {
624
626
  return mergeDefs(schema._zod.def);
625
627
  }
626
- function getElementAtPath(obj, path3) {
627
- if (!path3)
628
+ function getElementAtPath(obj, path) {
629
+ if (!path)
628
630
  return obj;
629
- return path3.reduce((acc, key) => acc?.[key], obj);
631
+ return path.reduce((acc, key) => acc?.[key], obj);
630
632
  }
631
633
  function promiseAllObject(promisesObj) {
632
634
  const keys = Object.keys(promisesObj);
@@ -937,11 +939,11 @@ function aborted(x, startIndex = 0) {
937
939
  }
938
940
  return false;
939
941
  }
940
- function prefixIssues(path3, issues) {
942
+ function prefixIssues(path, issues) {
941
943
  return issues.map((iss) => {
942
944
  var _a;
943
945
  (_a = iss).path ?? (_a.path = []);
944
- iss.path.unshift(path3);
946
+ iss.path.unshift(path);
945
947
  return iss;
946
948
  });
947
949
  }
@@ -1179,7 +1181,7 @@ function formatError(error, mapper = (issue2) => issue2.message) {
1179
1181
  }
1180
1182
  function treeifyError(error, mapper = (issue2) => issue2.message) {
1181
1183
  const result = { errors: [] };
1182
- const processError = (error2, path3 = []) => {
1184
+ const processError = (error2, path = []) => {
1183
1185
  var _a, _b;
1184
1186
  for (const issue2 of error2.issues) {
1185
1187
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -1189,7 +1191,7 @@ function treeifyError(error, mapper = (issue2) => issue2.message) {
1189
1191
  } else if (issue2.code === "invalid_element") {
1190
1192
  processError({ issues: issue2.issues }, issue2.path);
1191
1193
  } else {
1192
- const fullpath = [...path3, ...issue2.path];
1194
+ const fullpath = [...path, ...issue2.path];
1193
1195
  if (fullpath.length === 0) {
1194
1196
  result.errors.push(mapper(issue2));
1195
1197
  continue;
@@ -1221,8 +1223,8 @@ function treeifyError(error, mapper = (issue2) => issue2.message) {
1221
1223
  }
1222
1224
  function toDotPath(_path) {
1223
1225
  const segs = [];
1224
- const path3 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1225
- for (const seg of path3) {
1226
+ const path = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1227
+ for (const seg of path) {
1226
1228
  if (typeof seg === "number")
1227
1229
  segs.push(`[${seg}]`);
1228
1230
  else if (typeof seg === "symbol")
@@ -13497,13 +13499,13 @@ function resolveRef(ref, ctx) {
13497
13499
  if (!ref.startsWith("#")) {
13498
13500
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
13499
13501
  }
13500
- const path3 = ref.slice(1).split("/").filter(Boolean);
13501
- if (path3.length === 0) {
13502
+ const path = ref.slice(1).split("/").filter(Boolean);
13503
+ if (path.length === 0) {
13502
13504
  return ctx.rootSchema;
13503
13505
  }
13504
13506
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
13505
- if (path3[0] === defsKey) {
13506
- const key = path3[1];
13507
+ if (path[0] === defsKey) {
13508
+ const key = path[1];
13507
13509
  if (!key || !ctx.defs[key]) {
13508
13510
  throw new Error(`Reference not found: ${ref}`);
13509
13511
  }
@@ -14271,7 +14273,12 @@ class BufferSink {
14271
14273
  }
14272
14274
 
14273
14275
  // src/mcp/cli-bridge.ts
14274
- import { getOutputSink, runWithSink, setGlobalSink } from "@uipath/common";
14276
+ import {
14277
+ catchError as catchError3,
14278
+ getOutputSink,
14279
+ runWithSink,
14280
+ setGlobalSink
14281
+ } from "@uipath/common";
14275
14282
  async function executeCommand(command) {
14276
14283
  const args = command.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) || [];
14277
14284
  const cleanArgs = args.map((a) => a.replace(/^["']|["']$/g, ""));
@@ -14293,22 +14300,20 @@ async function executeCommand(command) {
14293
14300
  }
14294
14301
  };
14295
14302
  const previousSink = getOutputSink();
14296
- try {
14297
- setGlobalSink(sink);
14298
- await runWithSink(sink, async () => {
14299
- const { run } = await Promise.resolve().then(() => (init_cli(), exports_cli));
14300
- await run(context);
14301
- });
14302
- } catch (error48) {
14303
+ setGlobalSink(sink);
14304
+ const [error48] = await catchError3(runWithSink(sink, async () => {
14305
+ const { run } = await Promise.resolve().then(() => (init_cli(), exports_cli));
14306
+ await run(context);
14307
+ }));
14308
+ if (error48) {
14303
14309
  if (error48 instanceof ExitError) {
14304
14310
  exitCode = error48.exitCode;
14305
14311
  } else {
14306
14312
  exitCode = 1;
14307
14313
  sink.writeErr(error48 instanceof Error ? error48.message : String(error48));
14308
14314
  }
14309
- } finally {
14310
- setGlobalSink(previousSink);
14311
14315
  }
14316
+ setGlobalSink(previousSink);
14312
14317
  return { stdout: sink.stdout, stderr: sink.stderr, exitCode };
14313
14318
  }
14314
14319
  var ExitError;
@@ -14358,7 +14363,7 @@ function introspectCommands(program) {
14358
14363
  }
14359
14364
  lines.push(`
14360
14365
  Global Options (can be used with any command):`, " --output <table|json|yaml|plain>: Output format (default: json)", " --output-filter <expression>: JMESPath expression to filter output", " --log-level <debug|info|warn|error>: Log level threshold (default: info)", " --log-file <path>: Write logs to file instead of stderr", `
14361
- Pass the command without the 'uip' prefix. Example: "login status --output json"`, `Filter example: "tools installed --output-filter 'Data[].name'"`);
14366
+ Pass the command without the 'uip' prefix. Example: "login status --output json"`, `Filter example: "tools list --output-filter 'Data[].name'"`);
14362
14367
  return lines.join(`
14363
14368
  `);
14364
14369
  }
@@ -14802,8 +14807,8 @@ class ParseStatus {
14802
14807
  }
14803
14808
  }
14804
14809
  var makeIssue = (params) => {
14805
- const { data, path: path3, errorMaps, issueData } = params;
14806
- const fullPath = [...path3, ...issueData.path || []];
14810
+ const { data, path, errorMaps, issueData } = params;
14811
+ const fullPath = [...path, ...issueData.path || []];
14807
14812
  const fullIssue = {
14808
14813
  ...issueData,
14809
14814
  path: fullPath
@@ -14848,11 +14853,11 @@ var init_errorUtil = __esm(() => {
14848
14853
 
14849
14854
  // ../../node_modules/zod/v3/types.js
14850
14855
  class ParseInputLazyPath {
14851
- constructor(parent, value, path3, key) {
14856
+ constructor(parent, value, path, key) {
14852
14857
  this._cachedPath = [];
14853
14858
  this.parent = parent;
14854
14859
  this.data = value;
14855
- this._path = path3;
14860
+ this._path = path;
14856
14861
  this._key = key;
14857
14862
  }
14858
14863
  get path() {
@@ -18429,7 +18434,7 @@ var init_types2 = __esm(() => {
18429
18434
  ProgressTokenSchema = union([string2(), number2().int()]);
18430
18435
  CursorSchema = string2();
18431
18436
  TaskCreationParamsSchema = looseObject({
18432
- ttl: union([number2(), _null3()]).optional(),
18437
+ ttl: number2().optional(),
18433
18438
  pollInterval: number2().optional()
18434
18439
  });
18435
18440
  TaskMetadataSchema = object({
@@ -18577,7 +18582,8 @@ var init_types2 = __esm(() => {
18577
18582
  roots: object({
18578
18583
  listChanged: boolean2().optional()
18579
18584
  }).optional(),
18580
- tasks: ClientTasksCapabilitySchema.optional()
18585
+ tasks: ClientTasksCapabilitySchema.optional(),
18586
+ extensions: record(string2(), AssertObjectSchema).optional()
18581
18587
  });
18582
18588
  InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
18583
18589
  protocolVersion: string2(),
@@ -18602,7 +18608,8 @@ var init_types2 = __esm(() => {
18602
18608
  tools: object({
18603
18609
  listChanged: boolean2().optional()
18604
18610
  }).optional(),
18605
- tasks: ServerTasksCapabilitySchema.optional()
18611
+ tasks: ServerTasksCapabilitySchema.optional(),
18612
+ extensions: record(string2(), AssertObjectSchema).optional()
18606
18613
  });
18607
18614
  InitializeResultSchema = ResultSchema.extend({
18608
18615
  protocolVersion: string2(),
@@ -18717,6 +18724,7 @@ var init_types2 = __esm(() => {
18717
18724
  uri: string2(),
18718
18725
  description: optional(string2()),
18719
18726
  mimeType: optional(string2()),
18727
+ size: optional(number2()),
18720
18728
  annotations: AnnotationsSchema.optional(),
18721
18729
  _meta: optional(looseObject({}))
18722
18730
  });
@@ -24665,8 +24673,8 @@ var require_utils = __commonJS((exports, module) => {
24665
24673
  }
24666
24674
  return ind;
24667
24675
  }
24668
- function removeDotSegments(path3) {
24669
- let input = path3;
24676
+ function removeDotSegments(path) {
24677
+ let input = path;
24670
24678
  const output = [];
24671
24679
  let nextSlash = -1;
24672
24680
  let len = 0;
@@ -24856,8 +24864,8 @@ var require_schemes = __commonJS((exports, module) => {
24856
24864
  wsComponent.secure = undefined;
24857
24865
  }
24858
24866
  if (wsComponent.resourceName) {
24859
- const [path3, query] = wsComponent.resourceName.split("?");
24860
- wsComponent.path = path3 && path3 !== "/" ? path3 : undefined;
24867
+ const [path, query] = wsComponent.resourceName.split("?");
24868
+ wsComponent.path = path && path !== "/" ? path : undefined;
24861
24869
  wsComponent.query = query;
24862
24870
  wsComponent.resourceName = undefined;
24863
24871
  }
@@ -26083,6 +26091,7 @@ var require_limitLength = __commonJS((exports) => {
26083
26091
  var require_pattern = __commonJS((exports) => {
26084
26092
  Object.defineProperty(exports, "__esModule", { value: true });
26085
26093
  var code_1 = require_code2();
26094
+ var util_1 = require_util();
26086
26095
  var codegen_1 = require_codegen();
26087
26096
  var error48 = {
26088
26097
  message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
@@ -26095,10 +26104,18 @@ var require_pattern = __commonJS((exports) => {
26095
26104
  $data: true,
26096
26105
  error: error48,
26097
26106
  code(cxt) {
26098
- const { data, $data, schema, schemaCode, it } = cxt;
26107
+ const { gen, data, $data, schema, schemaCode, it } = cxt;
26099
26108
  const u = it.opts.unicodeRegExp ? "u" : "";
26100
- const regExp = $data ? (0, codegen_1._)`(new RegExp(${schemaCode}, ${u}))` : (0, code_1.usePattern)(cxt, schema);
26101
- cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
26109
+ if ($data) {
26110
+ const { regExp } = it.opts.code;
26111
+ const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
26112
+ const valid = gen.let("valid");
26113
+ gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
26114
+ cxt.fail$data((0, codegen_1._)`!${valid}`);
26115
+ } else {
26116
+ const regExp = (0, code_1.usePattern)(cxt, schema);
26117
+ cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
26118
+ }
26102
26119
  }
26103
26120
  };
26104
26121
  exports.default = def;
@@ -29729,16 +29746,16 @@ __export(exports_claude, {
29729
29746
  install: () => install
29730
29747
  });
29731
29748
  import { logger } from "@uipath/common";
29732
- import { getFileSystem } from "@uipath/filesystem";
29749
+ import { getFileSystem as getFileSystem3 } from "@uipath/filesystem";
29733
29750
  async function install(skill, rootDir) {
29734
- const fs = getFileSystem();
29751
+ const fs = getFileSystem3();
29735
29752
  const target = fs.path.join(rootDir, ".claude", "skills", skill.name);
29736
29753
  await fs.mkdir(target);
29737
29754
  await fs.copyDirectory(skill.skillDir, target);
29738
29755
  logger.info(` claude: installed ${skill.name}`);
29739
29756
  }
29740
29757
  async function uninstall(skillName, rootDir) {
29741
- const fs = getFileSystem();
29758
+ const fs = getFileSystem3();
29742
29759
  const target = fs.path.join(rootDir, ".claude", "skills", skillName);
29743
29760
  if (await fs.exists(target)) {
29744
29761
  await fs.rm(target);
@@ -32395,15 +32412,15 @@ var init_js_yaml = __esm(() => {
32395
32412
 
32396
32413
  // src/commands/skills/contentStore.ts
32397
32414
  import { spawn } from "node:child_process";
32398
- import { catchError as catchError3, logger as logger2, UIPATH_HOME_DIR } from "@uipath/common";
32399
- import { getFileSystem as getFileSystem2 } from "@uipath/filesystem";
32415
+ import { catchError as catchError4, logger as logger2, UIPATH_HOME_DIR } from "@uipath/common";
32416
+ import { getFileSystem as getFileSystem4 } from "@uipath/filesystem";
32400
32417
  async function getContentStore(rootDir) {
32401
- const fs = getFileSystem2();
32418
+ const fs = getFileSystem4();
32402
32419
  const storePath = fs.path.join(rootDir, STORE_NAME);
32403
32420
  let needsClone = true;
32404
32421
  if (await fs.exists(fs.path.join(storePath, ".git"))) {
32405
32422
  logger2.info("Updating content store...");
32406
- const [pullError] = await catchError3(runGit(["pull", "--ff-only"], storePath));
32423
+ const [pullError] = await catchError4(runGit(["pull", "--ff-only"], storePath));
32407
32424
  if (pullError) {
32408
32425
  logger2.warn("git pull failed, re-cloning...");
32409
32426
  } else {
@@ -32421,7 +32438,7 @@ async function getContentStore(rootDir) {
32421
32438
  await fs.rm(storePath);
32422
32439
  }
32423
32440
  await fs.mkdir(storePath);
32424
- const [cloneError] = await catchError3(runGit(["clone", "--depth", "1", REPO_URL, storePath], rootDir));
32441
+ const [cloneError] = await catchError4(runGit(["clone", "--depth", "1", REPO_URL, storePath], rootDir));
32425
32442
  if (cloneError) {
32426
32443
  logger2.info("git clone failed, falling back to zip download...");
32427
32444
  await downloadAndExtractZip(storePath);
@@ -32432,8 +32449,16 @@ async function getContentStore(rootDir) {
32432
32449
  }
32433
32450
  return storePath;
32434
32451
  }
32452
+ async function readSkillDescription(fs, skillMdPath) {
32453
+ const [err, content] = await catchError4(fs.readFile(skillMdPath, { encoding: "utf-8" }));
32454
+ if (err || !content)
32455
+ return;
32456
+ const head = content.length > 2048 ? content.slice(0, 2048) : content;
32457
+ const { meta: meta3 } = parseSkillMd(head);
32458
+ return meta3.description;
32459
+ }
32435
32460
  async function getAvailableSkills(storePath) {
32436
- const fs = getFileSystem2();
32461
+ const fs = getFileSystem4();
32437
32462
  const skills = [];
32438
32463
  const rootSkillsDir = fs.path.join(storePath, "skills");
32439
32464
  if (await fs.exists(rootSkillsDir)) {
@@ -32442,7 +32467,8 @@ async function getAvailableSkills(storePath) {
32442
32467
  const skillDir = fs.path.join(rootSkillsDir, name);
32443
32468
  const stat = await fs.stat(skillDir);
32444
32469
  if (stat?.isDirectory() && await fs.exists(fs.path.join(skillDir, "SKILL.md"))) {
32445
- skills.push({ name, skillDir });
32470
+ const description = await readSkillDescription(fs, fs.path.join(skillDir, "SKILL.md"));
32471
+ skills.push({ name, skillDir, description });
32446
32472
  }
32447
32473
  }
32448
32474
  }
@@ -32462,7 +32488,8 @@ async function getAvailableSkills(storePath) {
32462
32488
  const skillDir = fs.path.join(entrySkillsDir, name);
32463
32489
  const stat = await fs.stat(skillDir);
32464
32490
  if (stat?.isDirectory() && await fs.exists(fs.path.join(skillDir, "SKILL.md"))) {
32465
- skills.push({ name, skillDir });
32491
+ const description = await readSkillDescription(fs, fs.path.join(skillDir, "SKILL.md"));
32492
+ skills.push({ name, skillDir, description });
32466
32493
  }
32467
32494
  }
32468
32495
  }
@@ -32477,7 +32504,7 @@ function parseSkillMd(content) {
32477
32504
  return { meta: meta3, body: fmMatch[2] };
32478
32505
  }
32479
32506
  async function getSkillMetadata(skillMdPath) {
32480
- const fs = getFileSystem2();
32507
+ const fs = getFileSystem4();
32481
32508
  const content = await fs.readFile(skillMdPath, { encoding: "utf-8" });
32482
32509
  if (content === null) {
32483
32510
  throw new Error(`Skill metadata not found: ${skillMdPath}`);
@@ -32485,7 +32512,7 @@ async function getSkillMetadata(skillMdPath) {
32485
32512
  return parseSkillMd(content);
32486
32513
  }
32487
32514
  function rewriteBody(body, skillDir, targetDir) {
32488
- const fs = getFileSystem2();
32515
+ const fs = getFileSystem4();
32489
32516
  const relFromTarget = fs.path.relative(targetDir, skillDir).split("\\").join("/");
32490
32517
  return body.replace(/(\[.*?\]\()(?!https?:\/\/|\/)([^)]+?)(\))/g, (_match, prefix, relPath, suffix) => {
32491
32518
  const rewritten = [relFromTarget, relPath].join("/").replace(/\/+/g, "/");
@@ -32495,7 +32522,7 @@ function rewriteBody(body, skillDir, targetDir) {
32495
32522
  async function setMarkedBlock(filePath, marker, content, commentStyle = "hash") {
32496
32523
  const startTag = commentStyle === "html" ? `<!-- ${marker} START -->` : `# ${marker} START`;
32497
32524
  const endTag = commentStyle === "html" ? `<!-- ${marker} END -->` : `# ${marker} END`;
32498
- const fs = getFileSystem2();
32525
+ const fs = getFileSystem4();
32499
32526
  const block = `${startTag}
32500
32527
  ${content}
32501
32528
  ${endTag}`;
@@ -32514,7 +32541,7 @@ ${endTag}`;
32514
32541
  }
32515
32542
  }
32516
32543
  async function removeMarkedBlock(filePath, marker, commentStyle = "hash") {
32517
- const fs = getFileSystem2();
32544
+ const fs = getFileSystem4();
32518
32545
  const startTag = commentStyle === "html" ? `<!-- ${marker} START -->` : `# ${marker} START`;
32519
32546
  const endTag = commentStyle === "html" ? `<!-- ${marker} END -->` : `# ${marker} END`;
32520
32547
  const existing = await fs.readFile(filePath, { encoding: "utf-8" });
@@ -32531,7 +32558,7 @@ async function removeMarkedBlock(filePath, marker, commentStyle = "hash") {
32531
32558
  await fs.writeFile(filePath, updated);
32532
32559
  }
32533
32560
  async function addToGitignore(rootDir, entry) {
32534
- const fs = getFileSystem2();
32561
+ const fs = getFileSystem4();
32535
32562
  const gitignorePath = fs.path.join(rootDir, ".gitignore");
32536
32563
  const content = await fs.readFile(gitignorePath, { encoding: "utf-8" }) ?? "";
32537
32564
  const lines = content.split(`
@@ -32545,19 +32572,19 @@ async function addToGitignore(rootDir, entry) {
32545
32572
  }
32546
32573
  }
32547
32574
  async function readManifest(storePath) {
32548
- const fs = getFileSystem2();
32575
+ const fs = getFileSystem4();
32549
32576
  const manifestPath = fs.path.join(storePath, MANIFEST_NAME);
32550
32577
  const content = await fs.readFile(manifestPath, { encoding: "utf-8" });
32551
32578
  if (content === null) {
32552
32579
  return { skills: {} };
32553
32580
  }
32554
- const [parseError, parsed] = catchError3(() => JSON.parse(content));
32581
+ const [parseError, parsed] = catchError4(() => JSON.parse(content));
32555
32582
  if (parseError)
32556
32583
  return { skills: {} };
32557
32584
  return parsed;
32558
32585
  }
32559
32586
  async function writeManifest(storePath, manifest) {
32560
- const fs = getFileSystem2();
32587
+ const fs = getFileSystem4();
32561
32588
  const manifestPath = fs.path.join(storePath, MANIFEST_NAME);
32562
32589
  await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 4)}
32563
32590
  `);
@@ -32623,7 +32650,7 @@ function runGit(args, cwd) {
32623
32650
  });
32624
32651
  }
32625
32652
  async function downloadAndExtractZip(storePath) {
32626
- const fs = getFileSystem2();
32653
+ const fs = getFileSystem4();
32627
32654
  const response = await fetch(ZIP_URL, {
32628
32655
  signal: AbortSignal.timeout(60000)
32629
32656
  });
@@ -32675,9 +32702,9 @@ __export(exports_codex, {
32675
32702
  install: () => install2
32676
32703
  });
32677
32704
  import { logger as logger3 } from "@uipath/common";
32678
- import { getFileSystem as getFileSystem3 } from "@uipath/filesystem";
32705
+ import { getFileSystem as getFileSystem5 } from "@uipath/filesystem";
32679
32706
  async function install2(skill, rootDir) {
32680
- const fs = getFileSystem3();
32707
+ const fs = getFileSystem5();
32681
32708
  const isGlobal = fs.path.resolve(rootDir) === fs.path.resolve(fs.env.homedir());
32682
32709
  const targetFile = isGlobal ? fs.path.join(rootDir, ".codex", "instructions.md") : fs.path.join(rootDir, "codex.md");
32683
32710
  await fs.mkdir(fs.path.dirname(targetFile));
@@ -32689,7 +32716,7 @@ async function install2(skill, rootDir) {
32689
32716
  logger3.info(` codex: installed ${skill.name}`);
32690
32717
  }
32691
32718
  async function uninstall2(skillName, rootDir) {
32692
- const fs = getFileSystem3();
32719
+ const fs = getFileSystem5();
32693
32720
  const isGlobal = fs.path.resolve(rootDir) === fs.path.resolve(fs.env.homedir());
32694
32721
  const targetFile = isGlobal ? fs.path.join(rootDir, ".codex", "instructions.md") : fs.path.join(rootDir, "codex.md");
32695
32722
  const marker = `uipath-skill:${skillName}`;
@@ -32706,9 +32733,9 @@ __export(exports_copilot, {
32706
32733
  install: () => install3
32707
32734
  });
32708
32735
  import { logger as logger4 } from "@uipath/common";
32709
- import { getFileSystem as getFileSystem4 } from "@uipath/filesystem";
32736
+ import { getFileSystem as getFileSystem6 } from "@uipath/filesystem";
32710
32737
  async function install3(skill, rootDir) {
32711
- const fs = getFileSystem4();
32738
+ const fs = getFileSystem6();
32712
32739
  const skillMdPath = fs.path.join(skill.skillDir, "SKILL.md");
32713
32740
  const { meta: meta3, body } = await getSkillMetadata(skillMdPath);
32714
32741
  const targetDir = fs.path.join(rootDir, ".github", "instructions");
@@ -32722,7 +32749,7 @@ applyTo: "${Array.isArray(meta3.globs) ? meta3.globs.join(", ") : meta3.globs}"
32722
32749
  logger4.info(` copilot: installed ${skill.name}`);
32723
32750
  }
32724
32751
  async function uninstall3(skillName, rootDir) {
32725
- const fs = getFileSystem4();
32752
+ const fs = getFileSystem6();
32726
32753
  const target = fs.path.join(rootDir, ".github", "instructions", `${skillName}.instructions.md`);
32727
32754
  if (await fs.exists(target)) {
32728
32755
  await fs.rm(target);
@@ -32739,9 +32766,9 @@ __export(exports_cursor, {
32739
32766
  install: () => install4
32740
32767
  });
32741
32768
  import { logger as logger5 } from "@uipath/common";
32742
- import { getFileSystem as getFileSystem5 } from "@uipath/filesystem";
32769
+ import { getFileSystem as getFileSystem7 } from "@uipath/filesystem";
32743
32770
  async function install4(skill, rootDir) {
32744
- const fs = getFileSystem5();
32771
+ const fs = getFileSystem7();
32745
32772
  const skillMdPath = fs.path.join(skill.skillDir, "SKILL.md");
32746
32773
  const { meta: meta3, body } = await getSkillMetadata(skillMdPath);
32747
32774
  const targetDir = fs.path.join(rootDir, ".cursor", "rules");
@@ -32752,7 +32779,7 @@ async function install4(skill, rootDir) {
32752
32779
  logger5.info(` cursor: installed ${skill.name}`);
32753
32780
  }
32754
32781
  async function uninstall4(skillName, rootDir) {
32755
- const fs = getFileSystem5();
32782
+ const fs = getFileSystem7();
32756
32783
  const target = fs.path.join(rootDir, ".cursor", "rules", `${skillName}.mdc`);
32757
32784
  if (await fs.exists(target)) {
32758
32785
  await fs.rm(target);
@@ -32784,9 +32811,9 @@ __export(exports_gemini, {
32784
32811
  install: () => install5
32785
32812
  });
32786
32813
  import { logger as logger6 } from "@uipath/common";
32787
- import { getFileSystem as getFileSystem6 } from "@uipath/filesystem";
32814
+ import { getFileSystem as getFileSystem8 } from "@uipath/filesystem";
32788
32815
  async function install5(skill, rootDir) {
32789
- const fs = getFileSystem6();
32816
+ const fs = getFileSystem8();
32790
32817
  const geminiDir = fs.path.join(rootDir, ".gemini");
32791
32818
  const geminiMd = fs.path.join(geminiDir, "GEMINI.md");
32792
32819
  await fs.mkdir(geminiDir);
@@ -32798,7 +32825,7 @@ async function install5(skill, rootDir) {
32798
32825
  logger6.info(` gemini: installed ${skill.name}`);
32799
32826
  }
32800
32827
  async function uninstall5(skillName, rootDir) {
32801
- const fs = getFileSystem6();
32828
+ const fs = getFileSystem8();
32802
32829
  const geminiMd = fs.path.join(rootDir, ".gemini", "GEMINI.md");
32803
32830
  const marker = `uipath-skill:${skillName}`;
32804
32831
  await removeMarkedBlock(geminiMd, marker, "html");
@@ -32827,74 +32854,1884 @@ var init_agents = __esm(() => {
32827
32854
  };
32828
32855
  });
32829
32856
 
32830
- // src/commands/skills/prompt.ts
32831
- import { createInterface } from "node:readline";
32832
- function ask(rl, prompt) {
32833
- return new Promise((resolve, reject) => {
32834
- rl.question(prompt, (line) => {
32835
- resolve(line.trim());
32857
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/key.js
32858
+ var isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p", isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n", isSpaceKey = (key) => key.name === "space", isNumberKey = (key) => "1234567890".includes(key.name), isEnterKey = (key) => key.name === "enter" || key.name === "return";
32859
+
32860
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/errors.js
32861
+ var AbortPromptError, CancelPromptError, ExitPromptError, HookError, ValidationError;
32862
+ var init_errors4 = __esm(() => {
32863
+ AbortPromptError = class AbortPromptError extends Error {
32864
+ name = "AbortPromptError";
32865
+ message = "Prompt was aborted";
32866
+ constructor(options) {
32867
+ super();
32868
+ this.cause = options?.cause;
32869
+ }
32870
+ };
32871
+ CancelPromptError = class CancelPromptError extends Error {
32872
+ name = "CancelPromptError";
32873
+ message = "Prompt was canceled";
32874
+ };
32875
+ ExitPromptError = class ExitPromptError extends Error {
32876
+ name = "ExitPromptError";
32877
+ };
32878
+ HookError = class HookError extends Error {
32879
+ name = "HookError";
32880
+ };
32881
+ ValidationError = class ValidationError extends Error {
32882
+ name = "ValidationError";
32883
+ };
32884
+ });
32885
+
32886
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/hook-engine.js
32887
+ import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
32888
+ function createStore(rl) {
32889
+ const store = {
32890
+ rl,
32891
+ hooks: [],
32892
+ hooksCleanup: [],
32893
+ hooksEffect: [],
32894
+ index: 0,
32895
+ handleChange() {}
32896
+ };
32897
+ return store;
32898
+ }
32899
+ function withHooks(rl, cb) {
32900
+ const store = createStore(rl);
32901
+ return hookStorage.run(store, () => {
32902
+ function cycle(render) {
32903
+ store.handleChange = () => {
32904
+ store.index = 0;
32905
+ render();
32906
+ };
32907
+ store.handleChange();
32908
+ }
32909
+ return cb(cycle);
32910
+ });
32911
+ }
32912
+ function getStore() {
32913
+ const store = hookStorage.getStore();
32914
+ if (!store) {
32915
+ throw new HookError("[Inquirer] Hook functions can only be called from within a prompt");
32916
+ }
32917
+ return store;
32918
+ }
32919
+ function readline() {
32920
+ return getStore().rl;
32921
+ }
32922
+ function withUpdates(fn) {
32923
+ const wrapped = (...args) => {
32924
+ const store = getStore();
32925
+ let shouldUpdate = false;
32926
+ const oldHandleChange = store.handleChange;
32927
+ store.handleChange = () => {
32928
+ shouldUpdate = true;
32929
+ };
32930
+ const returnValue = fn(...args);
32931
+ if (shouldUpdate) {
32932
+ oldHandleChange();
32933
+ }
32934
+ store.handleChange = oldHandleChange;
32935
+ return returnValue;
32936
+ };
32937
+ return AsyncResource.bind(wrapped);
32938
+ }
32939
+ function withPointer(cb) {
32940
+ const store = getStore();
32941
+ const { index } = store;
32942
+ const pointer = {
32943
+ get() {
32944
+ return store.hooks[index];
32945
+ },
32946
+ set(value) {
32947
+ store.hooks[index] = value;
32948
+ },
32949
+ initialized: index in store.hooks
32950
+ };
32951
+ const returnValue = cb(pointer);
32952
+ store.index++;
32953
+ return returnValue;
32954
+ }
32955
+ function handleChange() {
32956
+ getStore().handleChange();
32957
+ }
32958
+ var hookStorage, effectScheduler;
32959
+ var init_hook_engine = __esm(() => {
32960
+ init_errors4();
32961
+ hookStorage = new AsyncLocalStorage;
32962
+ effectScheduler = {
32963
+ queue(cb) {
32964
+ const store = getStore();
32965
+ const { index } = store;
32966
+ store.hooksEffect.push(() => {
32967
+ store.hooksCleanup[index]?.();
32968
+ const cleanFn = cb(readline());
32969
+ if (cleanFn != null && typeof cleanFn !== "function") {
32970
+ throw new ValidationError("useEffect return value must be a cleanup function or nothing.");
32971
+ }
32972
+ store.hooksCleanup[index] = cleanFn;
32973
+ });
32974
+ },
32975
+ run() {
32976
+ const store = getStore();
32977
+ withUpdates(() => {
32978
+ store.hooksEffect.forEach((effect) => {
32979
+ effect();
32980
+ });
32981
+ store.hooksEffect.length = 0;
32982
+ })();
32983
+ },
32984
+ clearAll() {
32985
+ const store = getStore();
32986
+ store.hooksCleanup.forEach((cleanFn) => {
32987
+ cleanFn?.();
32988
+ });
32989
+ store.hooksEffect.length = 0;
32990
+ store.hooksCleanup.length = 0;
32991
+ }
32992
+ };
32993
+ });
32994
+
32995
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/use-state.js
32996
+ import { AsyncResource as AsyncResource2 } from "node:async_hooks";
32997
+ function useState(defaultValue) {
32998
+ return withPointer((pointer) => {
32999
+ const setState = AsyncResource2.bind(function setState2(newValue) {
33000
+ if (pointer.get() !== newValue) {
33001
+ pointer.set(newValue);
33002
+ handleChange();
33003
+ }
32836
33004
  });
32837
- rl.once("close", () => reject(new Error("Input stream closed before selection.")));
33005
+ if (pointer.initialized) {
33006
+ return [pointer.get(), setState];
33007
+ }
33008
+ const value = typeof defaultValue === "function" ? defaultValue() : defaultValue;
33009
+ pointer.set(value);
33010
+ return [value, setState];
32838
33011
  });
32839
33012
  }
32840
- async function promptAgentSelection(operation = "manage") {
32841
- const rl = createInterface({
32842
- input: process.stdin,
32843
- output: process.stderr
33013
+ var init_use_state = __esm(() => {
33014
+ init_hook_engine();
33015
+ });
33016
+
33017
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/use-effect.js
33018
+ function useEffect(cb, depArray) {
33019
+ withPointer((pointer) => {
33020
+ const oldDeps = pointer.get();
33021
+ const hasChanged = !Array.isArray(oldDeps) || depArray.some((dep, i2) => !Object.is(dep, oldDeps[i2]));
33022
+ if (hasChanged) {
33023
+ effectScheduler.queue(cb);
33024
+ }
33025
+ pointer.set(depArray);
32844
33026
  });
32845
- const prompt = `
32846
- Select agents to ${operation} skills for:
32847
- ` + ALL_AGENTS.map((a, i2) => ` ${i2 + 1}. ${AGENT_DISPLAY_NAMES[a]}`).join(`
32848
- `) + `
33027
+ }
33028
+ var init_use_effect = __esm(() => {
33029
+ init_hook_engine();
33030
+ });
32849
33031
 
32850
- Enter numbers separated by commas (e.g., 1,2,3) or 'all': `;
32851
- try {
33032
+ // ../../node_modules/@inquirer/figures/dist/index.js
33033
+ import process4 from "node:process";
33034
+ function isUnicodeSupported() {
33035
+ if (process4.platform !== "win32") {
33036
+ return process4.env["TERM"] !== "linux";
33037
+ }
33038
+ return Boolean(process4.env["WT_SESSION"]) || Boolean(process4.env["TERMINUS_SUBLIME"]) || process4.env["ConEmuTask"] === "{cmd::Cmder}" || process4.env["TERM_PROGRAM"] === "Terminus-Sublime" || process4.env["TERM_PROGRAM"] === "vscode" || process4.env["TERM"] === "xterm-256color" || process4.env["TERM"] === "alacritty" || process4.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
33039
+ }
33040
+ var common2, specialMainSymbols, specialFallbackSymbols, mainSymbols, fallbackSymbols, shouldUseMain, figures, dist_default, replacements;
33041
+ var init_dist = __esm(() => {
33042
+ common2 = {
33043
+ circleQuestionMark: "(?)",
33044
+ questionMarkPrefix: "(?)",
33045
+ square: "█",
33046
+ squareDarkShade: "▓",
33047
+ squareMediumShade: "▒",
33048
+ squareLightShade: "░",
33049
+ squareTop: "▀",
33050
+ squareBottom: "▄",
33051
+ squareLeft: "▌",
33052
+ squareRight: "▐",
33053
+ squareCenter: "■",
33054
+ bullet: "●",
33055
+ dot: "․",
33056
+ ellipsis: "…",
33057
+ pointerSmall: "›",
33058
+ triangleUp: "▲",
33059
+ triangleUpSmall: "▴",
33060
+ triangleDown: "▼",
33061
+ triangleDownSmall: "▾",
33062
+ triangleLeftSmall: "◂",
33063
+ triangleRightSmall: "▸",
33064
+ home: "⌂",
33065
+ heart: "♥",
33066
+ musicNote: "♪",
33067
+ musicNoteBeamed: "♫",
33068
+ arrowUp: "↑",
33069
+ arrowDown: "↓",
33070
+ arrowLeft: "←",
33071
+ arrowRight: "→",
33072
+ arrowLeftRight: "↔",
33073
+ arrowUpDown: "↕",
33074
+ almostEqual: "≈",
33075
+ notEqual: "≠",
33076
+ lessOrEqual: "≤",
33077
+ greaterOrEqual: "≥",
33078
+ identical: "≡",
33079
+ infinity: "∞",
33080
+ subscriptZero: "₀",
33081
+ subscriptOne: "₁",
33082
+ subscriptTwo: "₂",
33083
+ subscriptThree: "₃",
33084
+ subscriptFour: "₄",
33085
+ subscriptFive: "₅",
33086
+ subscriptSix: "₆",
33087
+ subscriptSeven: "₇",
33088
+ subscriptEight: "₈",
33089
+ subscriptNine: "₉",
33090
+ oneHalf: "½",
33091
+ oneThird: "⅓",
33092
+ oneQuarter: "¼",
33093
+ oneFifth: "⅕",
33094
+ oneSixth: "⅙",
33095
+ oneEighth: "⅛",
33096
+ twoThirds: "⅔",
33097
+ twoFifths: "⅖",
33098
+ threeQuarters: "¾",
33099
+ threeFifths: "⅗",
33100
+ threeEighths: "⅜",
33101
+ fourFifths: "⅘",
33102
+ fiveSixths: "⅚",
33103
+ fiveEighths: "⅝",
33104
+ sevenEighths: "⅞",
33105
+ line: "─",
33106
+ lineBold: "━",
33107
+ lineDouble: "═",
33108
+ lineDashed0: "┄",
33109
+ lineDashed1: "┅",
33110
+ lineDashed2: "┈",
33111
+ lineDashed3: "┉",
33112
+ lineDashed4: "╌",
33113
+ lineDashed5: "╍",
33114
+ lineDashed6: "╴",
33115
+ lineDashed7: "╶",
33116
+ lineDashed8: "╸",
33117
+ lineDashed9: "╺",
33118
+ lineDashed10: "╼",
33119
+ lineDashed11: "╾",
33120
+ lineDashed12: "−",
33121
+ lineDashed13: "–",
33122
+ lineDashed14: "‐",
33123
+ lineDashed15: "⁃",
33124
+ lineVertical: "│",
33125
+ lineVerticalBold: "┃",
33126
+ lineVerticalDouble: "║",
33127
+ lineVerticalDashed0: "┆",
33128
+ lineVerticalDashed1: "┇",
33129
+ lineVerticalDashed2: "┊",
33130
+ lineVerticalDashed3: "┋",
33131
+ lineVerticalDashed4: "╎",
33132
+ lineVerticalDashed5: "╏",
33133
+ lineVerticalDashed6: "╵",
33134
+ lineVerticalDashed7: "╷",
33135
+ lineVerticalDashed8: "╹",
33136
+ lineVerticalDashed9: "╻",
33137
+ lineVerticalDashed10: "╽",
33138
+ lineVerticalDashed11: "╿",
33139
+ lineDownLeft: "┐",
33140
+ lineDownLeftArc: "╮",
33141
+ lineDownBoldLeftBold: "┓",
33142
+ lineDownBoldLeft: "┒",
33143
+ lineDownLeftBold: "┑",
33144
+ lineDownDoubleLeftDouble: "╗",
33145
+ lineDownDoubleLeft: "╖",
33146
+ lineDownLeftDouble: "╕",
33147
+ lineDownRight: "┌",
33148
+ lineDownRightArc: "╭",
33149
+ lineDownBoldRightBold: "┏",
33150
+ lineDownBoldRight: "┎",
33151
+ lineDownRightBold: "┍",
33152
+ lineDownDoubleRightDouble: "╔",
33153
+ lineDownDoubleRight: "╓",
33154
+ lineDownRightDouble: "╒",
33155
+ lineUpLeft: "┘",
33156
+ lineUpLeftArc: "╯",
33157
+ lineUpBoldLeftBold: "┛",
33158
+ lineUpBoldLeft: "┚",
33159
+ lineUpLeftBold: "┙",
33160
+ lineUpDoubleLeftDouble: "╝",
33161
+ lineUpDoubleLeft: "╜",
33162
+ lineUpLeftDouble: "╛",
33163
+ lineUpRight: "└",
33164
+ lineUpRightArc: "╰",
33165
+ lineUpBoldRightBold: "┗",
33166
+ lineUpBoldRight: "┖",
33167
+ lineUpRightBold: "┕",
33168
+ lineUpDoubleRightDouble: "╚",
33169
+ lineUpDoubleRight: "╙",
33170
+ lineUpRightDouble: "╘",
33171
+ lineUpDownLeft: "┤",
33172
+ lineUpBoldDownBoldLeftBold: "┫",
33173
+ lineUpBoldDownBoldLeft: "┨",
33174
+ lineUpDownLeftBold: "┥",
33175
+ lineUpBoldDownLeftBold: "┩",
33176
+ lineUpDownBoldLeftBold: "┪",
33177
+ lineUpDownBoldLeft: "┧",
33178
+ lineUpBoldDownLeft: "┦",
33179
+ lineUpDoubleDownDoubleLeftDouble: "╣",
33180
+ lineUpDoubleDownDoubleLeft: "╢",
33181
+ lineUpDownLeftDouble: "╡",
33182
+ lineUpDownRight: "├",
33183
+ lineUpBoldDownBoldRightBold: "┣",
33184
+ lineUpBoldDownBoldRight: "┠",
33185
+ lineUpDownRightBold: "┝",
33186
+ lineUpBoldDownRightBold: "┡",
33187
+ lineUpDownBoldRightBold: "┢",
33188
+ lineUpDownBoldRight: "┟",
33189
+ lineUpBoldDownRight: "┞",
33190
+ lineUpDoubleDownDoubleRightDouble: "╠",
33191
+ lineUpDoubleDownDoubleRight: "╟",
33192
+ lineUpDownRightDouble: "╞",
33193
+ lineDownLeftRight: "┬",
33194
+ lineDownBoldLeftBoldRightBold: "┳",
33195
+ lineDownLeftBoldRightBold: "┯",
33196
+ lineDownBoldLeftRight: "┰",
33197
+ lineDownBoldLeftBoldRight: "┱",
33198
+ lineDownBoldLeftRightBold: "┲",
33199
+ lineDownLeftRightBold: "┮",
33200
+ lineDownLeftBoldRight: "┭",
33201
+ lineDownDoubleLeftDoubleRightDouble: "╦",
33202
+ lineDownDoubleLeftRight: "╥",
33203
+ lineDownLeftDoubleRightDouble: "╤",
33204
+ lineUpLeftRight: "┴",
33205
+ lineUpBoldLeftBoldRightBold: "┻",
33206
+ lineUpLeftBoldRightBold: "┷",
33207
+ lineUpBoldLeftRight: "┸",
33208
+ lineUpBoldLeftBoldRight: "┹",
33209
+ lineUpBoldLeftRightBold: "┺",
33210
+ lineUpLeftRightBold: "┶",
33211
+ lineUpLeftBoldRight: "┵",
33212
+ lineUpDoubleLeftDoubleRightDouble: "╩",
33213
+ lineUpDoubleLeftRight: "╨",
33214
+ lineUpLeftDoubleRightDouble: "╧",
33215
+ lineUpDownLeftRight: "┼",
33216
+ lineUpBoldDownBoldLeftBoldRightBold: "╋",
33217
+ lineUpDownBoldLeftBoldRightBold: "╈",
33218
+ lineUpBoldDownLeftBoldRightBold: "╇",
33219
+ lineUpBoldDownBoldLeftRightBold: "╊",
33220
+ lineUpBoldDownBoldLeftBoldRight: "╉",
33221
+ lineUpBoldDownLeftRight: "╀",
33222
+ lineUpDownBoldLeftRight: "╁",
33223
+ lineUpDownLeftBoldRight: "┽",
33224
+ lineUpDownLeftRightBold: "┾",
33225
+ lineUpBoldDownBoldLeftRight: "╂",
33226
+ lineUpDownLeftBoldRightBold: "┿",
33227
+ lineUpBoldDownLeftBoldRight: "╃",
33228
+ lineUpBoldDownLeftRightBold: "╄",
33229
+ lineUpDownBoldLeftBoldRight: "╅",
33230
+ lineUpDownBoldLeftRightBold: "╆",
33231
+ lineUpDoubleDownDoubleLeftDoubleRightDouble: "╬",
33232
+ lineUpDoubleDownDoubleLeftRight: "╫",
33233
+ lineUpDownLeftDoubleRightDouble: "╪",
33234
+ lineCross: "╳",
33235
+ lineBackslash: "╲",
33236
+ lineSlash: "╱"
33237
+ };
33238
+ specialMainSymbols = {
33239
+ tick: "✔",
33240
+ info: "ℹ",
33241
+ warning: "⚠",
33242
+ cross: "✘",
33243
+ squareSmall: "◻",
33244
+ squareSmallFilled: "◼",
33245
+ circle: "◯",
33246
+ circleFilled: "◉",
33247
+ circleDotted: "◌",
33248
+ circleDouble: "◎",
33249
+ circleCircle: "ⓞ",
33250
+ circleCross: "ⓧ",
33251
+ circlePipe: "Ⓘ",
33252
+ radioOn: "◉",
33253
+ radioOff: "◯",
33254
+ checkboxOn: "☒",
33255
+ checkboxOff: "☐",
33256
+ checkboxCircleOn: "ⓧ",
33257
+ checkboxCircleOff: "Ⓘ",
33258
+ pointer: "❯",
33259
+ triangleUpOutline: "△",
33260
+ triangleLeft: "◀",
33261
+ triangleRight: "▶",
33262
+ lozenge: "◆",
33263
+ lozengeOutline: "◇",
33264
+ hamburger: "☰",
33265
+ smiley: "㋡",
33266
+ mustache: "෴",
33267
+ star: "★",
33268
+ play: "▶",
33269
+ nodejs: "⬢",
33270
+ oneSeventh: "⅐",
33271
+ oneNinth: "⅑",
33272
+ oneTenth: "⅒"
33273
+ };
33274
+ specialFallbackSymbols = {
33275
+ tick: "√",
33276
+ info: "i",
33277
+ warning: "‼",
33278
+ cross: "×",
33279
+ squareSmall: "□",
33280
+ squareSmallFilled: "■",
33281
+ circle: "( )",
33282
+ circleFilled: "(*)",
33283
+ circleDotted: "( )",
33284
+ circleDouble: "( )",
33285
+ circleCircle: "(○)",
33286
+ circleCross: "(×)",
33287
+ circlePipe: "(│)",
33288
+ radioOn: "(*)",
33289
+ radioOff: "( )",
33290
+ checkboxOn: "[×]",
33291
+ checkboxOff: "[ ]",
33292
+ checkboxCircleOn: "(×)",
33293
+ checkboxCircleOff: "( )",
33294
+ pointer: ">",
33295
+ triangleUpOutline: "∆",
33296
+ triangleLeft: "◄",
33297
+ triangleRight: "►",
33298
+ lozenge: "♦",
33299
+ lozengeOutline: "◊",
33300
+ hamburger: "≡",
33301
+ smiley: "☺",
33302
+ mustache: "┌─┐",
33303
+ star: "✶",
33304
+ play: "►",
33305
+ nodejs: "♦",
33306
+ oneSeventh: "1/7",
33307
+ oneNinth: "1/9",
33308
+ oneTenth: "1/10"
33309
+ };
33310
+ mainSymbols = {
33311
+ ...common2,
33312
+ ...specialMainSymbols
33313
+ };
33314
+ fallbackSymbols = {
33315
+ ...common2,
33316
+ ...specialFallbackSymbols
33317
+ };
33318
+ shouldUseMain = isUnicodeSupported();
33319
+ figures = shouldUseMain ? mainSymbols : fallbackSymbols;
33320
+ dist_default = figures;
33321
+ replacements = Object.entries(specialMainSymbols);
33322
+ });
33323
+
33324
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/theme.js
33325
+ import { styleText } from "node:util";
33326
+ var defaultTheme;
33327
+ var init_theme = __esm(() => {
33328
+ init_dist();
33329
+ defaultTheme = {
33330
+ prefix: {
33331
+ idle: styleText("blue", "?"),
33332
+ done: styleText("green", dist_default.tick)
33333
+ },
33334
+ spinner: {
33335
+ interval: 80,
33336
+ frames: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"].map((frame) => styleText("yellow", frame))
33337
+ },
33338
+ style: {
33339
+ answer: (text) => styleText("cyan", text),
33340
+ message: (text) => styleText("bold", text),
33341
+ error: (text) => styleText("red", `> ${text}`),
33342
+ defaultAnswer: (text) => styleText("dim", `(${text})`),
33343
+ help: (text) => styleText("dim", text),
33344
+ highlight: (text) => styleText("cyan", text),
33345
+ key: (text) => styleText("cyan", styleText("bold", `<${text}>`))
33346
+ }
33347
+ };
33348
+ });
33349
+
33350
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/make-theme.js
33351
+ function isPlainObject3(value) {
33352
+ if (typeof value !== "object" || value === null)
33353
+ return false;
33354
+ let proto = value;
33355
+ while (Object.getPrototypeOf(proto) !== null) {
33356
+ proto = Object.getPrototypeOf(proto);
33357
+ }
33358
+ return Object.getPrototypeOf(value) === proto;
33359
+ }
33360
+ function deepMerge(...objects) {
33361
+ const output = {};
33362
+ for (const obj of objects) {
33363
+ for (const [key, value] of Object.entries(obj)) {
33364
+ const prevValue = output[key];
33365
+ output[key] = isPlainObject3(prevValue) && isPlainObject3(value) ? deepMerge(prevValue, value) : value;
33366
+ }
33367
+ }
33368
+ return output;
33369
+ }
33370
+ function makeTheme(...themes) {
33371
+ const themesToMerge = [
33372
+ defaultTheme,
33373
+ ...themes.filter((theme) => theme != null)
33374
+ ];
33375
+ return deepMerge(...themesToMerge);
33376
+ }
33377
+ var init_make_theme = __esm(() => {
33378
+ init_theme();
33379
+ });
33380
+
33381
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/use-prefix.js
33382
+ function usePrefix({ status = "idle", theme }) {
33383
+ const [showLoader, setShowLoader] = useState(false);
33384
+ const [tick, setTick] = useState(0);
33385
+ const { prefix, spinner } = makeTheme(theme);
33386
+ useEffect(() => {
33387
+ if (status === "loading") {
33388
+ let tickInterval;
33389
+ let inc = -1;
33390
+ const delayTimeout = setTimeout(() => {
33391
+ setShowLoader(true);
33392
+ tickInterval = setInterval(() => {
33393
+ inc = inc + 1;
33394
+ setTick(inc % spinner.frames.length);
33395
+ }, spinner.interval);
33396
+ }, 300);
33397
+ return () => {
33398
+ clearTimeout(delayTimeout);
33399
+ clearInterval(tickInterval);
33400
+ };
33401
+ } else {
33402
+ setShowLoader(false);
33403
+ }
33404
+ }, [status]);
33405
+ if (showLoader) {
33406
+ return spinner.frames[tick];
33407
+ }
33408
+ const iconName = status === "loading" ? "idle" : status;
33409
+ return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
33410
+ }
33411
+ var init_use_prefix = __esm(() => {
33412
+ init_use_state();
33413
+ init_use_effect();
33414
+ init_make_theme();
33415
+ });
33416
+
33417
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/use-memo.js
33418
+ function useMemo(fn, dependencies) {
33419
+ return withPointer((pointer) => {
33420
+ const prev = pointer.get();
33421
+ if (!prev || prev.dependencies.length !== dependencies.length || prev.dependencies.some((dep, i2) => dep !== dependencies[i2])) {
33422
+ const value = fn();
33423
+ pointer.set({ value, dependencies });
33424
+ return value;
33425
+ }
33426
+ return prev.value;
33427
+ });
33428
+ }
33429
+ var init_use_memo = __esm(() => {
33430
+ init_hook_engine();
33431
+ });
33432
+
33433
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/use-ref.js
33434
+ function useRef(val) {
33435
+ return useState({ current: val })[0];
33436
+ }
33437
+ var init_use_ref = __esm(() => {
33438
+ init_use_state();
33439
+ });
33440
+
33441
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/use-keypress.js
33442
+ function useKeypress(userHandler) {
33443
+ const signal = useRef(userHandler);
33444
+ signal.current = userHandler;
33445
+ useEffect((rl) => {
33446
+ let ignore = false;
33447
+ const handler = withUpdates((_input, event) => {
33448
+ if (ignore)
33449
+ return;
33450
+ signal.current(event, rl);
33451
+ });
33452
+ rl.input.on("keypress", handler);
33453
+ return () => {
33454
+ ignore = true;
33455
+ rl.input.removeListener("keypress", handler);
33456
+ };
33457
+ }, []);
33458
+ }
33459
+ var init_use_keypress = __esm(() => {
33460
+ init_use_ref();
33461
+ init_use_effect();
33462
+ init_hook_engine();
33463
+ });
33464
+
33465
+ // ../../node_modules/cli-width/index.js
33466
+ var require_cli_width = __commonJS((exports, module) => {
33467
+ module.exports = cliWidth;
33468
+ function normalizeOpts(options) {
33469
+ const defaultOpts = {
33470
+ defaultWidth: 0,
33471
+ output: process.stdout,
33472
+ tty: __require("tty")
33473
+ };
33474
+ if (!options) {
33475
+ return defaultOpts;
33476
+ }
33477
+ Object.keys(defaultOpts).forEach(function(key) {
33478
+ if (!options[key]) {
33479
+ options[key] = defaultOpts[key];
33480
+ }
33481
+ });
33482
+ return options;
33483
+ }
33484
+ function cliWidth(options) {
33485
+ const opts = normalizeOpts(options);
33486
+ if (opts.output.getWindowSize) {
33487
+ return opts.output.getWindowSize()[0] || opts.defaultWidth;
33488
+ }
33489
+ if (opts.tty.getWindowSize) {
33490
+ return opts.tty.getWindowSize()[1] || opts.defaultWidth;
33491
+ }
33492
+ if (opts.output.columns) {
33493
+ return opts.output.columns;
33494
+ }
33495
+ if (process.env.CLI_WIDTH) {
33496
+ const width = parseInt(process.env.CLI_WIDTH, 10);
33497
+ if (!isNaN(width) && width !== 0) {
33498
+ return width;
33499
+ }
33500
+ }
33501
+ return opts.defaultWidth;
33502
+ }
33503
+ });
33504
+
33505
+ // ../../node_modules/fast-string-truncated-width/dist/utils.js
33506
+ var getCodePointsLength, isFullWidth = (x) => {
33507
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
33508
+ }, isWideNotCJKTNotEmoji = (x) => {
33509
+ return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
33510
+ };
33511
+ var init_utils = __esm(() => {
33512
+ getCodePointsLength = (() => {
33513
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
33514
+ return (input) => {
33515
+ let surrogatePairsNr = 0;
33516
+ SURROGATE_PAIR_RE.lastIndex = 0;
33517
+ while (SURROGATE_PAIR_RE.test(input)) {
33518
+ surrogatePairsNr += 1;
33519
+ }
33520
+ return input.length - surrogatePairsNr;
33521
+ };
33522
+ })();
33523
+ });
33524
+
33525
+ // ../../node_modules/fast-string-truncated-width/dist/index.js
33526
+ var ANSI_RE, CONTROL_RE, CJKT_WIDE_RE, TAB_RE, EMOJI_RE, LATIN_RE, MODIFIER_RE, NO_TRUNCATION, getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
33527
+ const LIMIT = truncationOptions.limit ?? Infinity;
33528
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
33529
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
33530
+ const ANSI_WIDTH = 0;
33531
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
33532
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
33533
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
33534
+ const FULL_WIDTH_WIDTH = 2;
33535
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
33536
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
33537
+ const PARSE_BLOCKS = [
33538
+ [LATIN_RE, REGULAR_WIDTH],
33539
+ [ANSI_RE, ANSI_WIDTH],
33540
+ [CONTROL_RE, CONTROL_WIDTH],
33541
+ [TAB_RE, TAB_WIDTH],
33542
+ [EMOJI_RE, EMOJI_WIDTH],
33543
+ [CJKT_WIDE_RE, WIDE_WIDTH]
33544
+ ];
33545
+ let indexPrev = 0;
33546
+ let index = 0;
33547
+ let length = input.length;
33548
+ let lengthExtra = 0;
33549
+ let truncationEnabled = false;
33550
+ let truncationIndex = length;
33551
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
33552
+ let unmatchedStart = 0;
33553
+ let unmatchedEnd = 0;
33554
+ let width = 0;
33555
+ let widthExtra = 0;
33556
+ outer:
32852
33557
  while (true) {
32853
- const answer = await ask(rl, prompt);
32854
- if (answer.toLowerCase() === "all" || answer === "") {
32855
- return [...ALL_AGENTS];
33558
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
33559
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
33560
+ lengthExtra = 0;
33561
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
33562
+ const codePoint = char.codePointAt(0) || 0;
33563
+ if (isFullWidth(codePoint)) {
33564
+ widthExtra = FULL_WIDTH_WIDTH;
33565
+ } else if (isWideNotCJKTNotEmoji(codePoint)) {
33566
+ widthExtra = WIDE_WIDTH;
33567
+ } else {
33568
+ widthExtra = REGULAR_WIDTH;
33569
+ }
33570
+ if (width + widthExtra > truncationLimit) {
33571
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
33572
+ }
33573
+ if (width + widthExtra > LIMIT) {
33574
+ truncationEnabled = true;
33575
+ break outer;
33576
+ }
33577
+ lengthExtra += char.length;
33578
+ width += widthExtra;
33579
+ }
33580
+ unmatchedStart = unmatchedEnd = 0;
33581
+ }
33582
+ if (index >= length) {
33583
+ break outer;
33584
+ }
33585
+ for (let i2 = 0, l = PARSE_BLOCKS.length;i2 < l; i2++) {
33586
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
33587
+ BLOCK_RE.lastIndex = index;
33588
+ if (BLOCK_RE.test(input)) {
33589
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
33590
+ widthExtra = lengthExtra * BLOCK_WIDTH;
33591
+ if (width + widthExtra > truncationLimit) {
33592
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
33593
+ }
33594
+ if (width + widthExtra > LIMIT) {
33595
+ truncationEnabled = true;
33596
+ break outer;
33597
+ }
33598
+ width += widthExtra;
33599
+ unmatchedStart = indexPrev;
33600
+ unmatchedEnd = index;
33601
+ index = indexPrev = BLOCK_RE.lastIndex;
33602
+ continue outer;
33603
+ }
33604
+ }
33605
+ index += 1;
33606
+ }
33607
+ return {
33608
+ width: truncationEnabled ? truncationLimit : width,
33609
+ index: truncationEnabled ? truncationIndex : length,
33610
+ truncated: truncationEnabled,
33611
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
33612
+ };
33613
+ }, dist_default2;
33614
+ var init_dist2 = __esm(() => {
33615
+ init_utils();
33616
+ ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
33617
+ CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
33618
+ CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
33619
+ TAB_RE = /\t{1,1000}/y;
33620
+ EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
33621
+ LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
33622
+ MODIFIER_RE = /\p{M}+/gu;
33623
+ NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
33624
+ dist_default2 = getStringTruncatedWidth;
33625
+ });
33626
+
33627
+ // ../../node_modules/fast-string-width/dist/index.js
33628
+ var NO_TRUNCATION2, fastStringWidth = (input, options = {}) => {
33629
+ return dist_default2(input, NO_TRUNCATION2, options).width;
33630
+ }, dist_default3;
33631
+ var init_dist3 = __esm(() => {
33632
+ init_dist2();
33633
+ NO_TRUNCATION2 = {
33634
+ limit: Infinity,
33635
+ ellipsis: "",
33636
+ ellipsisWidth: 0
33637
+ };
33638
+ dist_default3 = fastStringWidth;
33639
+ });
33640
+
33641
+ // ../../node_modules/fast-wrap-ansi/lib/main.js
33642
+ function wrapAnsi(string5, columns, options) {
33643
+ return String(string5).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
33644
+ `);
33645
+ }
33646
+ var ESC = "\x1B", CSI = "›", END_CODE = 39, ANSI_ESCAPE_BELL = "\x07", ANSI_CSI = "[", ANSI_OSC = "]", ANSI_SGR_TERMINATOR = "m", ANSI_ESCAPE_LINK, GROUP_REGEX, getClosingCode = (openingCode) => {
33647
+ if (openingCode >= 30 && openingCode <= 37)
33648
+ return 39;
33649
+ if (openingCode >= 90 && openingCode <= 97)
33650
+ return 39;
33651
+ if (openingCode >= 40 && openingCode <= 47)
33652
+ return 49;
33653
+ if (openingCode >= 100 && openingCode <= 107)
33654
+ return 49;
33655
+ if (openingCode === 1 || openingCode === 2)
33656
+ return 22;
33657
+ if (openingCode === 3)
33658
+ return 23;
33659
+ if (openingCode === 4)
33660
+ return 24;
33661
+ if (openingCode === 7)
33662
+ return 27;
33663
+ if (openingCode === 8)
33664
+ return 28;
33665
+ if (openingCode === 9)
33666
+ return 29;
33667
+ if (openingCode === 0)
33668
+ return 0;
33669
+ return;
33670
+ }, wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`, wrapAnsiHyperlink = (url2) => `${ESC}${ANSI_ESCAPE_LINK}${url2}${ANSI_ESCAPE_BELL}`, wrapWord = (rows, word, columns) => {
33671
+ const characters = word[Symbol.iterator]();
33672
+ let isInsideEscape = false;
33673
+ let isInsideLinkEscape = false;
33674
+ let lastRow = rows.at(-1);
33675
+ let visible = lastRow === undefined ? 0 : dist_default3(lastRow);
33676
+ let currentCharacter = characters.next();
33677
+ let nextCharacter = characters.next();
33678
+ let rawCharacterIndex = 0;
33679
+ while (!currentCharacter.done) {
33680
+ const character = currentCharacter.value;
33681
+ const characterLength = dist_default3(character);
33682
+ if (visible + characterLength <= columns) {
33683
+ rows[rows.length - 1] += character;
33684
+ } else {
33685
+ rows.push(character);
33686
+ visible = 0;
33687
+ }
33688
+ if (character === ESC || character === CSI) {
33689
+ isInsideEscape = true;
33690
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
33691
+ }
33692
+ if (isInsideEscape) {
33693
+ if (isInsideLinkEscape) {
33694
+ if (character === ANSI_ESCAPE_BELL) {
33695
+ isInsideEscape = false;
33696
+ isInsideLinkEscape = false;
33697
+ }
33698
+ } else if (character === ANSI_SGR_TERMINATOR) {
33699
+ isInsideEscape = false;
33700
+ }
33701
+ } else {
33702
+ visible += characterLength;
33703
+ if (visible === columns && !nextCharacter.done) {
33704
+ rows.push("");
33705
+ visible = 0;
32856
33706
  }
32857
- const indices = answer.split(",").map((s) => Number.parseInt(s.trim(), 10) - 1).filter((i2) => i2 >= 0 && i2 < ALL_AGENTS.length);
32858
- if (indices.length > 0) {
32859
- return [...new Set(indices.map((i2) => ALL_AGENTS[i2]))];
33707
+ }
33708
+ currentCharacter = nextCharacter;
33709
+ nextCharacter = characters.next();
33710
+ rawCharacterIndex += character.length;
33711
+ }
33712
+ lastRow = rows.at(-1);
33713
+ if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
33714
+ rows[rows.length - 2] += rows.pop();
33715
+ }
33716
+ }, stringVisibleTrimSpacesRight = (string5) => {
33717
+ const words = string5.split(" ");
33718
+ let last = words.length;
33719
+ while (last) {
33720
+ if (dist_default3(words[last - 1])) {
33721
+ break;
33722
+ }
33723
+ last--;
33724
+ }
33725
+ if (last === words.length) {
33726
+ return string5;
33727
+ }
33728
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
33729
+ }, exec = (string5, columns, options = {}) => {
33730
+ if (options.trim !== false && string5.trim() === "") {
33731
+ return "";
33732
+ }
33733
+ let returnValue = "";
33734
+ let escapeCode;
33735
+ let escapeUrl;
33736
+ const words = string5.split(" ");
33737
+ let rows = [""];
33738
+ let rowLength = 0;
33739
+ for (let index = 0;index < words.length; index++) {
33740
+ const word = words[index];
33741
+ if (options.trim !== false) {
33742
+ const row = rows.at(-1) ?? "";
33743
+ const trimmed = row.trimStart();
33744
+ if (row.length !== trimmed.length) {
33745
+ rows[rows.length - 1] = trimmed;
33746
+ rowLength = dist_default3(trimmed);
33747
+ }
33748
+ }
33749
+ if (index !== 0) {
33750
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
33751
+ rows.push("");
33752
+ rowLength = 0;
33753
+ }
33754
+ if (rowLength || options.trim === false) {
33755
+ rows[rows.length - 1] += " ";
33756
+ rowLength++;
33757
+ }
33758
+ }
33759
+ const wordLength = dist_default3(word);
33760
+ if (options.hard && wordLength > columns) {
33761
+ const remainingColumns = columns - rowLength;
33762
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
33763
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
33764
+ if (breaksStartingNextLine < breaksStartingThisLine) {
33765
+ rows.push("");
33766
+ }
33767
+ wrapWord(rows, word, columns);
33768
+ rowLength = dist_default3(rows.at(-1) ?? "");
33769
+ continue;
33770
+ }
33771
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
33772
+ if (options.wordWrap === false && rowLength < columns) {
33773
+ wrapWord(rows, word, columns);
33774
+ rowLength = dist_default3(rows.at(-1) ?? "");
33775
+ continue;
32860
33776
  }
32861
- rl.write(`Invalid input. Enter numbers (1-5), comma-separated, or 'all'.
33777
+ rows.push("");
33778
+ rowLength = 0;
33779
+ }
33780
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
33781
+ wrapWord(rows, word, columns);
33782
+ rowLength = dist_default3(rows.at(-1) ?? "");
33783
+ continue;
33784
+ }
33785
+ rows[rows.length - 1] += word;
33786
+ rowLength += wordLength;
33787
+ }
33788
+ if (options.trim !== false) {
33789
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
33790
+ }
33791
+ const preString = rows.join(`
32862
33792
  `);
33793
+ let inSurrogate = false;
33794
+ for (let i2 = 0;i2 < preString.length; i2++) {
33795
+ const character = preString[i2];
33796
+ returnValue += character;
33797
+ if (!inSurrogate) {
33798
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
33799
+ if (inSurrogate) {
33800
+ continue;
33801
+ }
33802
+ } else {
33803
+ inSurrogate = false;
33804
+ }
33805
+ if (character === ESC || character === CSI) {
33806
+ GROUP_REGEX.lastIndex = i2 + 1;
33807
+ const groupsResult = GROUP_REGEX.exec(preString);
33808
+ const groups = groupsResult?.groups;
33809
+ if (groups?.code !== undefined) {
33810
+ const code = Number.parseFloat(groups.code);
33811
+ escapeCode = code === END_CODE ? undefined : code;
33812
+ } else if (groups?.uri !== undefined) {
33813
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
33814
+ }
33815
+ }
33816
+ if (preString[i2 + 1] === `
33817
+ `) {
33818
+ if (escapeUrl) {
33819
+ returnValue += wrapAnsiHyperlink("");
33820
+ }
33821
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
33822
+ if (escapeCode && closingCode) {
33823
+ returnValue += wrapAnsiCode(closingCode);
33824
+ }
33825
+ } else if (character === `
33826
+ `) {
33827
+ if (escapeCode && getClosingCode(escapeCode)) {
33828
+ returnValue += wrapAnsiCode(escapeCode);
33829
+ }
33830
+ if (escapeUrl) {
33831
+ returnValue += wrapAnsiHyperlink(escapeUrl);
33832
+ }
32863
33833
  }
32864
- } finally {
32865
- rl.close();
32866
33834
  }
33835
+ return returnValue;
33836
+ }, CRLF_OR_LF;
33837
+ var init_main = __esm(() => {
33838
+ init_dist3();
33839
+ ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
33840
+ GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
33841
+ CRLF_OR_LF = /\r?\n/;
33842
+ });
33843
+
33844
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/utils.js
33845
+ function breakLines(content, width) {
33846
+ return content.split(`
33847
+ `).flatMap((line) => wrapAnsi(line, width, { trim: false, hard: true }).split(`
33848
+ `).map((str2) => str2.trimEnd())).join(`
33849
+ `);
33850
+ }
33851
+ function readlineWidth() {
33852
+ return import_cli_width.default({ defaultWidth: 80, output: readline().output });
32867
33853
  }
32868
- async function promptSkillSelection(availableSkills, operation = "manage") {
32869
- const rl = createInterface({
32870
- input: process.stdin,
32871
- output: process.stderr
33854
+ var import_cli_width;
33855
+ var init_utils2 = __esm(() => {
33856
+ init_main();
33857
+ init_hook_engine();
33858
+ import_cli_width = __toESM(require_cli_width(), 1);
33859
+ });
33860
+
33861
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
33862
+ function usePointerPosition({ active, renderedItems, pageSize, loop }) {
33863
+ const state = useRef({
33864
+ lastPointer: active,
33865
+ lastActive: undefined
33866
+ });
33867
+ const { lastPointer, lastActive } = state.current;
33868
+ const middle = Math.floor(pageSize / 2);
33869
+ const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
33870
+ const defaultPointerPosition = renderedItems.slice(0, active).reduce((acc, item) => acc + item.length, 0);
33871
+ let pointer = defaultPointerPosition;
33872
+ if (renderedLength > pageSize) {
33873
+ if (loop) {
33874
+ pointer = lastPointer;
33875
+ if (lastActive != null && lastActive < active && active - lastActive < pageSize) {
33876
+ pointer = Math.min(middle, Math.abs(active - lastActive) === 1 ? Math.min(lastPointer + (renderedItems[lastActive]?.length ?? 0), Math.max(defaultPointerPosition, lastPointer)) : lastPointer + active - lastActive);
33877
+ }
33878
+ } else {
33879
+ const spaceUnderActive = renderedItems.slice(active).reduce((acc, item) => acc + item.length, 0);
33880
+ pointer = spaceUnderActive < pageSize - middle ? pageSize - spaceUnderActive : Math.min(defaultPointerPosition, middle);
33881
+ }
33882
+ }
33883
+ state.current.lastPointer = pointer;
33884
+ state.current.lastActive = active;
33885
+ return pointer;
33886
+ }
33887
+ function usePagination({ items, active, renderItem, pageSize, loop = true }) {
33888
+ const width = readlineWidth();
33889
+ const bound = (num) => (num % items.length + items.length) % items.length;
33890
+ const renderedItems = items.map((item, index) => {
33891
+ if (item == null)
33892
+ return [];
33893
+ return breakLines(renderItem({ item, index, isActive: index === active }), width).split(`
33894
+ `);
32872
33895
  });
32873
- const prompt = `
32874
- Select skills to ${operation}:
32875
- ` + availableSkills.map((s, i2) => ` ${i2 + 1}. ${s}`).join(`
32876
- `) + `
33896
+ const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
33897
+ const renderItemAtIndex = (index) => renderedItems[index] ?? [];
33898
+ const pointer = usePointerPosition({ active, renderedItems, pageSize, loop });
33899
+ const activeItem = renderItemAtIndex(active).slice(0, pageSize);
33900
+ const activeItemPosition = pointer + activeItem.length <= pageSize ? pointer : pageSize - activeItem.length;
33901
+ const pageBuffer = Array.from({ length: pageSize });
33902
+ pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem);
33903
+ const itemVisited = new Set([active]);
33904
+ let bufferPointer = activeItemPosition + activeItem.length;
33905
+ let itemPointer = bound(active + 1);
33906
+ while (bufferPointer < pageSize && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer > active)) {
33907
+ const lines = renderItemAtIndex(itemPointer);
33908
+ const linesToAdd = lines.slice(0, pageSize - bufferPointer);
33909
+ pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd);
33910
+ itemVisited.add(itemPointer);
33911
+ bufferPointer += linesToAdd.length;
33912
+ itemPointer = bound(itemPointer + 1);
33913
+ }
33914
+ bufferPointer = activeItemPosition - 1;
33915
+ itemPointer = bound(active - 1);
33916
+ while (bufferPointer >= 0 && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer < active)) {
33917
+ const lines = renderItemAtIndex(itemPointer);
33918
+ const linesToAdd = lines.slice(Math.max(0, lines.length - bufferPointer - 1));
33919
+ pageBuffer.splice(bufferPointer - linesToAdd.length + 1, linesToAdd.length, ...linesToAdd);
33920
+ itemVisited.add(itemPointer);
33921
+ bufferPointer -= linesToAdd.length;
33922
+ itemPointer = bound(itemPointer - 1);
33923
+ }
33924
+ return pageBuffer.filter((line) => typeof line === "string").join(`
33925
+ `);
33926
+ }
33927
+ var init_use_pagination = __esm(() => {
33928
+ init_use_ref();
33929
+ init_utils2();
33930
+ });
32877
33931
 
32878
- Enter numbers separated by commas (e.g., 1,2,3) or 'all': `;
32879
- try {
32880
- while (true) {
32881
- const answer = await ask(rl, prompt);
32882
- if (answer.toLowerCase() === "all" || answer === "") {
32883
- return [...availableSkills];
33932
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/node_modules/mute-stream/lib/index.js
33933
+ var require_lib = __commonJS((exports, module) => {
33934
+ var Stream = __require("stream");
33935
+
33936
+ class MuteStream extends Stream {
33937
+ #isTTY = null;
33938
+ constructor(opts = {}) {
33939
+ super(opts);
33940
+ this.writable = this.readable = true;
33941
+ this.muted = false;
33942
+ this.on("pipe", this._onpipe);
33943
+ this.replace = opts.replace;
33944
+ this._prompt = opts.prompt || null;
33945
+ this._hadControl = false;
33946
+ }
33947
+ #destSrc(key, def) {
33948
+ if (this._dest) {
33949
+ return this._dest[key];
32884
33950
  }
32885
- const indices = answer.split(",").map((s) => Number.parseInt(s.trim(), 10) - 1).filter((i2) => i2 >= 0 && i2 < availableSkills.length);
32886
- if (indices.length > 0) {
32887
- return [...new Set(indices.map((i2) => availableSkills[i2]))];
33951
+ if (this._src) {
33952
+ return this._src[key];
32888
33953
  }
32889
- rl.write(`Invalid input. Enter numbers (1-${availableSkills.length}), comma-separated, or 'all'.
32890
- `);
33954
+ return def;
33955
+ }
33956
+ #proxy(method, ...args) {
33957
+ if (typeof this._dest?.[method] === "function") {
33958
+ this._dest[method](...args);
33959
+ }
33960
+ if (typeof this._src?.[method] === "function") {
33961
+ this._src[method](...args);
33962
+ }
33963
+ }
33964
+ get isTTY() {
33965
+ if (this.#isTTY !== null) {
33966
+ return this.#isTTY;
33967
+ }
33968
+ return this.#destSrc("isTTY", false);
33969
+ }
33970
+ set isTTY(val) {
33971
+ this.#isTTY = val;
33972
+ }
33973
+ get rows() {
33974
+ return this.#destSrc("rows");
33975
+ }
33976
+ get columns() {
33977
+ return this.#destSrc("columns");
33978
+ }
33979
+ mute() {
33980
+ this.muted = true;
33981
+ }
33982
+ unmute() {
33983
+ this.muted = false;
33984
+ }
33985
+ _onpipe(src) {
33986
+ this._src = src;
33987
+ }
33988
+ pipe(dest, options) {
33989
+ this._dest = dest;
33990
+ return super.pipe(dest, options);
33991
+ }
33992
+ pause() {
33993
+ if (this._src) {
33994
+ return this._src.pause();
33995
+ }
33996
+ }
33997
+ resume() {
33998
+ if (this._src) {
33999
+ return this._src.resume();
34000
+ }
34001
+ }
34002
+ write(c) {
34003
+ if (this.muted) {
34004
+ if (!this.replace) {
34005
+ return true;
34006
+ }
34007
+ if (c.match(/^\u001b/)) {
34008
+ if (c.indexOf(this._prompt) === 0) {
34009
+ c = c.slice(this._prompt.length);
34010
+ c = c.replace(/./g, this.replace);
34011
+ c = this._prompt + c;
34012
+ }
34013
+ this._hadControl = true;
34014
+ return this.emit("data", c);
34015
+ } else {
34016
+ if (this._prompt && this._hadControl && c.indexOf(this._prompt) === 0) {
34017
+ this._hadControl = false;
34018
+ this.emit("data", this._prompt);
34019
+ c = c.slice(this._prompt.length);
34020
+ }
34021
+ c = c.toString().replace(/./g, this.replace);
34022
+ }
34023
+ }
34024
+ this.emit("data", c);
34025
+ }
34026
+ end(c) {
34027
+ if (this.muted) {
34028
+ if (c && this.replace) {
34029
+ c = c.toString().replace(/./g, this.replace);
34030
+ } else {
34031
+ c = null;
34032
+ }
34033
+ }
34034
+ if (c) {
34035
+ this.emit("data", c);
34036
+ }
34037
+ this.emit("end");
34038
+ }
34039
+ destroy(...args) {
34040
+ return this.#proxy("destroy", ...args);
34041
+ }
34042
+ destroySoon(...args) {
34043
+ return this.#proxy("destroySoon", ...args);
34044
+ }
34045
+ close(...args) {
34046
+ return this.#proxy("close", ...args);
34047
+ }
34048
+ }
34049
+ module.exports = MuteStream;
34050
+ });
34051
+
34052
+ // ../../node_modules/signal-exit/dist/mjs/signals.js
34053
+ var signals;
34054
+ var init_signals = __esm(() => {
34055
+ signals = [];
34056
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
34057
+ if (process.platform !== "win32") {
34058
+ signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
34059
+ }
34060
+ if (process.platform === "linux") {
34061
+ signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
34062
+ }
34063
+ });
34064
+
34065
+ // ../../node_modules/signal-exit/dist/mjs/index.js
34066
+ class Emitter {
34067
+ emitted = {
34068
+ afterExit: false,
34069
+ exit: false
34070
+ };
34071
+ listeners = {
34072
+ afterExit: [],
34073
+ exit: []
34074
+ };
34075
+ count = 0;
34076
+ id = Math.random();
34077
+ constructor() {
34078
+ if (global[kExitEmitter]) {
34079
+ return global[kExitEmitter];
34080
+ }
34081
+ ObjectDefineProperty(global, kExitEmitter, {
34082
+ value: this,
34083
+ writable: false,
34084
+ enumerable: false,
34085
+ configurable: false
34086
+ });
34087
+ }
34088
+ on(ev, fn) {
34089
+ this.listeners[ev].push(fn);
34090
+ }
34091
+ removeListener(ev, fn) {
34092
+ const list = this.listeners[ev];
34093
+ const i2 = list.indexOf(fn);
34094
+ if (i2 === -1) {
34095
+ return;
34096
+ }
34097
+ if (i2 === 0 && list.length === 1) {
34098
+ list.length = 0;
34099
+ } else {
34100
+ list.splice(i2, 1);
34101
+ }
34102
+ }
34103
+ emit(ev, code, signal) {
34104
+ if (this.emitted[ev]) {
34105
+ return false;
34106
+ }
34107
+ this.emitted[ev] = true;
34108
+ let ret = false;
34109
+ for (const fn of this.listeners[ev]) {
34110
+ ret = fn(code, signal) === true || ret;
34111
+ }
34112
+ if (ev === "exit") {
34113
+ ret = this.emit("afterExit", code, signal) || ret;
34114
+ }
34115
+ return ret;
34116
+ }
34117
+ }
34118
+
34119
+ class SignalExitBase {
34120
+ }
34121
+ var processOk = (process5) => !!process5 && typeof process5 === "object" && typeof process5.removeListener === "function" && typeof process5.emit === "function" && typeof process5.reallyExit === "function" && typeof process5.listeners === "function" && typeof process5.kill === "function" && typeof process5.pid === "number" && typeof process5.on === "function", kExitEmitter, global, ObjectDefineProperty, signalExitWrap = (handler) => {
34122
+ return {
34123
+ onExit(cb, opts) {
34124
+ return handler.onExit(cb, opts);
34125
+ },
34126
+ load() {
34127
+ return handler.load();
34128
+ },
34129
+ unload() {
34130
+ return handler.unload();
34131
+ }
34132
+ };
34133
+ }, SignalExitFallback, SignalExit, process5, onExit, load2, unload;
34134
+ var init_mjs = __esm(() => {
34135
+ init_signals();
34136
+ kExitEmitter = Symbol.for("signal-exit emitter");
34137
+ global = globalThis;
34138
+ ObjectDefineProperty = Object.defineProperty.bind(Object);
34139
+ SignalExitFallback = class SignalExitFallback extends SignalExitBase {
34140
+ onExit() {
34141
+ return () => {};
34142
+ }
34143
+ load() {}
34144
+ unload() {}
34145
+ };
34146
+ SignalExit = class SignalExit extends SignalExitBase {
34147
+ #hupSig = process5.platform === "win32" ? "SIGINT" : "SIGHUP";
34148
+ #emitter = new Emitter;
34149
+ #process;
34150
+ #originalProcessEmit;
34151
+ #originalProcessReallyExit;
34152
+ #sigListeners = {};
34153
+ #loaded = false;
34154
+ constructor(process5) {
34155
+ super();
34156
+ this.#process = process5;
34157
+ this.#sigListeners = {};
34158
+ for (const sig of signals) {
34159
+ this.#sigListeners[sig] = () => {
34160
+ const listeners = this.#process.listeners(sig);
34161
+ let { count } = this.#emitter;
34162
+ const p = process5;
34163
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
34164
+ count += p.__signal_exit_emitter__.count;
34165
+ }
34166
+ if (listeners.length === count) {
34167
+ this.unload();
34168
+ const ret = this.#emitter.emit("exit", null, sig);
34169
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
34170
+ if (!ret)
34171
+ process5.kill(process5.pid, s);
34172
+ }
34173
+ };
34174
+ }
34175
+ this.#originalProcessReallyExit = process5.reallyExit;
34176
+ this.#originalProcessEmit = process5.emit;
34177
+ }
34178
+ onExit(cb, opts) {
34179
+ if (!processOk(this.#process)) {
34180
+ return () => {};
34181
+ }
34182
+ if (this.#loaded === false) {
34183
+ this.load();
34184
+ }
34185
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
34186
+ this.#emitter.on(ev, cb);
34187
+ return () => {
34188
+ this.#emitter.removeListener(ev, cb);
34189
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
34190
+ this.unload();
34191
+ }
34192
+ };
34193
+ }
34194
+ load() {
34195
+ if (this.#loaded) {
34196
+ return;
34197
+ }
34198
+ this.#loaded = true;
34199
+ this.#emitter.count += 1;
34200
+ for (const sig of signals) {
34201
+ try {
34202
+ const fn = this.#sigListeners[sig];
34203
+ if (fn)
34204
+ this.#process.on(sig, fn);
34205
+ } catch (_) {}
34206
+ }
34207
+ this.#process.emit = (ev, ...a) => {
34208
+ return this.#processEmit(ev, ...a);
34209
+ };
34210
+ this.#process.reallyExit = (code) => {
34211
+ return this.#processReallyExit(code);
34212
+ };
34213
+ }
34214
+ unload() {
34215
+ if (!this.#loaded) {
34216
+ return;
34217
+ }
34218
+ this.#loaded = false;
34219
+ signals.forEach((sig) => {
34220
+ const listener = this.#sigListeners[sig];
34221
+ if (!listener) {
34222
+ throw new Error("Listener not defined for signal: " + sig);
34223
+ }
34224
+ try {
34225
+ this.#process.removeListener(sig, listener);
34226
+ } catch (_) {}
34227
+ });
34228
+ this.#process.emit = this.#originalProcessEmit;
34229
+ this.#process.reallyExit = this.#originalProcessReallyExit;
34230
+ this.#emitter.count -= 1;
34231
+ }
34232
+ #processReallyExit(code) {
34233
+ if (!processOk(this.#process)) {
34234
+ return 0;
34235
+ }
34236
+ this.#process.exitCode = code || 0;
34237
+ this.#emitter.emit("exit", this.#process.exitCode, null);
34238
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
34239
+ }
34240
+ #processEmit(ev, ...args) {
34241
+ const og = this.#originalProcessEmit;
34242
+ if (ev === "exit" && processOk(this.#process)) {
34243
+ if (typeof args[0] === "number") {
34244
+ this.#process.exitCode = args[0];
34245
+ }
34246
+ const ret = og.call(this.#process, ev, ...args);
34247
+ this.#emitter.emit("exit", this.#process.exitCode, null);
34248
+ return ret;
34249
+ } else {
34250
+ return og.call(this.#process, ev, ...args);
34251
+ }
34252
+ }
34253
+ };
34254
+ process5 = globalThis.process;
34255
+ ({
34256
+ onExit,
34257
+ load: load2,
34258
+ unload
34259
+ } = signalExitWrap(processOk(process5) ? new SignalExit(process5) : new SignalExitFallback));
34260
+ });
34261
+
34262
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/ansi/dist/index.js
34263
+ var ESC2 = "\x1B[", cursorLeft, cursorHide, cursorShow, cursorUp = (rows = 1) => rows > 0 ? `${ESC2}${rows}A` : "", cursorDown = (rows = 1) => rows > 0 ? `${ESC2}${rows}B` : "", cursorTo = (x, y) => {
34264
+ if (typeof y === "number" && !Number.isNaN(y)) {
34265
+ return `${ESC2}${y + 1};${x + 1}H`;
34266
+ }
34267
+ return `${ESC2}${x + 1}G`;
34268
+ }, eraseLine, eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
34269
+ var init_dist4 = __esm(() => {
34270
+ cursorLeft = ESC2 + "G";
34271
+ cursorHide = ESC2 + "?25l";
34272
+ cursorShow = ESC2 + "?25h";
34273
+ eraseLine = ESC2 + "2K";
34274
+ });
34275
+
34276
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/screen-manager.js
34277
+ import { stripVTControlCharacters } from "node:util";
34278
+
34279
+ class ScreenManager {
34280
+ height = 0;
34281
+ extraLinesUnderPrompt = 0;
34282
+ cursorPos;
34283
+ rl;
34284
+ constructor(rl) {
34285
+ this.rl = rl;
34286
+ this.cursorPos = rl.getCursorPos();
34287
+ }
34288
+ write(content) {
34289
+ this.rl.output.unmute();
34290
+ this.rl.output.write(content);
34291
+ this.rl.output.mute();
34292
+ }
34293
+ render(content, bottomContent = "") {
34294
+ const promptLine = lastLine(content);
34295
+ const rawPromptLine = stripVTControlCharacters(promptLine);
34296
+ let prompt = rawPromptLine;
34297
+ if (this.rl.line.length > 0) {
34298
+ prompt = prompt.slice(0, -this.rl.line.length);
34299
+ }
34300
+ this.rl.setPrompt(prompt);
34301
+ this.cursorPos = this.rl.getCursorPos();
34302
+ const width = readlineWidth();
34303
+ content = breakLines(content, width);
34304
+ bottomContent = breakLines(bottomContent, width);
34305
+ if (rawPromptLine.length % width === 0) {
34306
+ content += `
34307
+ `;
34308
+ }
34309
+ let output = content + (bottomContent ? `
34310
+ ` + bottomContent : "");
34311
+ const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
34312
+ const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
34313
+ if (bottomContentHeight > 0)
34314
+ output += cursorUp(bottomContentHeight);
34315
+ output += cursorTo(this.cursorPos.cols);
34316
+ this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
34317
+ this.extraLinesUnderPrompt = bottomContentHeight;
34318
+ this.height = height(output);
34319
+ }
34320
+ checkCursorPos() {
34321
+ const cursorPos = this.rl.getCursorPos();
34322
+ if (cursorPos.cols !== this.cursorPos.cols) {
34323
+ this.write(cursorTo(cursorPos.cols));
34324
+ this.cursorPos = cursorPos;
34325
+ }
34326
+ }
34327
+ done({ clearContent }) {
34328
+ this.rl.setPrompt("");
34329
+ let output = cursorDown(this.extraLinesUnderPrompt);
34330
+ output += clearContent ? eraseLines(this.height) : `
34331
+ `;
34332
+ output += cursorShow;
34333
+ this.write(output);
34334
+ this.rl.close();
34335
+ }
34336
+ }
34337
+ var height = (content) => content.split(`
34338
+ `).length, lastLine = (content) => content.split(`
34339
+ `).pop() ?? "";
34340
+ var init_screen_manager = __esm(() => {
34341
+ init_utils2();
34342
+ init_dist4();
34343
+ });
34344
+
34345
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
34346
+ var PromisePolyfill;
34347
+ var init_promise_polyfill = __esm(() => {
34348
+ PromisePolyfill = class PromisePolyfill extends Promise {
34349
+ static withResolver() {
34350
+ let resolve;
34351
+ let reject;
34352
+ const promise3 = new Promise((res, rej) => {
34353
+ resolve = res;
34354
+ reject = rej;
34355
+ });
34356
+ return { promise: promise3, resolve, reject };
34357
+ }
34358
+ };
34359
+ });
34360
+
34361
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/create-prompt.js
34362
+ import * as readline2 from "node:readline";
34363
+ import { AsyncResource as AsyncResource3 } from "node:async_hooks";
34364
+ function getCallSites() {
34365
+ const _prepareStackTrace = Error.prepareStackTrace;
34366
+ let result = [];
34367
+ try {
34368
+ Error.prepareStackTrace = (_, callSites) => {
34369
+ const callSitesWithoutCurrent = callSites.slice(1);
34370
+ result = callSitesWithoutCurrent;
34371
+ return callSitesWithoutCurrent;
34372
+ };
34373
+ new Error().stack;
34374
+ } catch {
34375
+ return result;
34376
+ }
34377
+ Error.prepareStackTrace = _prepareStackTrace;
34378
+ return result;
34379
+ }
34380
+ function createPrompt(view) {
34381
+ const callSites = getCallSites();
34382
+ const prompt = (config2, context = {}) => {
34383
+ const { input = process.stdin, signal } = context;
34384
+ const cleanups = new Set;
34385
+ const output = new import_mute_stream.default;
34386
+ output.pipe(context.output ?? process.stdout);
34387
+ output.mute();
34388
+ const rl = readline2.createInterface({
34389
+ terminal: true,
34390
+ input,
34391
+ output
34392
+ });
34393
+ const screen = new ScreenManager(rl);
34394
+ const { promise: promise3, resolve, reject } = PromisePolyfill.withResolver();
34395
+ const cancel = () => reject(new CancelPromptError);
34396
+ if (signal) {
34397
+ const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
34398
+ if (signal.aborted) {
34399
+ abort();
34400
+ return Object.assign(promise3, { cancel });
34401
+ }
34402
+ signal.addEventListener("abort", abort);
34403
+ cleanups.add(() => signal.removeEventListener("abort", abort));
34404
+ }
34405
+ cleanups.add(onExit((code, signal2) => {
34406
+ reject(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
34407
+ }));
34408
+ const sigint = () => reject(new ExitPromptError(`User force closed the prompt with SIGINT`));
34409
+ rl.on("SIGINT", sigint);
34410
+ cleanups.add(() => rl.removeListener("SIGINT", sigint));
34411
+ return withHooks(rl, (cycle) => {
34412
+ const hooksCleanup = AsyncResource3.bind(() => effectScheduler.clearAll());
34413
+ rl.on("close", hooksCleanup);
34414
+ cleanups.add(() => rl.removeListener("close", hooksCleanup));
34415
+ const startCycle = () => {
34416
+ const checkCursorPos = () => screen.checkCursorPos();
34417
+ rl.input.on("keypress", checkCursorPos);
34418
+ cleanups.add(() => rl.input.removeListener("keypress", checkCursorPos));
34419
+ cycle(() => {
34420
+ try {
34421
+ const nextView = view(config2, (value) => {
34422
+ setImmediate(() => resolve(value));
34423
+ });
34424
+ if (nextView === undefined) {
34425
+ const callerFilename = callSites[1]?.getFileName();
34426
+ throw new Error(`Prompt functions must return a string.
34427
+ at ${callerFilename}`);
34428
+ }
34429
+ const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
34430
+ screen.render(content, bottomContent);
34431
+ effectScheduler.run();
34432
+ } catch (error48) {
34433
+ reject(error48);
34434
+ }
34435
+ });
34436
+ };
34437
+ if ("readableFlowing" in input) {
34438
+ nativeSetImmediate(startCycle);
34439
+ } else {
34440
+ startCycle();
34441
+ }
34442
+ return Object.assign(promise3.then((answer) => {
34443
+ effectScheduler.clearAll();
34444
+ return answer;
34445
+ }, (error48) => {
34446
+ effectScheduler.clearAll();
34447
+ throw error48;
34448
+ }).finally(() => {
34449
+ cleanups.forEach((cleanup) => cleanup());
34450
+ screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
34451
+ output.end();
34452
+ }).then(() => promise3), { cancel });
34453
+ });
34454
+ };
34455
+ return prompt;
34456
+ }
34457
+ var import_mute_stream, nativeSetImmediate;
34458
+ var init_create_prompt = __esm(() => {
34459
+ init_mjs();
34460
+ init_screen_manager();
34461
+ init_promise_polyfill();
34462
+ init_hook_engine();
34463
+ init_errors4();
34464
+ import_mute_stream = __toESM(require_lib(), 1);
34465
+ nativeSetImmediate = globalThis.setImmediate;
34466
+ });
34467
+
34468
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/lib/Separator.js
34469
+ import { styleText as styleText2 } from "node:util";
34470
+
34471
+ class Separator {
34472
+ separator = styleText2("dim", Array.from({ length: 15 }).join(dist_default.line));
34473
+ type = "separator";
34474
+ constructor(separator) {
34475
+ if (separator) {
34476
+ this.separator = separator;
32891
34477
  }
32892
- } finally {
32893
- rl.close();
34478
+ }
34479
+ static isSeparator(choice) {
34480
+ return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
32894
34481
  }
32895
34482
  }
32896
- var ALL_AGENTS, AGENT_DISPLAY_NAMES;
34483
+ var init_Separator = __esm(() => {
34484
+ init_dist();
34485
+ });
34486
+
34487
+ // ../../node_modules/@inquirer/checkbox/node_modules/@inquirer/core/dist/index.js
34488
+ var init_dist5 = __esm(() => {
34489
+ init_use_prefix();
34490
+ init_use_state();
34491
+ init_use_memo();
34492
+ init_use_keypress();
34493
+ init_make_theme();
34494
+ init_use_pagination();
34495
+ init_create_prompt();
34496
+ init_Separator();
34497
+ init_errors4();
34498
+ });
34499
+
34500
+ // ../../node_modules/@inquirer/checkbox/dist/index.js
34501
+ import { styleText as styleText3 } from "node:util";
34502
+ function isSelectable(item) {
34503
+ return !Separator.isSeparator(item) && !item.disabled;
34504
+ }
34505
+ function isNavigable(item) {
34506
+ return !Separator.isSeparator(item);
34507
+ }
34508
+ function isChecked(item) {
34509
+ return !Separator.isSeparator(item) && item.checked;
34510
+ }
34511
+ function toggle(item) {
34512
+ return isSelectable(item) ? { ...item, checked: !item.checked } : item;
34513
+ }
34514
+ function check2(checked) {
34515
+ return function(item) {
34516
+ return isSelectable(item) ? { ...item, checked } : item;
34517
+ };
34518
+ }
34519
+ function normalizeChoices(choices) {
34520
+ return choices.map((choice) => {
34521
+ if (Separator.isSeparator(choice))
34522
+ return choice;
34523
+ if (typeof choice === "string") {
34524
+ return {
34525
+ value: choice,
34526
+ name: choice,
34527
+ short: choice,
34528
+ checkedName: choice,
34529
+ disabled: false,
34530
+ checked: false
34531
+ };
34532
+ }
34533
+ const name = choice.name ?? String(choice.value);
34534
+ const normalizedChoice = {
34535
+ value: choice.value,
34536
+ name,
34537
+ short: choice.short ?? name,
34538
+ checkedName: choice.checkedName ?? name,
34539
+ disabled: choice.disabled ?? false,
34540
+ checked: choice.checked ?? false
34541
+ };
34542
+ if (choice.description) {
34543
+ normalizedChoice.description = choice.description;
34544
+ }
34545
+ return normalizedChoice;
34546
+ });
34547
+ }
34548
+ var checkboxTheme, dist_default4;
34549
+ var init_dist6 = __esm(() => {
34550
+ init_dist5();
34551
+ init_dist4();
34552
+ init_dist();
34553
+ checkboxTheme = {
34554
+ icon: {
34555
+ checked: styleText3("green", dist_default.circleFilled),
34556
+ unchecked: dist_default.circle,
34557
+ cursor: dist_default.pointer,
34558
+ disabledChecked: styleText3("green", dist_default.circleDouble),
34559
+ disabledUnchecked: "-"
34560
+ },
34561
+ style: {
34562
+ disabled: (text) => styleText3("dim", text),
34563
+ renderSelectedChoices: (selectedChoices) => selectedChoices.map((choice) => choice.short).join(", "),
34564
+ description: (text) => styleText3("cyan", text),
34565
+ keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText3("bold", key)} ${styleText3("dim", action)}`).join(styleText3("dim", " • "))
34566
+ },
34567
+ i18n: { disabledError: "This option is disabled and cannot be toggled." },
34568
+ keybindings: []
34569
+ };
34570
+ dist_default4 = createPrompt((config2, done) => {
34571
+ const { pageSize = 7, loop = true, required: required2, validate = () => true } = config2;
34572
+ const shortcuts = { all: "a", invert: "i", ...config2.shortcuts };
34573
+ const theme = makeTheme(checkboxTheme, config2.theme);
34574
+ const { keybindings } = theme;
34575
+ const [status, setStatus] = useState("idle");
34576
+ const prefix = usePrefix({ status, theme });
34577
+ const [items, setItems] = useState(normalizeChoices(config2.choices));
34578
+ const bounds = useMemo(() => {
34579
+ const first = items.findIndex(isNavigable);
34580
+ const last = items.findLastIndex(isNavigable);
34581
+ if (first === -1) {
34582
+ throw new ValidationError("[checkbox prompt] No selectable choices. All choices are disabled.");
34583
+ }
34584
+ return { first, last };
34585
+ }, [items]);
34586
+ const [active, setActive] = useState(bounds.first);
34587
+ const [errorMsg, setError] = useState();
34588
+ useKeypress(async (key) => {
34589
+ if (isEnterKey(key)) {
34590
+ const selection = items.filter(isChecked);
34591
+ const isValid2 = await validate([...selection]);
34592
+ if (required2 && !selection.length) {
34593
+ setError("At least one choice must be selected");
34594
+ } else if (isValid2 === true) {
34595
+ setStatus("done");
34596
+ done(selection.map((choice) => choice.value));
34597
+ } else {
34598
+ setError(isValid2 || "You must select a valid value");
34599
+ }
34600
+ } else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
34601
+ if (errorMsg) {
34602
+ setError(undefined);
34603
+ }
34604
+ if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
34605
+ const offset = isUpKey(key, keybindings) ? -1 : 1;
34606
+ let next = active;
34607
+ do {
34608
+ next = (next + offset + items.length) % items.length;
34609
+ } while (!isNavigable(items[next]));
34610
+ setActive(next);
34611
+ }
34612
+ } else if (isSpaceKey(key)) {
34613
+ const activeItem = items[active];
34614
+ if (activeItem && !Separator.isSeparator(activeItem)) {
34615
+ if (activeItem.disabled) {
34616
+ setError(theme.i18n.disabledError);
34617
+ } else {
34618
+ setError(undefined);
34619
+ setItems(items.map((choice, i2) => i2 === active ? toggle(choice) : choice));
34620
+ }
34621
+ }
34622
+ } else if (key.name === shortcuts.all) {
34623
+ const selectAll = items.some((choice) => isSelectable(choice) && !choice.checked);
34624
+ setItems(items.map(check2(selectAll)));
34625
+ } else if (key.name === shortcuts.invert) {
34626
+ setItems(items.map(toggle));
34627
+ } else if (isNumberKey(key)) {
34628
+ const selectedIndex = Number(key.name) - 1;
34629
+ let selectableIndex = -1;
34630
+ const position = items.findIndex((item) => {
34631
+ if (Separator.isSeparator(item))
34632
+ return false;
34633
+ selectableIndex++;
34634
+ return selectableIndex === selectedIndex;
34635
+ });
34636
+ const selectedItem = items[position];
34637
+ if (selectedItem && isSelectable(selectedItem)) {
34638
+ setActive(position);
34639
+ setItems(items.map((choice, i2) => i2 === position ? toggle(choice) : choice));
34640
+ }
34641
+ }
34642
+ });
34643
+ const message = theme.style.message(config2.message, status);
34644
+ let description;
34645
+ const page = usePagination({
34646
+ items,
34647
+ active,
34648
+ renderItem({ item, isActive }) {
34649
+ if (Separator.isSeparator(item)) {
34650
+ return ` ${item.separator}`;
34651
+ }
34652
+ const cursor = isActive ? theme.icon.cursor : " ";
34653
+ if (item.disabled) {
34654
+ const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
34655
+ const checkbox2 = item.checked ? theme.icon.disabledChecked : theme.icon.disabledUnchecked;
34656
+ return theme.style.disabled(`${cursor}${checkbox2} ${item.name} ${disabledLabel}`);
34657
+ }
34658
+ if (isActive) {
34659
+ description = item.description;
34660
+ }
34661
+ const checkbox = item.checked ? theme.icon.checked : theme.icon.unchecked;
34662
+ const name = item.checked ? item.checkedName : item.name;
34663
+ const color = isActive ? theme.style.highlight : (x) => x;
34664
+ return color(`${cursor}${checkbox} ${name}`);
34665
+ },
34666
+ pageSize,
34667
+ loop
34668
+ });
34669
+ if (status === "done") {
34670
+ const selection = items.filter(isChecked);
34671
+ const answer = theme.style.answer(theme.style.renderSelectedChoices(selection, items));
34672
+ return [prefix, message, answer].filter(Boolean).join(" ");
34673
+ }
34674
+ const keys = [
34675
+ ["↑↓", "navigate"],
34676
+ ["space", "select"]
34677
+ ];
34678
+ if (shortcuts.all)
34679
+ keys.push([shortcuts.all, "all"]);
34680
+ if (shortcuts.invert)
34681
+ keys.push([shortcuts.invert, "invert"]);
34682
+ keys.push(["⏎", "submit"]);
34683
+ const helpLine = theme.style.keysHelpTip(keys);
34684
+ const lines = [
34685
+ [prefix, message].filter(Boolean).join(" "),
34686
+ page,
34687
+ " ",
34688
+ description ? theme.style.description(description) : "",
34689
+ errorMsg ? theme.style.error(errorMsg) : "",
34690
+ helpLine
34691
+ ].filter(Boolean).join(`
34692
+ `).trimEnd();
34693
+ return `${lines}${cursorHide}`;
34694
+ });
34695
+ });
34696
+
34697
+ // ../../node_modules/@inquirer/prompts/dist/index.js
34698
+ var init_dist7 = __esm(() => {
34699
+ init_dist6();
34700
+ });
34701
+
34702
+ // src/commands/skills/prompt.ts
34703
+ function truncate(text, maxLen) {
34704
+ if (text.length <= maxLen)
34705
+ return text;
34706
+ return `${text.slice(0, maxLen - 3)}...`;
34707
+ }
34708
+ async function promptAgentSelection(operation = "manage") {
34709
+ const selected = await dist_default4({
34710
+ message: `Select agents to ${operation} skills for`,
34711
+ required: true,
34712
+ choices: ALL_AGENTS.map((a) => ({
34713
+ name: AGENT_DISPLAY_NAMES[a],
34714
+ value: a,
34715
+ description: AGENT_DESTINATIONS[a]
34716
+ }))
34717
+ });
34718
+ return selected;
34719
+ }
34720
+ async function promptSkillSelection(skills, operation = "manage") {
34721
+ const selected = await dist_default4({
34722
+ message: `Select skills to ${operation}`,
34723
+ required: true,
34724
+ choices: skills.map((s) => ({
34725
+ name: s.name,
34726
+ value: s.name,
34727
+ description: s.description ? truncate(s.description, 120) : undefined
34728
+ }))
34729
+ });
34730
+ return selected;
34731
+ }
34732
+ var ALL_AGENTS, AGENT_DISPLAY_NAMES, AGENT_DESTINATIONS;
32897
34733
  var init_prompt = __esm(() => {
34734
+ init_dist7();
32898
34735
  ALL_AGENTS = [
32899
34736
  "claude",
32900
34737
  "cursor",
@@ -32909,14 +34746,28 @@ var init_prompt = __esm(() => {
32909
34746
  gemini: "Gemini CLI",
32910
34747
  codex: "Codex"
32911
34748
  };
34749
+ AGENT_DESTINATIONS = {
34750
+ claude: ".claude/skills/<skill>/",
34751
+ cursor: ".cursor/rules/<skill>.mdc",
34752
+ copilot: ".github/instructions/<skill>.instructions.md",
34753
+ gemini: ".gemini/GEMINI.md",
34754
+ codex: "~/.codex/instructions.md"
34755
+ };
32912
34756
  });
32913
34757
 
32914
34758
  // src/commands/skills/skillsService.ts
32915
- import { catchError as catchError4, OutputFormatter as OutputFormatter3 } from "@uipath/common";
32916
- import { getFileSystem as getFileSystem7 } from "@uipath/filesystem";
34759
+ import { catchError as catchError5, logger as logger7, OutputFormatter as OutputFormatter3 } from "@uipath/common";
34760
+ import { getFileSystem as getFileSystem9 } from "@uipath/filesystem";
34761
+ function handlePromptCancellation(err, operation) {
34762
+ if (err instanceof Error && err.name === "ExitPromptError") {
34763
+ logger7.warn(`${operation.charAt(0).toUpperCase() + operation.slice(1)} cancelled.`);
34764
+ throw Object.assign(new Error("cancelled"), { exitCode: 130 });
34765
+ }
34766
+ throw err;
34767
+ }
32917
34768
  async function resolveSkillsContext(options, operation) {
32918
34769
  const isLocal = !!options.local;
32919
- const fs = getFileSystem7();
34770
+ const fs = getFileSystem9();
32920
34771
  const rootDir = isLocal ? fs.env.cwd() : fs.env.homedir();
32921
34772
  const storePath = await getContentStore(rootDir);
32922
34773
  const availableSkills = await getAvailableSkills(storePath);
@@ -32931,8 +34782,9 @@ async function resolveSkillsContext(options, operation) {
32931
34782
  }
32932
34783
  let selectedSkills = availableSkills;
32933
34784
  if (!options.skills && !options.agents) {
32934
- const availableNames = availableSkills.map((s) => s.name);
32935
- const chosen = await promptSkillSelection(availableNames, operation);
34785
+ const [skillErr, chosen] = await catchError5(promptSkillSelection(availableSkills, operation));
34786
+ if (skillErr)
34787
+ handlePromptCancellation(skillErr, operation);
32936
34788
  selectedSkills = availableSkills.filter((s) => chosen.includes(s.name));
32937
34789
  } else if (options.skills) {
32938
34790
  const requested = options.skills.split(",").map((s) => s.trim());
@@ -32973,7 +34825,10 @@ async function resolveSkillsContext(options, operation) {
32973
34825
  return null;
32974
34826
  }
32975
34827
  } else {
32976
- agents = await promptAgentSelection(operation);
34828
+ const [agentErr, selected] = await catchError5(promptAgentSelection(operation));
34829
+ if (agentErr)
34830
+ handlePromptCancellation(agentErr, operation);
34831
+ agents = selected;
32977
34832
  }
32978
34833
  return { rootDir, storePath, selectedSkills, agents, isLocal };
32979
34834
  }
@@ -32983,7 +34838,7 @@ async function runAgentInstalls(resolved) {
32983
34838
  for (const agent of agents) {
32984
34839
  const handler = getAgentHandler(agent);
32985
34840
  for (const skill of selectedSkills) {
32986
- const [installError] = await catchError4(handler.install(skill, rootDir));
34841
+ const [installError] = await catchError5(handler.install(skill, rootDir));
32987
34842
  if (installError) {
32988
34843
  OutputFormatter3.error({
32989
34844
  Result: "Failure",
@@ -32996,7 +34851,7 @@ async function runAgentInstalls(resolved) {
32996
34851
  installed.push(`${agent}:${skill.name}`);
32997
34852
  }
32998
34853
  }
32999
- const [manifestError] = await catchError4(updateManifestAfterInstall(storePath, selectedSkills.map((s) => s.name), agents));
34854
+ const [manifestError] = await catchError5(updateManifestAfterInstall(storePath, selectedSkills.map((s) => s.name), agents));
33000
34855
  if (manifestError) {
33001
34856
  OutputFormatter3.error({
33002
34857
  Result: "Failure",
@@ -33007,7 +34862,7 @@ async function runAgentInstalls(resolved) {
33007
34862
  return null;
33008
34863
  }
33009
34864
  if (isLocal) {
33010
- const [gitignoreError] = await catchError4(addToGitignore(rootDir, `${STORE_NAME}/`));
34865
+ const [gitignoreError] = await catchError5(addToGitignore(rootDir, `${STORE_NAME}/`));
33011
34866
  if (gitignoreError) {
33012
34867
  OutputFormatter3.error({
33013
34868
  Result: "Failure",
@@ -33027,12 +34882,16 @@ var init_skillsService = __esm(() => {
33027
34882
  });
33028
34883
 
33029
34884
  // src/commands/skills/install.ts
33030
- import { catchError as catchError5, OutputFormatter as OutputFormatter4, processContext as processContext2 } from "@uipath/common";
34885
+ import { catchError as catchError6, OutputFormatter as OutputFormatter4, processContext as processContext2 } from "@uipath/common";
33031
34886
  function registerInstallCommand(skillsCommand) {
33032
34887
  skillsCommand.command("install").description("Download skills from UiPath and install them for your coding agents.").option("--agents <agents>", "Target agents: claude, cursor, copilot, gemini, codex (comma-separated)").option("--skills <skills>", "Specific skills to install (comma-separated)").option("--local", "Install to current project instead of globally").trackedAction(processContext2, async (options) => {
33033
- const [contextError, resolved] = await catchError5(resolveSkillsContext(options, "install"));
34888
+ const [contextError, resolved] = await catchError6(resolveSkillsContext(options, "install"));
33034
34889
  if (contextError || !resolved) {
33035
34890
  if (contextError) {
34891
+ if (contextError.exitCode === 130) {
34892
+ processContext2.exit(130);
34893
+ return;
34894
+ }
33036
34895
  OutputFormatter4.error({
33037
34896
  Result: "Failure",
33038
34897
  Message: `Failed to install skills: ${contextError.message}`,
@@ -33063,21 +34922,25 @@ var init_install = __esm(() => {
33063
34922
 
33064
34923
  // src/commands/skills/uninstall.ts
33065
34924
  import {
33066
- catchError as catchError6,
33067
- logger as logger7,
34925
+ catchError as catchError7,
34926
+ logger as logger8,
33068
34927
  OutputFormatter as OutputFormatter5,
33069
34928
  processContext as processContext3
33070
34929
  } from "@uipath/common";
33071
- import { getFileSystem as getFileSystem8 } from "@uipath/filesystem";
34930
+ import { getFileSystem as getFileSystem10 } from "@uipath/filesystem";
33072
34931
  function registerUninstallCommand(skillsCommand) {
33073
34932
  skillsCommand.command("uninstall").description("Remove previously installed skills from agent configurations.").option("--agents <agents>", "Target agents: claude, cursor, copilot, gemini, codex (comma-separated)").option("--skills <skills>", "Specific skills to uninstall (comma-separated)").option("--local", "Uninstall from current project instead of globally").trackedAction(processContext3, async (options) => {
33074
- const [contextError, resolved] = await catchError6(resolveSkillsContext(options, "uninstall"));
34933
+ const [contextError, resolved] = await catchError7(resolveSkillsContext(options, "uninstall"));
33075
34934
  const isLocal = !!options.local;
33076
34935
  let rootDir;
33077
34936
  let storePath;
33078
34937
  let skillNames;
33079
34938
  let agents;
33080
34939
  if (contextError) {
34940
+ if (contextError.exitCode === 130) {
34941
+ processContext3.exit(130);
34942
+ return;
34943
+ }
33081
34944
  OutputFormatter5.error({
33082
34945
  Result: "Failure",
33083
34946
  Message: `Failed to uninstall skills: ${contextError.message}`,
@@ -33095,7 +34958,7 @@ function registerUninstallCommand(skillsCommand) {
33095
34958
  if (!options.skills || !options.agents) {
33096
34959
  return;
33097
34960
  }
33098
- const fs = getFileSystem8();
34961
+ const fs = getFileSystem10();
33099
34962
  rootDir = isLocal ? fs.env.cwd() : fs.env.homedir();
33100
34963
  storePath = fs.path.join(rootDir, STORE_NAME);
33101
34964
  const manifest = await readManifest(storePath);
@@ -33122,13 +34985,13 @@ function registerUninstallCommand(skillsCommand) {
33122
34985
  processContext3.exit(1);
33123
34986
  return;
33124
34987
  }
33125
- logger7.info(`Uninstalling skills from manifest: ${inManifest.join(", ")}`);
34988
+ logger8.info(`Uninstalling skills from manifest: ${inManifest.join(", ")}`);
33126
34989
  }
33127
34990
  const uninstalled = [];
33128
34991
  for (const agent of agents) {
33129
34992
  const handler = getAgentHandler(agent);
33130
34993
  for (const name of skillNames) {
33131
- const [uninstallError] = await catchError6(handler.uninstall(name, rootDir));
34994
+ const [uninstallError] = await catchError7(handler.uninstall(name, rootDir));
33132
34995
  if (uninstallError) {
33133
34996
  OutputFormatter5.error({
33134
34997
  Result: "Failure",
@@ -33163,16 +35026,20 @@ var init_uninstall = __esm(() => {
33163
35026
 
33164
35027
  // src/commands/skills/update.ts
33165
35028
  import {
33166
- catchError as catchError7,
33167
- logger as logger8,
35029
+ catchError as catchError8,
35030
+ logger as logger9,
33168
35031
  OutputFormatter as OutputFormatter6,
33169
35032
  processContext as processContext4
33170
35033
  } from "@uipath/common";
33171
35034
  function registerUpdateCommand(skillsCommand) {
33172
35035
  skillsCommand.command("update").description("Re-fetch skills from UiPath and reinstall to get the latest versions.").option("--agents <agents>", "Target agents: claude, cursor, copilot, gemini, codex (comma-separated)").option("--skills <skills>", "Specific skills to update (comma-separated)").option("--local", "Update in current project instead of globally").trackedAction(processContext4, async (options) => {
33173
- const [contextError, resolved] = await catchError7(resolveSkillsContext(options, "update"));
35036
+ const [contextError, resolved] = await catchError8(resolveSkillsContext(options, "update"));
33174
35037
  if (contextError || !resolved) {
33175
35038
  if (contextError) {
35039
+ if (contextError.exitCode === 130) {
35040
+ processContext4.exit(130);
35041
+ return;
35042
+ }
33176
35043
  OutputFormatter6.error({
33177
35044
  Result: "Failure",
33178
35045
  Message: `Failed to update skills: ${contextError.message}`,
@@ -33183,13 +35050,13 @@ function registerUpdateCommand(skillsCommand) {
33183
35050
  return;
33184
35051
  }
33185
35052
  if (!options.skills) {
33186
- const [manifestErr, manifest] = await catchError7(readManifest(resolved.storePath));
33187
- const [skillsErr, availableSkills] = await catchError7(getAvailableSkills(resolved.storePath));
35053
+ const [manifestErr, manifest] = await catchError8(readManifest(resolved.storePath));
35054
+ const [skillsErr, availableSkills] = await catchError8(getAvailableSkills(resolved.storePath));
33188
35055
  if (!manifestErr && !skillsErr && availableSkills) {
33189
35056
  const availableNames = availableSkills.map((s) => s.name);
33190
35057
  const removed = Object.keys(manifest.skills).filter((s) => !availableNames.includes(s));
33191
35058
  if (removed.length > 0) {
33192
- logger8.warn(`Previously installed skills no longer available: ${removed.join(", ")}. They may have been removed or renamed. Use 'uipath skills uninstall --skills ${removed.join(",")}' to clean up.`);
35059
+ logger9.warn(`Previously installed skills no longer available: ${removed.join(", ")}. They may have been removed or renamed. Use 'uipath skills uninstall --skills ${removed.join(",")}' to clean up.`);
33193
35060
  }
33194
35061
  }
33195
35062
  }
@@ -33246,15 +35113,15 @@ var exports_npmrc = {};
33246
35113
  __export(exports_npmrc, {
33247
35114
  findNpmrcConfig: () => findNpmrcConfig
33248
35115
  });
33249
- import { logger as logger9 } from "@uipath/common";
33250
- import { getFileSystem as getFileSystem9 } from "@uipath/filesystem";
35116
+ import { catchError as catchError9, logger as logger10 } from "@uipath/common";
35117
+ import { getFileSystem as getFileSystem11 } from "@uipath/filesystem";
33251
35118
  function expandEnvVars(raw) {
33252
35119
  let hasMissing = false;
33253
35120
  const expanded = raw.replace(/\$\{([^}]+)\}/g, (_, v) => {
33254
35121
  const val = process.env[v];
33255
35122
  if (val === undefined) {
33256
35123
  hasMissing = true;
33257
- logger9.warn(`Warning: .npmrc references \${${v}} but it is not set.`);
35124
+ logger10.warn(`Warning: .npmrc references \${${v}} but it is not set.`);
33258
35125
  return "";
33259
35126
  }
33260
35127
  return val;
@@ -33287,14 +35154,13 @@ function parseNpmrc(content) {
33287
35154
  return result;
33288
35155
  }
33289
35156
  function registryHost(url2) {
33290
- try {
33291
- return new URL(url2).host;
33292
- } catch {
35157
+ const [error48, parsed] = catchError9(() => new URL(url2));
35158
+ if (error48)
33293
35159
  return;
33294
- }
35160
+ return parsed.host;
33295
35161
  }
33296
35162
  async function findNpmrcConfig() {
33297
- const fs = getFileSystem9();
35163
+ const fs = getFileSystem11();
33298
35164
  const paths = [];
33299
35165
  let dir = fs.env.cwd();
33300
35166
  for (let i2 = 0;i2 < 20; i2++) {
@@ -33305,22 +35171,31 @@ async function findNpmrcConfig() {
33305
35171
  dir = parent;
33306
35172
  }
33307
35173
  paths.push(fs.path.join(fs.env.homedir(), ".npmrc"));
35174
+ logger10.debug(`Searching for .npmrc in ${paths.length} locations`);
33308
35175
  let scopedRegistry;
33309
35176
  let prefix;
33310
35177
  const allTokensByHost = new Map;
33311
35178
  for (const p of paths) {
33312
- try {
33313
- const content = await fs.readFile(p, "utf-8");
33314
- const parsed = parseNpmrc(content);
33315
- if (parsed.scopedRegistry && !scopedRegistry)
33316
- scopedRegistry = parsed.scopedRegistry;
33317
- if (parsed.prefix && !prefix)
33318
- prefix = parsed.prefix;
33319
- for (const [host, token] of parsed.tokensByHost) {
33320
- if (!allTokensByHost.has(host))
33321
- allTokensByHost.set(host, token);
35179
+ const [readError, content] = await catchError9(fs.readFile(p, "utf-8"));
35180
+ if (readError) {
35181
+ continue;
35182
+ }
35183
+ logger10.debug(`Found .npmrc at ${p}`);
35184
+ if (!content)
35185
+ continue;
35186
+ const parsed = parseNpmrc(content);
35187
+ if (parsed.scopedRegistry && !scopedRegistry) {
35188
+ scopedRegistry = parsed.scopedRegistry;
35189
+ logger10.debug(`@uipath:registry = ${scopedRegistry} (from ${p})`);
35190
+ }
35191
+ if (parsed.prefix && !prefix)
35192
+ prefix = parsed.prefix;
35193
+ for (const [host, token] of parsed.tokensByHost) {
35194
+ if (!allTokensByHost.has(host)) {
35195
+ allTokensByHost.set(host, token);
35196
+ logger10.debug(`Auth token found for host '${host}' (from ${p})`);
33322
35197
  }
33323
- } catch {}
35198
+ }
33324
35199
  }
33325
35200
  let authToken;
33326
35201
  if (scopedRegistry) {
@@ -33334,8 +35209,13 @@ async function findNpmrcConfig() {
33334
35209
  var init_npmrc = () => {};
33335
35210
 
33336
35211
  // src/services/toolService.ts
33337
- import { DEFAULT_FETCH_TIMEOUT_MS, logger as logger10 } from "@uipath/common";
33338
- import { getFileSystem as getFileSystem10 } from "@uipath/filesystem";
35212
+ import {
35213
+ catchError as catchError10,
35214
+ DEFAULT_FETCH_TIMEOUT_MS,
35215
+ extractErrorMessageSync,
35216
+ logger as logger11
35217
+ } from "@uipath/common";
35218
+ import { getFileSystem as getFileSystem12 } from "@uipath/filesystem";
33339
35219
  function isValidSemver(v) {
33340
35220
  return SEMVER_RE.test(v);
33341
35221
  }
@@ -33400,9 +35280,19 @@ function validateVersionString(version2) {
33400
35280
  function resolveToolPackageName(arg) {
33401
35281
  return WHITELIST_BY_COMMAND.get(arg) ?? WHITELIST_BY_SHORT_NAME.get(arg) ?? arg;
33402
35282
  }
35283
+ function parsePackageSpec(spec) {
35284
+ const versionSeparator = spec.startsWith("@") ? spec.indexOf("@", 1) : spec.indexOf("@");
35285
+ if (versionSeparator === -1) {
35286
+ return { name: spec, version: undefined };
35287
+ }
35288
+ return {
35289
+ name: spec.slice(0, versionSeparator),
35290
+ version: spec.slice(versionSeparator + 1) || undefined
35291
+ };
35292
+ }
33403
35293
  async function isDevMode() {
33404
- try {
33405
- const fs = getFileSystem10();
35294
+ const [error48, result] = await catchError10((async () => {
35295
+ const fs = getFileSystem12();
33406
35296
  let dir = fs.env.cwd();
33407
35297
  for (let i2 = 0;i2 < 10; i2++) {
33408
35298
  const pkgPath = fs.path.join(dir, "package.json");
@@ -33410,8 +35300,12 @@ async function isDevMode() {
33410
35300
  const raw = await fs.readFile(pkgPath, "utf-8");
33411
35301
  if (raw) {
33412
35302
  const pkg = JSON.parse(raw);
33413
- if (pkg.workspaces && pkg.private && pkg.name === "uipcli") {
33414
- return true;
35303
+ if (pkg.workspaces && pkg.private) {
35304
+ const bunLockPath = fs.path.join(dir, "bun.lock");
35305
+ if (await fs.exists(bunLockPath)) {
35306
+ logger11.debug(`Dev mode detected — found monorepo root at ${dir}`);
35307
+ return true;
35308
+ }
33415
35309
  }
33416
35310
  }
33417
35311
  }
@@ -33420,7 +35314,15 @@ async function isDevMode() {
33420
35314
  break;
33421
35315
  dir = parent;
33422
35316
  }
33423
- } catch {}
35317
+ return false;
35318
+ })());
35319
+ if (error48) {
35320
+ logger11.debug("Dev mode not detected — using npm");
35321
+ return false;
35322
+ }
35323
+ if (result)
35324
+ return true;
35325
+ logger11.debug("Dev mode not detected — using npm");
33424
35326
  return false;
33425
35327
  }
33426
35328
  async function runPackageManager(args, cwd) {
@@ -33433,6 +35335,7 @@ async function runPackageManager(args, cwd) {
33433
35335
  const isWindows = process.platform === "win32";
33434
35336
  const useBun = await isDevMode();
33435
35337
  const pm = useBun ? "bun" : "npm";
35338
+ logger11.debug(`Running package manager: ${pm} ${args.join(" ")}${cwd ? ` (cwd: ${cwd})` : ""}`);
33436
35339
  const pmArgs = useBun ? args.filter((a) => a !== "-g").map((a) => a === "uninstall" ? "remove" : a) : args;
33437
35340
  return new Promise((resolve, reject) => {
33438
35341
  const proc = isWindows ? spawn2([pm, ...pmArgs].map((a) => a.includes(" ") ? `"${a}"` : a).join(" "), [], {
@@ -33446,7 +35349,7 @@ async function runPackageManager(args, cwd) {
33446
35349
  let stderr = "";
33447
35350
  const MAX_STDERR = 65536;
33448
35351
  proc.stdout?.on("data", (d) => {
33449
- logger10.info(d.toString().trimEnd());
35352
+ logger11.info(d.toString().trimEnd());
33450
35353
  });
33451
35354
  proc.stderr?.on("data", (d) => {
33452
35355
  if (stderr.length < MAX_STDERR) {
@@ -33468,18 +35371,20 @@ async function runPackageManager(args, cwd) {
33468
35371
  });
33469
35372
  }
33470
35373
  async function resolveRegistry() {
35374
+ logger11.debug("Resolving npm registry for @uipath packages...");
33471
35375
  const { findNpmrcConfig: findNpmrcConfig2 } = await Promise.resolve().then(() => (init_npmrc(), exports_npmrc));
33472
35376
  const config2 = await findNpmrcConfig2();
33473
35377
  const registryUrl = config2.scopedRegistry || DEFAULT_REGISTRY;
33474
- try {
33475
- new URL(registryUrl);
33476
- } catch {
35378
+ logger11.debug(`Registry URL: ${registryUrl}${config2.scopedRegistry ? " (from .npmrc)" : " (default)"}`);
35379
+ const [urlError] = catchError10(() => new URL(registryUrl));
35380
+ if (urlError) {
33477
35381
  throw new Error(`Invalid @uipath:registry URL in .npmrc: "${registryUrl}"`);
33478
35382
  }
33479
35383
  const envToken = globalThis.process?.env?.GH_NPM_REGISTRY_TOKEN;
33480
35384
  const authToken = envToken || config2.authToken || undefined;
35385
+ logger11.debug(`Auth token: ${authToken ? `found (source: ${envToken ? "GH_NPM_REGISTRY_TOKEN env" : ".npmrc"})` : "not found"}`);
33481
35386
  if (authToken && !config2.scopedRegistry) {
33482
- logger10.warn("Auth token found but no @uipath:registry configured in .npmrc — " + "token will be sent to the default registry (npmjs.org)");
35387
+ logger11.warn("Auth token found but no @uipath:registry configured in .npmrc — " + "token will be sent to the default registry (npmjs.org)");
33483
35388
  }
33484
35389
  return { registryUrl, authToken };
33485
35390
  }
@@ -33488,6 +35393,7 @@ class NodeToolService {
33488
35393
  async fetchPackageInfo(registryUrl, packageName, headers) {
33489
35394
  const encodedName = packageName.replaceAll("/", "%2f");
33490
35395
  const url2 = `${registryUrl.replace(/\/+$/, "")}/${encodedName}`;
35396
+ logger11.debug(`Fetching package info: ${url2}`);
33491
35397
  const fetchHeaders = {
33492
35398
  Accept: "application/json",
33493
35399
  ...headers
@@ -33504,17 +35410,15 @@ class NodeToolService {
33504
35410
  }
33505
35411
  const data = await response.json();
33506
35412
  const latestVersion = data["dist-tags"]?.latest;
33507
- let registryLabel;
33508
- try {
33509
- registryLabel = new URL(registryUrl).host;
33510
- } catch {
33511
- registryLabel = registryUrl;
33512
- }
35413
+ const [labelError, parsedUrl] = catchError10(() => new URL(registryUrl));
35414
+ const registryLabel = labelError ? registryUrl : parsedUrl.host;
35415
+ const availableVersions = Object.keys(data.versions || {}).filter(isValidSemver).sort((a, b) => compareSemver(b, a));
35416
+ logger11.debug(`Package '${packageName}': latest=${latestVersion ?? "unknown"}, ${availableVersions.length} versions available`);
33513
35417
  return {
33514
35418
  name: data.name,
33515
35419
  version: latestVersion || "latest",
33516
35420
  description: data.description || "",
33517
- availableVersions: Object.keys(data.versions || {}).filter(isValidSemver).sort((a, b) => compareSemver(b, a)),
35421
+ availableVersions,
33518
35422
  registry: registryLabel
33519
35423
  };
33520
35424
  }
@@ -33526,17 +35430,17 @@ class NodeToolService {
33526
35430
  const packages = [...TOOLS_WHITELIST.keys()];
33527
35431
  const settled = await Promise.allSettled(packages.map((name) => this.fetchPackageInfo(registryUrl, name, headers)));
33528
35432
  const results = [];
33529
- const errors4 = [];
35433
+ const errors5 = [];
33530
35434
  for (const r of settled) {
33531
35435
  if (r.status === "fulfilled") {
33532
35436
  results.push(r.value);
33533
35437
  } else {
33534
- errors4.push(r.reason instanceof Error ? r.reason.message : String(r.reason));
35438
+ errors5.push(r.reason instanceof Error ? r.reason.message : String(r.reason));
33535
35439
  }
33536
35440
  }
33537
35441
  if (results.length === 0) {
33538
35442
  throw new Error(`All ${packages.length} package lookups on ${registryUrl} failed:
33539
- ${errors4.map((e) => ` - ${e}`).join(`
35443
+ ${errors5.map((e) => ` - ${e}`).join(`
33540
35444
  `)}`);
33541
35445
  }
33542
35446
  if (query && query.trim() !== "") {
@@ -33546,6 +35450,7 @@ ${errors4.map((e) => ` - ${e}`).join(`
33546
35450
  return results;
33547
35451
  }
33548
35452
  async searchLatestVersion(packageName, versionPrefix) {
35453
+ logger11.debug(`Searching latest version of '${packageName}'${versionPrefix ? ` with prefix '${versionPrefix}'` : ""}`);
33549
35454
  const { registryUrl, authToken } = await resolveRegistry();
33550
35455
  const headers = {};
33551
35456
  if (authToken)
@@ -33554,24 +35459,40 @@ ${errors4.map((e) => ` - ${e}`).join(`
33554
35459
  if (versionPrefix && info.availableVersions) {
33555
35460
  const matching = info.availableVersions.filter((v) => v.startsWith(versionPrefix));
33556
35461
  const stable = matching.find((v) => !v.includes("-"));
33557
- if (stable)
35462
+ if (stable) {
35463
+ logger11.debug(`Resolved version: ${stable} (stable, prefix match)`);
33558
35464
  return stable;
33559
- if (matching.length > 0)
35465
+ }
35466
+ if (matching.length > 0) {
35467
+ logger11.debug(`Resolved version: ${matching[0]} (prerelease, prefix match)`);
33560
35468
  return matching[0];
35469
+ }
35470
+ logger11.debug(`No version found matching prefix '${versionPrefix}'`);
33561
35471
  return null;
33562
35472
  }
35473
+ logger11.debug(`Resolved version: ${info.version ?? "null"} (latest)`);
33563
35474
  return info.version ?? null;
33564
35475
  }
33565
35476
  async install(packageName, destination, options) {
33566
35477
  validatePackageSpec(packageName);
33567
- if (options?.global) {
33568
- await runPackageManager(["install", "-g", packageName], destination);
33569
- } else {
33570
- await runPackageManager(["install", packageName], destination);
35478
+ const baseArgs = options?.global ? ["install", "-g", packageName] : ["install", packageName];
35479
+ for (let attempt = 0;attempt <= NPM_MAX_RETRIES; attempt++) {
35480
+ const [err] = await catchError10(runPackageManager(baseArgs, destination));
35481
+ if (!err) {
35482
+ return;
35483
+ }
35484
+ const msg = extractErrorMessageSync(err);
35485
+ const isTransient = TRANSIENT_NPM_ERRORS.some((code) => msg.includes(code));
35486
+ if (!isTransient || attempt === NPM_MAX_RETRIES) {
35487
+ throw err;
35488
+ }
35489
+ const delayMs = 1000 * (attempt + 1);
35490
+ logger11.warn(`npm install failed with transient error (attempt ${attempt + 1}/${NPM_MAX_RETRIES + 1}), retrying in ${delayMs}ms: ${msg}`);
35491
+ await new Promise((r) => setTimeout(r, delayMs));
33571
35492
  }
33572
35493
  }
33573
35494
  async uninstall(packageName, destination, options) {
33574
- const fs = getFileSystem10();
35495
+ const fs = getFileSystem12();
33575
35496
  const nodeModulesDir = fs.path.resolve(destination, "node_modules");
33576
35497
  const packageDir = fs.path.resolve(fs.path.join(destination, "node_modules", packageName));
33577
35498
  if (!packageDir.startsWith(`${nodeModulesDir}/`) && !packageDir.startsWith(`${nodeModulesDir}\\`)) {
@@ -33580,14 +35501,12 @@ ${errors4.map((e) => ` - ${e}`).join(`
33580
35501
  if (!await fs.exists(packageDir)) {
33581
35502
  throw new Error(`Package '${packageName}' is not installed at ${destination}`);
33582
35503
  }
33583
- try {
33584
- const stat = await fs.stat(packageDir);
33585
- if (!stat) {
33586
- await fs.rm(packageDir);
33587
- logger10.info(`Removed workspace-linked package '${packageName}'`);
33588
- return;
33589
- }
33590
- } catch (_e) {}
35504
+ const [statError, stat] = await catchError10(fs.stat(packageDir));
35505
+ if (!statError && !stat) {
35506
+ await fs.rm(packageDir);
35507
+ logger11.info(`Removed workspace-linked package '${packageName}'`);
35508
+ return;
35509
+ }
33591
35510
  if (options?.global) {
33592
35511
  await runPackageManager(["uninstall", "-g", packageName], destination);
33593
35512
  } else {
@@ -33595,7 +35514,7 @@ ${errors4.map((e) => ` - ${e}`).join(`
33595
35514
  }
33596
35515
  if (await fs.exists(packageDir)) {
33597
35516
  await fs.rm(packageDir);
33598
- logger10.info(`Package directory for '${packageName}' still existed after uninstall — removed manually`);
35517
+ logger11.info(`Package directory for '${packageName}' still existed after uninstall — removed manually`);
33599
35518
  }
33600
35519
  }
33601
35520
  }
@@ -33622,11 +35541,12 @@ function truncateVersionsForDisplay(versions2) {
33622
35541
  }
33623
35542
  return result;
33624
35543
  }
33625
- var SEMVER_RE, SAFE_PACKAGE_SPEC, SAFE_VERSION, NPM_TIMEOUT_MS = 180000, TOOLS_WHITELIST, WHITELIST_BY_COMMAND, WHITELIST_BY_SHORT_NAME, DEFAULT_REGISTRY = "https://registry.npmjs.org", toolService;
35544
+ var SEMVER_RE, SAFE_PACKAGE_SPEC, SAFE_VERSION, NPM_TIMEOUT_MS = 180000, NPM_MAX_RETRIES = 2, TRANSIENT_NPM_ERRORS, TOOLS_WHITELIST, WHITELIST_BY_COMMAND, WHITELIST_BY_SHORT_NAME, DEFAULT_REGISTRY = "https://registry.npmjs.org", toolService;
33626
35545
  var init_toolService = __esm(() => {
33627
35546
  SEMVER_RE = /^\d+\.\d+\.\d+(-[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*)?(\+[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*)?$/;
33628
35547
  SAFE_PACKAGE_SPEC = /^@?[a-zA-Z0-9._/-]+(@[a-zA-Z0-9._+:~^<>=| -]+)?$/;
33629
35548
  SAFE_VERSION = /^[a-zA-Z0-9._+:~^<>=| -]+$/;
35549
+ TRANSIENT_NPM_ERRORS = ["ENOTEMPTY", "EPERM", "EBUSY"];
33630
35550
  TOOLS_WHITELIST = new Map([
33631
35551
  ["@uipath/solution-tool", "solution"],
33632
35552
  ["@uipath/agent-tool", "agent"],
@@ -33654,15 +35574,25 @@ var init_toolService = __esm(() => {
33654
35574
 
33655
35575
  // src/commands/tools/install.ts
33656
35576
  import {
33657
- catchError as catchError8,
33658
- logger as logger11,
35577
+ catchError as catchError11,
35578
+ logger as logger12,
33659
35579
  OutputFormatter as OutputFormatter7,
33660
35580
  processContext as processContext5
33661
35581
  } from "@uipath/common";
33662
35582
  function registerInstallCommand2(toolsCommand, _context, state) {
33663
35583
  const { resolveInstallPath, getCliVersionPrefix } = state;
33664
- toolsCommand.command("install").description("Install a tool from registry").argument("<package-name>", "Name of the package to install").trackedAction(processContext5, async (packageArg) => {
33665
- const packageName = resolveToolPackageName(packageArg);
35584
+ toolsCommand.command("install").description("Install a tool from registry").argument("<package-name>", "Name of the package to install (optionally with @version)").trackedAction(processContext5, async (packageArg) => {
35585
+ const { name: rawName, version: explicitVersion } = parsePackageSpec(packageArg);
35586
+ if (explicitVersion && !isValidSemver(explicitVersion)) {
35587
+ OutputFormatter7.error({
35588
+ Result: "Failure",
35589
+ Message: `Invalid version '${explicitVersion}'.`,
35590
+ Instructions: "Version must be a valid semver string (e.g. 1.0.0 or 1.0.0-beta.1)."
35591
+ });
35592
+ processContext5.exit(1);
35593
+ return;
35594
+ }
35595
+ const packageName = resolveToolPackageName(rawName);
33666
35596
  if (!TOOLS_WHITELIST.has(packageName)) {
33667
35597
  OutputFormatter7.error({
33668
35598
  Result: "Failure",
@@ -33672,10 +35602,13 @@ function registerInstallCommand2(toolsCommand, _context, state) {
33672
35602
  processContext5.exit(1);
33673
35603
  return;
33674
35604
  }
33675
- const [error48] = await catchError8((async () => {
35605
+ const [error48] = await catchError11((async () => {
33676
35606
  const location = await resolveInstallPath(packageName);
33677
- let packageSpec = packageName;
33678
- if (!packageName.includes("@", 1)) {
35607
+ let packageSpec;
35608
+ if (explicitVersion) {
35609
+ packageSpec = `${packageName}@${explicitVersion}`;
35610
+ } else {
35611
+ packageSpec = packageName;
33679
35612
  const cliPrefix = getCliVersionPrefix();
33680
35613
  const version2 = await toolService.searchLatestVersion(packageName, cliPrefix);
33681
35614
  if (version2) {
@@ -33685,7 +35618,7 @@ function registerInstallCommand2(toolsCommand, _context, state) {
33685
35618
  await toolService.install(packageSpec, location.path, {
33686
35619
  global: location.global
33687
35620
  });
33688
- logger11.info(`Installed to ${location.path}`);
35621
+ logger12.info(`Installed to ${location.path}`);
33689
35622
  OutputFormatter7.success({
33690
35623
  Result: "Success",
33691
35624
  Code: "Message",
@@ -33712,20 +35645,26 @@ var init_install2 = __esm(() => {
33712
35645
  import { OutputFormatter as OutputFormatter8, processContext as processContext6 } from "@uipath/common";
33713
35646
  function registerListCommand(toolsCommand, state) {
33714
35647
  toolsCommand.command("list").description("List installed tools").trackedAction(processContext6, async () => {
35648
+ const data = state.tools.length > 0 ? state.tools.map((tool) => tool.metadata) : (state.discoveredTools ?? []).map((d) => ({
35649
+ name: d.toolName,
35650
+ version: d.version,
35651
+ description: d.description,
35652
+ commandPrefix: d.commandPrefix
35653
+ }));
33715
35654
  OutputFormatter8.success({
33716
35655
  Result: "Success",
33717
35656
  Code: "ToolList",
33718
- Data: state.tools.map((tool) => tool.metadata)
35657
+ Data: data
33719
35658
  });
33720
35659
  });
33721
35660
  }
33722
35661
  var init_list = () => {};
33723
35662
 
33724
35663
  // src/commands/tools/search.ts
33725
- import { catchError as catchError9, OutputFormatter as OutputFormatter9, processContext as processContext7 } from "@uipath/common";
35664
+ import { catchError as catchError12, OutputFormatter as OutputFormatter9, processContext as processContext7 } from "@uipath/common";
33726
35665
  function registerSearchCommand(toolsCommand, _context) {
33727
35666
  toolsCommand.command("search").description("Search for tools in the configured registry").argument("[query]", "Search query (name or keyword)").trackedAction(processContext7, async (query) => {
33728
- const [error48, results] = await catchError9(toolService.search(query));
35667
+ const [error48, results] = await catchError12(toolService.search(query));
33729
35668
  if (error48) {
33730
35669
  OutputFormatter9.error({
33731
35670
  Result: "Failure",
@@ -33751,7 +35690,7 @@ var init_search = __esm(() => {
33751
35690
  });
33752
35691
 
33753
35692
  // src/commands/tools/uninstall.ts
33754
- import { catchError as catchError10, OutputFormatter as OutputFormatter10, processContext as processContext8 } from "@uipath/common";
35693
+ import { catchError as catchError13, OutputFormatter as OutputFormatter10, processContext as processContext8 } from "@uipath/common";
33755
35694
  function registerUninstallCommand2(toolsCommand, _context, state) {
33756
35695
  const { resolveInstallPath } = state;
33757
35696
  toolsCommand.command("uninstall").description("Uninstall an installed tool").argument("<package-name>", "Package name (e.g. @uipath/rpa-tool) or command alias (e.g. rpa)").trackedAction(processContext8, async (packageArg) => {
@@ -33760,12 +35699,12 @@ function registerUninstallCommand2(toolsCommand, _context, state) {
33760
35699
  OutputFormatter10.error({
33761
35700
  Result: "Failure",
33762
35701
  Message: `Unknown tool '${packageArg}'.`,
33763
- Instructions: `Use 'uip tools installed' to see installed tools.`
35702
+ Instructions: `Use 'uip tools list' to see installed tools.`
33764
35703
  });
33765
35704
  processContext8.exit(1);
33766
35705
  return;
33767
35706
  }
33768
- const [error48] = await catchError10((async () => {
35707
+ const [error48] = await catchError13((async () => {
33769
35708
  const location = await resolveInstallPath();
33770
35709
  await toolService.uninstall(packageName, location.path, {
33771
35710
  global: location.global
@@ -33782,7 +35721,7 @@ function registerUninstallCommand2(toolsCommand, _context, state) {
33782
35721
  OutputFormatter10.error({
33783
35722
  Result: "Failure",
33784
35723
  Message: `Failed to uninstall '${packageName}': ${error48.message}`,
33785
- Instructions: "Use 'uip tools installed' to see installed tools."
35724
+ Instructions: "Use 'uip tools list' to see installed tools."
33786
35725
  });
33787
35726
  processContext8.exit(1);
33788
35727
  }
@@ -33794,12 +35733,12 @@ var init_uninstall2 = __esm(() => {
33794
35733
 
33795
35734
  // src/commands/tools/update.ts
33796
35735
  import {
33797
- catchError as catchError11,
33798
- logger as logger12,
35736
+ catchError as catchError14,
35737
+ logger as logger13,
33799
35738
  OutputFormatter as OutputFormatter11,
33800
35739
  processContext as processContext9
33801
35740
  } from "@uipath/common";
33802
- import { getFileSystem as getFileSystem11 } from "@uipath/filesystem";
35741
+ import { getFileSystem as getFileSystem13 } from "@uipath/filesystem";
33803
35742
  function registerUpdateCommand2(toolsCommand, _context, state) {
33804
35743
  const { tools, toolsDirs, resolveInstallPath, getCliVersionPrefix } = state;
33805
35744
  toolsCommand.command("update").description("Update installed tools").option("--name <scoped-tool-name>", "scoped package name").option("--version <version>", "package version to install", "latest").trackedAction(processContext9, async (options) => {
@@ -33812,7 +35751,7 @@ function registerUpdateCommand2(toolsCommand, _context, state) {
33812
35751
  processContext9.exit(1);
33813
35752
  return;
33814
35753
  }
33815
- const [locationError, location] = await catchError11(resolveInstallPath());
35754
+ const [locationError, location] = await catchError14(resolveInstallPath());
33816
35755
  if (locationError) {
33817
35756
  OutputFormatter11.error({
33818
35757
  Result: "Failure",
@@ -33828,13 +35767,13 @@ function registerUpdateCommand2(toolsCommand, _context, state) {
33828
35767
  OutputFormatter11.error({
33829
35768
  Result: "Failure",
33830
35769
  Message: `Tool '${options.name}' is not installed.`,
33831
- Instructions: "Use 'uip tools installed' to see installed tools."
35770
+ Instructions: "Use 'uip tools list' to see installed tools."
33832
35771
  });
33833
35772
  processContext9.exit(1);
33834
35773
  return;
33835
35774
  }
33836
35775
  if (options.version !== "latest") {
33837
- const [validateError] = catchError11(() => validateVersionString(options.version));
35776
+ const [validateError] = catchError14(() => validateVersionString(options.version));
33838
35777
  if (validateError) {
33839
35778
  OutputFormatter11.error({
33840
35779
  Result: "Failure",
@@ -33849,7 +35788,7 @@ function registerUpdateCommand2(toolsCommand, _context, state) {
33849
35788
  const previousVersions = new Map(toUpdate.map((t) => [t.metadata.name, t.metadata.version]));
33850
35789
  for (const tool of toUpdate) {
33851
35790
  const fullName = `@uipath/${tool.metadata.name}`;
33852
- const [updateError] = await catchError11((async () => {
35791
+ const [updateError] = await catchError14((async () => {
33853
35792
  let targetVersion = options.version;
33854
35793
  if (targetVersion === "latest") {
33855
35794
  const cliPrefix = getCliVersionPrefix();
@@ -33887,7 +35826,7 @@ function registerUpdateCommand2(toolsCommand, _context, state) {
33887
35826
  });
33888
35827
  }
33889
35828
  }
33890
- const fs = getFileSystem11();
35829
+ const fs = getFileSystem13();
33891
35830
  const updatedVersions = new Map;
33892
35831
  for (const dir of toolsDirs) {
33893
35832
  for (const tool of toUpdate) {
@@ -33897,10 +35836,10 @@ function registerUpdateCommand2(toolsCommand, _context, state) {
33897
35836
  const pkgPath = fs.path.join(dir, name, "package.json");
33898
35837
  if (!await fs.exists(pkgPath))
33899
35838
  continue;
33900
- const [readError, raw] = await catchError11(fs.readFile(pkgPath, "utf-8"));
35839
+ const [readError, raw] = await catchError14(fs.readFile(pkgPath, "utf-8"));
33901
35840
  if (readError || !raw)
33902
35841
  continue;
33903
- const [parseError, pkg] = catchError11(() => JSON.parse(raw));
35842
+ const [parseError, pkg] = catchError14(() => JSON.parse(raw));
33904
35843
  if (parseError || !pkg.version)
33905
35844
  continue;
33906
35845
  updatedVersions.set(name, pkg.version);
@@ -33932,7 +35871,7 @@ function registerUpdateCommand2(toolsCommand, _context, state) {
33932
35871
  Data: results
33933
35872
  });
33934
35873
  if (failed.length > 0) {
33935
- logger12.error(`Failed to update ${failed.length} tool(s): ${failed.map((f) => `${f.name}: ${f.error}`).join("; ")}`);
35874
+ logger13.error(`Failed to update ${failed.length} tool(s): ${failed.map((f) => `${f.name}: ${f.error}`).join("; ")}`);
33936
35875
  processContext9.exit(1);
33937
35876
  }
33938
35877
  });
@@ -33958,18 +35897,82 @@ var init_tools = __esm(() => {
33958
35897
  init_update2();
33959
35898
  });
33960
35899
 
35900
+ // src/services/installPath.ts
35901
+ import { catchError as catchError15, logger as logger14 } from "@uipath/common";
35902
+ function createInstallPathResolver(toolsDir, isBrowser2) {
35903
+ return async (packageName) => {
35904
+ if (isBrowser2) {
35905
+ const path = packageName ? `/tools/${packageName.replace(/[/@]/g, "_")}` : "/tools";
35906
+ return { path, global: false };
35907
+ }
35908
+ const { getFileSystem: getFileSystem14 } = await import("@uipath/filesystem");
35909
+ const fsLocal = getFileSystem14();
35910
+ const { dirname: dirnameFn, join: joinFn } = fsLocal.path;
35911
+ if (toolsDir) {
35912
+ let path = dirnameFn(dirnameFn(toolsDir));
35913
+ while (insideNodeModules(path)) {
35914
+ const parent = dirnameFn(path);
35915
+ if (parent === path)
35916
+ break;
35917
+ path = parent;
35918
+ }
35919
+ let isGlobal = true;
35920
+ const pkgJsonPath = joinFn(path, "package.json");
35921
+ if (await fsLocal.exists(pkgJsonPath)) {
35922
+ const [, raw] = await catchError15(fsLocal.readFile(pkgJsonPath, "utf-8"));
35923
+ if (raw) {
35924
+ const [, pkgJson] = catchError15(() => JSON.parse(raw));
35925
+ if (pkgJson) {
35926
+ const deps = {
35927
+ ...pkgJson.dependencies,
35928
+ ...pkgJson.devDependencies
35929
+ };
35930
+ if (deps && "@uipath/cli" in deps) {
35931
+ isGlobal = false;
35932
+ }
35933
+ if (pkgJson.workspaces) {
35934
+ isGlobal = false;
35935
+ }
35936
+ }
35937
+ }
35938
+ }
35939
+ logger14.debug(`Install path resolved: ${path} (global: ${isGlobal})`);
35940
+ return { path, global: isGlobal };
35941
+ }
35942
+ let searchDir = fsLocal.env.cwd();
35943
+ for (let i2 = 0;i2 < 10; i2++) {
35944
+ const nodeModulesPath = joinFn(searchDir, "node_modules");
35945
+ const [, exists] = await catchError15(fsLocal.exists(nodeModulesPath));
35946
+ if (exists) {
35947
+ logger14.debug(`Install path resolved via fallback: ${searchDir}`);
35948
+ return { path: searchDir, global: false };
35949
+ }
35950
+ const parentDir = dirnameFn(searchDir);
35951
+ if (parentDir === searchDir)
35952
+ break;
35953
+ searchDir = parentDir;
35954
+ }
35955
+ throw new Error("Unable to determine install location. No node_modules found in parent directories.");
35956
+ };
35957
+ }
35958
+ var insideNodeModules = (dir) => /[\\/]node_modules([\\/]|$)/.test(dir);
35959
+ var init_installPath = () => {};
35960
+
33961
35961
  // src/services/storage.ts
33962
- import { getFileSystem as getFileSystem12, getFileSystemAsync } from "@uipath/filesystem";
35962
+ import { logger as logger15 } from "@uipath/common";
35963
+ import { getFileSystem as getFileSystem14, getFileSystemAsync } from "@uipath/filesystem";
33963
35964
 
33964
35965
  class GeneralizedStorage {
33965
35966
  async init() {
35967
+ logger15.debug("Initializing filesystem...");
33966
35968
  await getFileSystemAsync();
35969
+ logger15.debug("Filesystem initialized");
33967
35970
  }
33968
35971
  get fs() {
33969
- return getFileSystem12();
35972
+ return getFileSystem14();
33970
35973
  }
33971
- async read(path3) {
33972
- const res = await this.fs.readFile(path3);
35974
+ async read(path) {
35975
+ const res = await this.fs.readFile(path);
33973
35976
  if (res === null)
33974
35977
  return null;
33975
35978
  if (typeof res === "string") {
@@ -33977,25 +35980,25 @@ class GeneralizedStorage {
33977
35980
  }
33978
35981
  return res;
33979
35982
  }
33980
- async readText(path3) {
33981
- return this.fs.readFile(path3, "utf-8");
35983
+ async readText(path) {
35984
+ return this.fs.readFile(path, "utf-8");
33982
35985
  }
33983
- async write(path3, content) {
33984
- await this.fs.writeFile(path3, content);
35986
+ async write(path, content) {
35987
+ await this.fs.writeFile(path, content);
33985
35988
  }
33986
- async exists(path3) {
33987
- return this.fs.exists(path3);
35989
+ async exists(path) {
35990
+ return this.fs.exists(path);
33988
35991
  }
33989
- async readdir(path3) {
33990
- return this.fs.readdir(path3);
35992
+ async readdir(path) {
35993
+ return this.fs.readdir(path);
33991
35994
  }
33992
- async remove(path3) {
33993
- if (!await this.fs.exists(path3))
35995
+ async remove(path) {
35996
+ if (!await this.fs.exists(path))
33994
35997
  return;
33995
- await this.fs.rm(path3);
35998
+ await this.fs.rm(path);
33996
35999
  }
33997
- async mkdir(path3) {
33998
- await this.fs.mkdir(path3);
36000
+ async mkdir(path) {
36001
+ await this.fs.mkdir(path);
33999
36002
  }
34000
36003
  }
34001
36004
  var storage;
@@ -34004,36 +36007,38 @@ var init_storage = __esm(() => {
34004
36007
  });
34005
36008
 
34006
36009
  // src/utils/toolLoader.ts
34007
- import { logger as logger13 } from "@uipath/common";
36010
+ import { catchError as catchError16, logger as logger16 } from "@uipath/common";
36011
+ import { getFileSystem as getFileSystem15 } from "@uipath/filesystem";
34008
36012
  import { Command } from "commander";
34009
36013
  function isRunningFromSource() {
34010
- try {
34011
- const mainUrl = import.meta.url;
34012
- return mainUrl.endsWith(".ts");
34013
- } catch {
36014
+ const [error48, mainUrl] = catchError16(() => import.meta.url);
36015
+ if (error48) {
34014
36016
  return false;
34015
36017
  }
36018
+ return mainUrl.endsWith(".ts");
34016
36019
  }
34017
36020
  function joinPath(...parts) {
34018
36021
  return parts.filter((p) => p).join("/").replace(/\/+/g, "/");
34019
36022
  }
34020
- async function discoverTools(toolsDirs) {
34021
- try {
34022
- await storage.init();
34023
- } catch (error48) {
34024
- logger13.error("Storage initialization failed:", error48);
36023
+ async function discoverToolPaths(toolsDirs) {
36024
+ const [initError] = await catchError16(storage.init());
36025
+ if (initError) {
36026
+ logger16.error("Storage initialization failed:", initError);
34025
36027
  return [];
34026
36028
  }
34027
36029
  const dirs = Array.isArray(toolsDirs) ? toolsDirs : [toolsDirs];
34028
- const tools = [];
34029
- const seenCommands = new Set;
36030
+ const discovered = [];
36031
+ const seenPrefixes = new Set;
34030
36032
  for (const toolsDir of dirs) {
34031
36033
  if (!await storage.exists(toolsDir)) {
36034
+ logger16.debug(`Tools directory does not exist, skipping: ${toolsDir}`);
34032
36035
  continue;
34033
36036
  }
34034
- for (const toolName of WHITELIST_BY_SHORT_NAME.keys()) {
36037
+ logger16.debug(`Scanning tools directory: ${toolsDir}`);
36038
+ const toolNames = [...WHITELIST_BY_SHORT_NAME.keys()];
36039
+ const resolvedPaths = await Promise.all(toolNames.map(async (toolName) => {
34035
36040
  const toolDir = joinPath(toolsDir, toolName);
34036
- const possiblePaths = isRunningFromSource() ? [
36041
+ const possiblePaths = _isRunningFromSource ? [
34037
36042
  joinPath(toolDir, "src", "tool.ts"),
34038
36043
  joinPath(toolDir, "dist", "tool.js"),
34039
36044
  joinPath(toolDir, "tool.js")
@@ -34042,123 +36047,403 @@ async function discoverTools(toolsDirs) {
34042
36047
  joinPath(toolDir, "tool.js"),
34043
36048
  joinPath(toolDir, "src", "tool.ts")
34044
36049
  ];
34045
- let toolPath = null;
34046
- for (const path3 of possiblePaths) {
34047
- if (await storage.exists(path3)) {
34048
- toolPath = path3;
34049
- break;
36050
+ const factoryPaths = _isRunningFromSource ? [
36051
+ joinPath(toolDir, "src", "packager-tool.ts"),
36052
+ joinPath(toolDir, "dist", "packager-tool.js")
36053
+ ] : [
36054
+ joinPath(toolDir, "dist", "packager-tool.js"),
36055
+ joinPath(toolDir, "src", "packager-tool.ts")
36056
+ ];
36057
+ const [existResults, factoryExistResults, pkgJson] = await Promise.all([
36058
+ Promise.all(possiblePaths.map((p) => storage.exists(p))),
36059
+ Promise.all(factoryPaths.map((p) => storage.exists(p))),
36060
+ storage.readText(joinPath(toolDir, "package.json")).catch(() => null)
36061
+ ]);
36062
+ const foundIndex = existResults.indexOf(true);
36063
+ const factoryIndex = factoryExistResults.indexOf(true);
36064
+ let description = "";
36065
+ let version2 = "";
36066
+ if (pkgJson) {
36067
+ const [parseErr, pkg] = catchError16(() => JSON.parse(pkgJson));
36068
+ if (!parseErr) {
36069
+ description = pkg.description ?? "";
36070
+ version2 = pkg.version ?? "";
34050
36071
  }
34051
36072
  }
36073
+ return {
36074
+ toolName,
36075
+ toolPath: foundIndex >= 0 ? possiblePaths[foundIndex] : null,
36076
+ packagerToolPath: factoryIndex >= 0 ? factoryPaths[factoryIndex] : undefined,
36077
+ description,
36078
+ version: version2
36079
+ };
36080
+ }));
36081
+ for (const {
36082
+ toolName,
36083
+ toolPath,
36084
+ packagerToolPath,
36085
+ description,
36086
+ version: version2
36087
+ } of resolvedPaths) {
34052
36088
  if (!toolPath) {
36089
+ logger16.debug(`Tool '${toolName}' not found in ${joinPath(toolsDir, toolName)}`);
34053
36090
  continue;
34054
36091
  }
34055
- try {
34056
- let toolModule;
34057
- const isNode = typeof process !== "undefined" && process.versions && process.versions.node;
34058
- const isBrowser2 = !isNode;
34059
- const savedTrackedAction = Command.prototype.trackedAction;
34060
- if (isBrowser2) {
34061
- const content = await storage.readText(toolPath);
34062
- if (!content)
34063
- continue;
34064
- const blob = new Blob([content], {
34065
- type: "text/javascript"
34066
- });
34067
- const blobUrl = URL.createObjectURL(blob);
34068
- try {
34069
- toolModule = await import(blobUrl);
34070
- } finally {
34071
- URL.revokeObjectURL(blobUrl);
34072
- }
34073
- } else {
34074
- const { pathToFileURL } = await import("node:url");
34075
- const fileUrl = pathToFileURL(toolPath).href;
34076
- toolModule = await import(fileUrl);
34077
- }
34078
- if (savedTrackedAction && Command.prototype.trackedAction !== savedTrackedAction) {
34079
- Command.prototype.trackedAction = savedTrackedAction;
34080
- logger13.warn(`Tool ${toolName} overwrote Command.prototype.trackedAction — restored CLI version. ` + `This tool likely bundles @uipath/common instead of externalizing it.`);
34081
- }
34082
- const { metadata, registerCommands } = toolModule ?? {};
34083
- if (!metadata || !registerCommands) {
34084
- logger13.warn(`Tool ${toolName} missing required exports (metadata or registerCommands), skipping`);
34085
- continue;
34086
- }
34087
- const prefix = metadata.commandPrefix;
34088
- if (seenCommands.has(prefix)) {
34089
- logger13.info(`Tool ${toolName} (command '${prefix}') already loaded from a higher-priority path, skipping`);
34090
- continue;
34091
- }
34092
- seenCommands.add(prefix);
34093
- const tool = {
34094
- metadata,
34095
- registerCommands
34096
- };
34097
- tools.push(tool);
34098
- } catch (error48) {
34099
- logger13.error(`Failed to load tool ${toolName}:`, error48);
36092
+ const packageName = WHITELIST_BY_SHORT_NAME.get(toolName);
36093
+ const commandPrefix = packageName ? TOOLS_WHITELIST.get(packageName) : undefined;
36094
+ if (!commandPrefix || !packageName) {
36095
+ logger16.warn(`Tool '${toolName}' found at ${toolPath} but not in whitelist, skipping`);
36096
+ continue;
36097
+ }
36098
+ if (seenPrefixes.has(commandPrefix)) {
36099
+ logger16.info(`Tool ${toolName} (command '${commandPrefix}') already found from a higher-priority path, skipping`);
36100
+ continue;
34100
36101
  }
36102
+ seenPrefixes.add(commandPrefix);
36103
+ discovered.push({
36104
+ toolName,
36105
+ toolPath,
36106
+ commandPrefix,
36107
+ packageName,
36108
+ description,
36109
+ version: version2,
36110
+ packagerToolPath
36111
+ });
36112
+ logger16.debug(`Discovered tool '${toolName}' at ${toolPath} (prefix: ${commandPrefix})`);
36113
+ }
36114
+ }
36115
+ return discovered;
36116
+ }
36117
+ async function importModuleByPath(modulePath) {
36118
+ const savedTrackedAction = Command.prototype.trackedAction;
36119
+ const [error48, mod] = await catchError16((async () => {
36120
+ if (_isBrowser) {
36121
+ const content = await storage.readText(modulePath);
36122
+ if (!content)
36123
+ return;
36124
+ const blob = new Blob([content], { type: "text/javascript" });
36125
+ const blobUrl = URL.createObjectURL(blob);
36126
+ const [importError, imported] = await catchError16(import(blobUrl));
36127
+ URL.revokeObjectURL(blobUrl);
36128
+ if (importError)
36129
+ throw importError;
36130
+ return imported;
36131
+ } else {
36132
+ const { pathToFileURL } = await import("node:url");
36133
+ const fileUrl = pathToFileURL(modulePath).href;
36134
+ return await import(fileUrl);
36135
+ }
36136
+ })());
36137
+ if (savedTrackedAction && Command.prototype.trackedAction !== savedTrackedAction) {
36138
+ Command.prototype.trackedAction = savedTrackedAction;
36139
+ logger16.warn(`Import of ${modulePath} overwrote Command.prototype.trackedAction — restored CLI version.`);
36140
+ }
36141
+ if (error48)
36142
+ throw error48;
36143
+ return mod;
36144
+ }
36145
+ async function importTool(discovered) {
36146
+ const { toolName, toolPath } = discovered;
36147
+ logger16.debug(`Loading tool '${toolName}' from ${toolPath}`);
36148
+ const [error48, toolModule] = await catchError16(importModuleByPath(toolPath));
36149
+ if (error48) {
36150
+ logger16.error(`Failed to load tool ${toolName}:`, error48);
36151
+ return;
36152
+ }
36153
+ const { metadata, registerCommands } = toolModule ?? {};
36154
+ if (!metadata || !registerCommands) {
36155
+ logger16.warn(`Tool ${toolName} missing required exports (metadata or registerCommands), skipping`);
36156
+ return;
36157
+ }
36158
+ logger16.debug(`Tool '${toolName}' loaded successfully (prefix: ${metadata.commandPrefix}, version: ${metadata.version ?? "unknown"})`);
36159
+ return { metadata, registerCommands };
36160
+ }
36161
+ async function importPackagerTool(discovered) {
36162
+ const { toolName, packagerToolPath } = discovered;
36163
+ if (!packagerToolPath)
36164
+ return;
36165
+ logger16.debug(`Loading packager factory for '${toolName}' from ${packagerToolPath}`);
36166
+ const [error48] = await catchError16(importModuleByPath(packagerToolPath));
36167
+ if (error48) {
36168
+ throw new Error(`Failed to load packager factory for '${toolName}' from ${packagerToolPath}: ${error48 instanceof Error ? error48.message : error48}`);
36169
+ }
36170
+ }
36171
+ async function discoverTools(toolsDirs) {
36172
+ const discovered = await discoverToolPaths(toolsDirs);
36173
+ const tools = [];
36174
+ for (const entry of discovered) {
36175
+ const tool = await importTool(entry);
36176
+ if (tool) {
36177
+ tools.push(tool);
34101
36178
  }
34102
36179
  }
34103
36180
  return tools;
34104
36181
  }
36182
+ function isInsideNodeModules(dir) {
36183
+ const segments = dir.replace(/\\/g, "/").split("/").filter(Boolean);
36184
+ return segments.includes("node_modules");
36185
+ }
36186
+ async function findNearestToolsDir(startDir, seen) {
36187
+ const fs = getFileSystem15();
36188
+ const { dirname, join } = fs.path;
36189
+ const results = [];
36190
+ let searchPath = startDir;
36191
+ for (let i2 = 0;i2 < MAX_WALK_DEPTH; i2++) {
36192
+ const candidate = join(searchPath, "node_modules", "@uipath");
36193
+ const [, exists] = await catchError16(fs.exists(candidate));
36194
+ if (exists) {
36195
+ if (seen.has(candidate)) {
36196
+ logger16.debug(`Tools directory already seen, stopping walk: ${candidate}`);
36197
+ break;
36198
+ }
36199
+ seen.add(candidate);
36200
+ results.push(candidate);
36201
+ logger16.debug(`Found tools directory: ${candidate}`);
36202
+ if (!isInsideNodeModules(searchPath)) {
36203
+ break;
36204
+ }
36205
+ logger16.debug("Search path is inside node_modules, continuing walk for hoisted packages");
36206
+ }
36207
+ const parentPath = dirname(searchPath);
36208
+ if (parentPath === searchPath) {
36209
+ break;
36210
+ }
36211
+ searchPath = parentPath;
36212
+ }
36213
+ if (results.length === 0) {
36214
+ logger16.debug(`No tools directory found walking up from ${startDir}`);
36215
+ }
36216
+ return results;
36217
+ }
36218
+ async function resolveToolsDirs(cliFilePath, cwd) {
36219
+ const fs = getFileSystem15();
36220
+ const { dirname } = fs.path;
36221
+ const seen = new Set;
36222
+ const dirs = [];
36223
+ dirs.push(...await findNearestToolsDir(dirname(cliFilePath), seen));
36224
+ dirs.push(...await findNearestToolsDir(cwd, seen));
36225
+ logger16.debug(`Resolved ${dirs.length} tool directories: ${dirs.join(", ") || "(none)"}`);
36226
+ return dirs;
36227
+ }
36228
+ var _isRunningFromSource, _isBrowser, MAX_WALK_DEPTH = 10;
34105
36229
  var init_toolLoader = __esm(() => {
34106
36230
  init_storage();
34107
36231
  init_toolService();
36232
+ _isRunningFromSource = isRunningFromSource();
36233
+ _isBrowser = !(typeof process !== "undefined" && process.versions && process.versions.node);
34108
36234
  });
34109
36235
 
34110
36236
  // src/services/tool-manager.ts
34111
- import { logger as logger14 } from "@uipath/common";
36237
+ import { logger as logger17 } from "@uipath/common";
34112
36238
 
34113
36239
  class ToolManager {
34114
36240
  toolsDirs;
34115
36241
  resolveInstallPath;
34116
36242
  cliVersionPrefix;
34117
36243
  tools;
34118
- constructor(tools, toolsDirs, resolveInstallPath, cliVersionPrefix) {
36244
+ discoveredTools;
36245
+ discoveredPrefixes;
36246
+ constructor(tools, toolsDirs, resolveInstallPath, cliVersionPrefix, discoveredTools) {
34119
36247
  this.toolsDirs = toolsDirs;
34120
36248
  this.resolveInstallPath = resolveInstallPath;
34121
36249
  this.cliVersionPrefix = cliVersionPrefix;
34122
36250
  this.tools = tools;
36251
+ this.discoveredTools = discoveredTools ?? [];
36252
+ this.discoveredPrefixes = new Set(this.discoveredTools.map((d) => d.commandPrefix));
34123
36253
  }
34124
36254
  isInstalled(verb) {
34125
- return this.tools.some((t) => t.metadata.commandPrefix === verb);
36255
+ return this.discoveredPrefixes.has(verb) || this.tools.some((t) => t.metadata.commandPrefix === verb);
34126
36256
  }
34127
36257
  async ensureAvailable(verb) {
34128
- if (this.isInstalled(verb))
36258
+ if (this.isInstalled(verb)) {
36259
+ logger17.debug(`Tool '${verb}' is already installed`);
34129
36260
  return;
36261
+ }
34130
36262
  const packageName = WHITELIST_BY_COMMAND.get(verb);
34131
36263
  if (!packageName) {
34132
36264
  throw new Error(`Unknown tool verb '${verb}'.`);
34133
36265
  }
34134
- logger14.info(`Tool '${verb}' is not installed. Searching for compatible version...`);
36266
+ logger17.info(`Tool '${verb}' is not installed. Searching for compatible version...`);
36267
+ logger17.debug(`Searching latest version of '${packageName}' with prefix '${this.cliVersionPrefix}'`);
34135
36268
  const version2 = await toolService.searchLatestVersion(packageName, this.cliVersionPrefix);
34136
36269
  if (!version2) {
34137
36270
  throw new Error(`No compatible version of '${packageName}' found for CLI (needs ${this.cliVersionPrefix}x).`);
34138
36271
  }
34139
36272
  const packageSpec = `${packageName}@${version2}`;
34140
36273
  const location = await this.resolveInstallPath();
36274
+ logger17.debug(`Installing ${packageSpec} to ${location.path} (global: ${location.global})`);
34141
36275
  await toolService.install(packageSpec, location.path, {
34142
36276
  global: location.global
34143
36277
  });
34144
- logger14.info(`Installed ${packageSpec} successfully.`);
36278
+ logger17.info(`Installed ${packageSpec} successfully.`);
36279
+ logger17.debug("Re-discovering tools after install...");
34145
36280
  this.tools = await discoverTools(this.toolsDirs);
34146
36281
  }
36282
+ async ensurePackagerFactory(verb) {
36283
+ let entry = this.discoveredTools.find((d) => d.commandPrefix === verb);
36284
+ if (!entry) {
36285
+ logger17.info(`Tool '${verb}' not found on disk. Attempting install...`);
36286
+ await this.installTool(verb);
36287
+ entry = this.discoveredTools.find((d) => d.commandPrefix === verb);
36288
+ if (!entry) {
36289
+ const discovered = this.discoveredTools.map((d) => d.commandPrefix).join(", ");
36290
+ throw new Error(`Tool '${verb}' was not found after installation. ` + `Scanned directories: [${this.toolsDirs.join(", ")}]. ` + `Discovered tools: [${discovered || "none"}].`);
36291
+ }
36292
+ }
36293
+ if (entry.packagerToolPath) {
36294
+ logger17.debug(`Loading packager factory for '${verb}' from ${entry.packagerToolPath}`);
36295
+ await importPackagerTool(entry);
36296
+ return;
36297
+ }
36298
+ logger17.debug(`Tool '${verb}' has no packager-tool entry point, falling back to full tool import`);
36299
+ const tool = await importTool(entry);
36300
+ if (!tool) {
36301
+ throw new Error(`Tool '${verb}' was discovered on disk but failed to load. ` + `Entry point: ${entry.toolPath}`);
36302
+ }
36303
+ }
34147
36304
  getTools() {
34148
36305
  return this.tools;
34149
36306
  }
36307
+ async installTool(verb) {
36308
+ const packageName = WHITELIST_BY_COMMAND.get(verb);
36309
+ if (!packageName) {
36310
+ throw new Error(`Unknown tool verb '${verb}'.`);
36311
+ }
36312
+ logger17.info(`Tool '${verb}' is not installed. Searching for compatible version...`);
36313
+ const version2 = await toolService.searchLatestVersion(packageName, this.cliVersionPrefix);
36314
+ if (!version2) {
36315
+ throw new Error(`No compatible version of '${packageName}' found for CLI (needs ${this.cliVersionPrefix}x).`);
36316
+ }
36317
+ const packageSpec = `${packageName}@${version2}`;
36318
+ const location = await this.resolveInstallPath();
36319
+ logger17.debug(`Installing ${packageSpec} to ${location.path} (global: ${location.global})`);
36320
+ await toolService.install(packageSpec, location.path, {
36321
+ global: location.global
36322
+ });
36323
+ logger17.info(`Installed ${packageSpec} successfully.`);
36324
+ logger17.debug(`Re-discovering tools in [${this.toolsDirs.join(", ")}]...`);
36325
+ this.discoveredTools = await discoverToolPaths(this.toolsDirs);
36326
+ this.discoveredPrefixes = new Set(this.discoveredTools.map((d) => d.commandPrefix));
36327
+ logger17.debug(`After install, discovered: [${this.discoveredTools.map((d) => d.commandPrefix).join(", ") || "none"}]`);
36328
+ }
34150
36329
  }
34151
36330
  var init_tool_manager = __esm(() => {
34152
36331
  init_toolLoader();
34153
36332
  init_toolService();
34154
36333
  });
34155
36334
 
34156
- // src/telemetry-events.ts
34157
- var CliTelemetryEvents;
34158
- var init_telemetry_events = __esm(() => {
34159
- CliTelemetryEvents = {
34160
- Help: "uip.help",
34161
- Version: "uip.version"
36335
+ // src/utils/autoInstall.ts
36336
+ import { catchError as catchError17, logger as logger18, OutputFormatter as OutputFormatter12 } from "@uipath/common";
36337
+ async function autoInstallToolIfNeeded(args, program, toolManager, context) {
36338
+ if (context.capabilities.isBrowser)
36339
+ return false;
36340
+ const OPTS_WITH_VALUES = new Set(program.options.filter((o) => o.required || o.optional).flatMap((o) => [o.short, o.long].filter(Boolean)));
36341
+ let requestedVerb;
36342
+ const cliArgs = args.slice(2);
36343
+ for (let i2 = 0;i2 < cliArgs.length; i2++) {
36344
+ const a = cliArgs[i2];
36345
+ if (OPTS_WITH_VALUES.has(a)) {
36346
+ i2++;
36347
+ continue;
36348
+ }
36349
+ if (a.startsWith("-"))
36350
+ continue;
36351
+ if (WHITELIST_BY_COMMAND.has(a))
36352
+ requestedVerb = a;
36353
+ break;
36354
+ }
36355
+ if (requestedVerb && !toolManager.isInstalled(requestedVerb)) {
36356
+ logger18.debug(`Tool '${requestedVerb}' not installed — attempting auto-install`);
36357
+ const [error48] = await catchError17(toolManager.ensureAvailable(requestedVerb));
36358
+ if (error48) {
36359
+ OutputFormatter12.error({
36360
+ Result: "Failure",
36361
+ Message: `Failed to auto-install '${requestedVerb}': ${error48.message}`,
36362
+ Instructions: `Run 'uip tools install ${requestedVerb}' to install manually.`
36363
+ });
36364
+ context.exit(1);
36365
+ return false;
36366
+ }
36367
+ return true;
36368
+ }
36369
+ return false;
36370
+ }
36371
+ var init_autoInstall = __esm(() => {
36372
+ init_toolService();
36373
+ });
36374
+
36375
+ // src/utils/globalOptions.ts
36376
+ import {
36377
+ getOutputSink as getOutputSink2
36378
+ } from "@uipath/common";
36379
+ function stripGlobalOptions(args) {
36380
+ const cleaned = [];
36381
+ let format;
36382
+ let filter;
36383
+ let logLevel;
36384
+ let logFile;
36385
+ for (let i2 = 0;i2 < args.length; i2++) {
36386
+ if (args[i2] === "--output-filter" && i2 + 1 < args.length) {
36387
+ filter = args[i2 + 1];
36388
+ i2++;
36389
+ continue;
36390
+ }
36391
+ if (args[i2]?.startsWith("--output-filter=")) {
36392
+ filter = args[i2].substring("--output-filter=".length);
36393
+ continue;
36394
+ }
36395
+ if (args[i2] === "--output" && i2 + 1 < args.length) {
36396
+ const v = args[i2 + 1];
36397
+ if (VALID_FORMATS.includes(v)) {
36398
+ format = v;
36399
+ i2++;
36400
+ continue;
36401
+ }
36402
+ }
36403
+ if (args[i2]?.startsWith("--output=")) {
36404
+ const v = args[i2].substring("--output=".length);
36405
+ if (VALID_FORMATS.includes(v)) {
36406
+ format = v;
36407
+ continue;
36408
+ }
36409
+ }
36410
+ if (args[i2] === "--log-level" && i2 + 1 < args.length) {
36411
+ const parsed = VALID_LOG_LEVELS[args[i2 + 1].toLowerCase()];
36412
+ if (parsed !== undefined) {
36413
+ logLevel = parsed;
36414
+ }
36415
+ i2++;
36416
+ continue;
36417
+ }
36418
+ if (args[i2]?.startsWith("--log-level=")) {
36419
+ const parsed = VALID_LOG_LEVELS[args[i2].substring("--log-level=".length).toLowerCase()];
36420
+ if (parsed !== undefined) {
36421
+ logLevel = parsed;
36422
+ }
36423
+ continue;
36424
+ }
36425
+ if (args[i2] === "--log-file" && i2 + 1 < args.length) {
36426
+ logFile = args[i2 + 1];
36427
+ i2++;
36428
+ continue;
36429
+ }
36430
+ if (args[i2]?.startsWith("--log-file=")) {
36431
+ logFile = args[i2].substring("--log-file=".length);
36432
+ continue;
36433
+ }
36434
+ cleaned.push(args[i2]);
36435
+ }
36436
+ const resolvedFormat = format ?? (getOutputSink2().capabilities.isInteractive ? "table" : "json");
36437
+ return { args: cleaned, format: resolvedFormat, filter, logLevel, logFile };
36438
+ }
36439
+ var VALID_FORMATS, VALID_LOG_LEVELS;
36440
+ var init_globalOptions = __esm(() => {
36441
+ VALID_FORMATS = ["table", "json", "yaml", "plain"];
36442
+ VALID_LOG_LEVELS = {
36443
+ debug: 0,
36444
+ info: 1,
36445
+ warn: 2,
36446
+ error: 3
34162
36447
  };
34163
36448
  });
34164
36449
 
@@ -34166,16 +36451,247 @@ var init_telemetry_events = __esm(() => {
34166
36451
  import {
34167
36452
  extractCommandHelp,
34168
36453
  getOutputFormat,
34169
- OutputFormatter as OutputFormatter12
36454
+ getOutputSink as getOutputSink3,
36455
+ OutputFormatter as OutputFormatter13
34170
36456
  } from "@uipath/common";
34171
- import { Help } from "commander";
36457
+ function getCommandPath(cmd) {
36458
+ const names = [];
36459
+ let current = cmd;
36460
+ while (current) {
36461
+ const name = current.name();
36462
+ if (name) {
36463
+ names.unshift(name);
36464
+ }
36465
+ current = current.parent ?? null;
36466
+ }
36467
+ return names.join(" ");
36468
+ }
36469
+ function isRootCommand(cmd) {
36470
+ return !cmd.parent;
36471
+ }
36472
+ function getHelpWidth() {
36473
+ const width = getOutputSink3().capabilities.outputWidth;
36474
+ if (!Number.isFinite(width) || width <= 0) {
36475
+ return 80;
36476
+ }
36477
+ return width < 56 ? width : Math.min(width, 120);
36478
+ }
36479
+ function centerText(text, width) {
36480
+ if (text.length >= width) {
36481
+ return text;
36482
+ }
36483
+ const left = Math.floor((width - text.length) / 2);
36484
+ const right = width - text.length - left;
36485
+ return `${" ".repeat(left)}${text}${" ".repeat(right)}`;
36486
+ }
36487
+ function wrapText(text, width) {
36488
+ if (width <= 0) {
36489
+ return [text];
36490
+ }
36491
+ const trimmed = text.trim();
36492
+ if (trimmed.length === 0) {
36493
+ return [""];
36494
+ }
36495
+ const words = trimmed.split(/\s+/);
36496
+ const lines = [];
36497
+ let current = "";
36498
+ for (const word of words) {
36499
+ if (current.length === 0) {
36500
+ if (word.length <= width) {
36501
+ current = word;
36502
+ continue;
36503
+ }
36504
+ for (let index = 0;index < word.length; index += width) {
36505
+ lines.push(word.slice(index, index + width));
36506
+ }
36507
+ continue;
36508
+ }
36509
+ if (current.length + word.length + 1 <= width) {
36510
+ current = `${current} ${word}`;
36511
+ continue;
36512
+ }
36513
+ lines.push(current);
36514
+ current = "";
36515
+ if (word.length <= width) {
36516
+ current = word;
36517
+ continue;
36518
+ }
36519
+ for (let index = 0;index < word.length; index += width) {
36520
+ const chunk = word.slice(index, index + width);
36521
+ if (chunk.length === width || index + width < word.length) {
36522
+ lines.push(chunk);
36523
+ } else {
36524
+ current = chunk;
36525
+ }
36526
+ }
36527
+ }
36528
+ if (current.length > 0) {
36529
+ lines.push(current);
36530
+ }
36531
+ return lines.length > 0 ? lines : [""];
36532
+ }
36533
+ function summarizeDescription(description) {
36534
+ const [firstLine = ""] = description.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
36535
+ return firstLine || "No description";
36536
+ }
36537
+ function renderRows(rows, contentWidth) {
36538
+ if (rows.length === 0) {
36539
+ return [];
36540
+ }
36541
+ const longestLabel = Math.max(...rows.map((row) => row.Label.length));
36542
+ const maxLabelWidth = Math.max(contentWidth - 3 - 12, 1);
36543
+ const labelWidth = Math.min(longestLabel, Math.max(18, Math.floor(contentWidth * 0.38)), maxLabelWidth);
36544
+ const descriptionWidth = Math.max(contentWidth - labelWidth - 3, 1);
36545
+ const lines = [];
36546
+ for (const row of rows) {
36547
+ const labelLines = wrapText(row.Label, labelWidth);
36548
+ const descriptionLines = wrapText(row.Description, descriptionWidth);
36549
+ const rowHeight = Math.max(labelLines.length, descriptionLines.length);
36550
+ for (let index = 0;index < rowHeight; index++) {
36551
+ const label = (labelLines[index] ?? "").padEnd(labelWidth);
36552
+ const description = descriptionLines[index] ?? "";
36553
+ lines.push(`${label} ${description}`);
36554
+ }
36555
+ }
36556
+ return lines;
36557
+ }
36558
+ function renderSection(section, width) {
36559
+ const contentWidth = Math.max(width - 4, 16);
36560
+ const title = ` ${section.Title} `;
36561
+ const ruleWidth = Math.max(width - title.length - 3, 0);
36562
+ const top = `┌─${title}${"─".repeat(ruleWidth)}┐`;
36563
+ const body = section.Lines.map((line) => `│ ${line.padEnd(contentWidth)} │`);
36564
+ const bottom = `└${"─".repeat(width - 2)}┘`;
36565
+ return [top, ...body, bottom].join(`
36566
+ `);
36567
+ }
36568
+ function renderBanner(description, cmd) {
36569
+ const title = description || "UiPath CLI";
36570
+ const tagline = "Build automations, agents, and orchestrations from your terminal.";
36571
+ const rootName = getCommandPath(cmd);
36572
+ const usage = [
36573
+ `${rootName} <command> [options]`,
36574
+ `${rootName} <tool> <command> [options]`
36575
+ ];
36576
+ return [
36577
+ ` ${title}`,
36578
+ ` ${tagline}`,
36579
+ "",
36580
+ ` Usage: ${usage[0]}`,
36581
+ ` ${usage[1]}`
36582
+ ].join(`
36583
+ `);
36584
+ }
36585
+ function renderCommandHeader(commandPath, description, width) {
36586
+ const lines = [centerText(commandPath, width)];
36587
+ if (description) {
36588
+ lines.push(centerText(description, width));
36589
+ }
36590
+ lines.push(centerText("Use --help with nested commands for more detail.", width));
36591
+ return lines.join(`
36592
+ `);
36593
+ }
36594
+ function buildUsageLines(cmd, helper) {
36595
+ return [helper.commandUsage(cmd)];
36596
+ }
36597
+ function sortByLabel(rows) {
36598
+ return [...rows].sort((a, b) => a.Label.localeCompare(b.Label));
36599
+ }
36600
+ function buildTableHelpSections(cmd, helper) {
36601
+ const contentWidth = Math.max(getHelpWidth() - 4, 16);
36602
+ const baseHelp = extractCommandHelp(cmd, helper);
36603
+ const sections = [];
36604
+ if (!isRootCommand(cmd)) {
36605
+ sections.push({
36606
+ Title: "Usage",
36607
+ Lines: buildUsageLines(cmd, helper)
36608
+ });
36609
+ }
36610
+ if (baseHelp.Arguments.length > 0) {
36611
+ sections.push({
36612
+ Title: "Arguments",
36613
+ Lines: renderRows(baseHelp.Arguments.map((argument) => ({
36614
+ Label: argument.Name,
36615
+ Description: argument.Description || "No description"
36616
+ })), contentWidth)
36617
+ });
36618
+ }
36619
+ const subcommands = helper.visibleCommands(cmd).map((subcommand) => ({
36620
+ Key: subcommand.name(),
36621
+ Label: subcommand.name(),
36622
+ Description: summarizeDescription(helper.subcommandDescription(subcommand) || "")
36623
+ }));
36624
+ if (isRootCommand(cmd)) {
36625
+ const builtIns = subcommands.filter((subcommand) => BUILT_IN_ROOT_COMMANDS.has(subcommand.Key) && subcommand.Key !== "help");
36626
+ const tools = subcommands.filter((subcommand) => !BUILT_IN_ROOT_COMMANDS.has(subcommand.Key));
36627
+ if (builtIns.length > 0) {
36628
+ sections.push({
36629
+ Title: "Commands",
36630
+ Lines: renderRows(sortByLabel(builtIns.map(({ Label, Description }) => ({
36631
+ Label,
36632
+ Description
36633
+ }))), contentWidth)
36634
+ });
36635
+ }
36636
+ if (tools.length > 0) {
36637
+ sections.push({
36638
+ Title: "Installed Tools",
36639
+ Lines: renderRows(sortByLabel(tools.map(({ Label, Description }) => ({
36640
+ Label,
36641
+ Description
36642
+ }))), contentWidth)
36643
+ });
36644
+ }
36645
+ } else if (subcommands.length > 0) {
36646
+ sections.push({
36647
+ Title: "Commands",
36648
+ Lines: renderRows(sortByLabel(subcommands.map(({ Label, Description }) => ({
36649
+ Label,
36650
+ Description
36651
+ }))), contentWidth)
36652
+ });
36653
+ }
36654
+ const allOptions = [
36655
+ ...baseHelp.Options.map((option) => ({
36656
+ Label: option.Flags,
36657
+ Description: option.Description || "No description"
36658
+ })),
36659
+ ...GLOBAL_OPTIONS.map((option) => ({
36660
+ Label: option.Flags,
36661
+ Description: option.Description
36662
+ }))
36663
+ ];
36664
+ if (allOptions.length > 0) {
36665
+ sections.push({
36666
+ Title: "Options",
36667
+ Lines: renderRows(allOptions, contentWidth)
36668
+ });
36669
+ }
36670
+ return sections;
36671
+ }
36672
+ function renderTableHelp(cmd, helper) {
36673
+ const width = getHelpWidth();
36674
+ const description = helper.commandDescription(cmd);
36675
+ const parts = [];
36676
+ if (isRootCommand(cmd)) {
36677
+ parts.push(renderBanner(description, cmd));
36678
+ } else {
36679
+ parts.push(renderCommandHeader(getCommandPath(cmd), description, width));
36680
+ }
36681
+ for (const section of buildTableHelpSections(cmd, helper)) {
36682
+ parts.push(renderSection(section, width));
36683
+ }
36684
+ return parts.join(`
36685
+
36686
+ `) + `
36687
+ `;
36688
+ }
34172
36689
  function createHelpConfiguration(isBrowser2) {
34173
- const originalFormatHelp = Help.prototype.formatHelp;
34174
36690
  const config2 = {
34175
36691
  formatHelp(cmd, helper) {
34176
36692
  const format = getOutputFormat();
34177
36693
  if (format === "table") {
34178
- return originalFormatHelp.call(this, cmd, helper);
36694
+ return renderTableHelp(cmd, helper);
34179
36695
  }
34180
36696
  const baseHelp = extractCommandHelp(cmd, helper);
34181
36697
  const subcommands = helper.visibleCommands(cmd).map((sub) => ({
@@ -34192,7 +36708,7 @@ function createHelpConfiguration(isBrowser2) {
34192
36708
  Code: "Help",
34193
36709
  Data: helpData
34194
36710
  };
34195
- return OutputFormatter12.formatToString(output);
36711
+ return OutputFormatter13.formatToString(output);
34196
36712
  }
34197
36713
  };
34198
36714
  if (isBrowser2) {
@@ -34208,7 +36724,7 @@ function createHelpConfiguration(isBrowser2) {
34208
36724
  }
34209
36725
  return config2;
34210
36726
  }
34211
- var GLOBAL_OPTIONS;
36727
+ var GLOBAL_OPTIONS, BUILT_IN_ROOT_COMMANDS;
34212
36728
  var init_helpFormatter = __esm(() => {
34213
36729
  GLOBAL_OPTIONS = [
34214
36730
  {
@@ -34228,6 +36744,136 @@ var init_helpFormatter = __esm(() => {
34228
36744
  Description: "Write logs to file instead of stderr"
34229
36745
  }
34230
36746
  ];
36747
+ BUILT_IN_ROOT_COMMANDS = new Set([
36748
+ "help",
36749
+ "login",
36750
+ "logout",
36751
+ "mcp",
36752
+ "skills",
36753
+ "tools"
36754
+ ]);
36755
+ });
36756
+
36757
+ // src/telemetry-events.ts
36758
+ var CliTelemetryEvents;
36759
+ var init_telemetry_events = __esm(() => {
36760
+ CliTelemetryEvents = {
36761
+ Help: "uip.help",
36762
+ Version: "uip.version"
36763
+ };
36764
+ });
36765
+
36766
+ // src/utils/parseError.ts
36767
+ import {
36768
+ OutputFormatter as OutputFormatter14,
36769
+ telemetry,
36770
+ telemetryFlushAndShutdown
36771
+ } from "@uipath/common";
36772
+ async function handleParseError(error48, cleanedArgs, context) {
36773
+ const isObj = error48 !== null && typeof error48 === "object";
36774
+ const e = isObj ? error48 : {};
36775
+ const code = typeof e.code === "string" ? e.code : undefined;
36776
+ const message = typeof e.message === "string" ? e.message : String(error48);
36777
+ const exitCode = typeof e.exitCode === "number" ? e.exitCode : undefined;
36778
+ if (code?.startsWith("commander.")) {
36779
+ if (code === "commander.helpDisplayed" || code === "commander.version" || message === "(outputHelp)") {
36780
+ const eventName = code === "commander.version" ? CliTelemetryEvents.Version : CliTelemetryEvents.Help;
36781
+ const command = cleanedArgs.slice(2).filter((a) => !a.startsWith("-")).join(" ") || "root";
36782
+ telemetry.trackEvent(eventName, { command });
36783
+ await telemetryFlushAndShutdown();
36784
+ context.exit(exitCode ?? 0);
36785
+ return;
36786
+ }
36787
+ OutputFormatter14.error({
36788
+ Result: "ValidationError",
36789
+ Message: message,
36790
+ Instructions: "Check command arguments and options. Use --help for usage information."
36791
+ });
36792
+ await telemetryFlushAndShutdown();
36793
+ context.exit(exitCode ?? 1);
36794
+ return;
36795
+ }
36796
+ await telemetryFlushAndShutdown();
36797
+ context.exit(1);
36798
+ }
36799
+ var init_parseError = __esm(() => {
36800
+ init_telemetry_events();
36801
+ });
36802
+
36803
+ // src/utils/registerToolCommands.ts
36804
+ import { catchError as catchError18, logger as logger19, OutputFormatter as OutputFormatter15 } from "@uipath/common";
36805
+ function registerLazyToolCommands(program, discovered, context) {
36806
+ logger19.debug("Registering lazy tool commands...");
36807
+ for (const entry of discovered) {
36808
+ logger19.debug(`Registering lazy command for tool '${entry.toolName}' (prefix: ${entry.commandPrefix})`);
36809
+ const toolCommand = program.command(entry.commandPrefix).description(entry.description).allowUnknownOption().allowExcessArguments(true).helpOption(false);
36810
+ toolCommand.action(async () => {
36811
+ logger19.debug(`Lazy-loading tool '${entry.toolName}' on first use...`);
36812
+ const tool = await importTool(entry);
36813
+ if (!tool) {
36814
+ OutputFormatter15.error({
36815
+ Result: "Failure",
36816
+ Message: `Failed to load tool '${entry.toolName}'.`,
36817
+ Instructions: `Try reinstalling with 'uip tools install ${entry.commandPrefix}'.`
36818
+ });
36819
+ context.exit(1);
36820
+ return;
36821
+ }
36822
+ const idx = program.commands.indexOf(toolCommand);
36823
+ if (idx >= 0) {
36824
+ program.commands.splice(idx, 1);
36825
+ }
36826
+ const realCommand = program.command(tool.metadata.commandPrefix).description(tool.metadata.description);
36827
+ const [regError] = await catchError18(tool.registerCommands(realCommand));
36828
+ if (regError) {
36829
+ OutputFormatter15.error({
36830
+ Result: "Failure",
36831
+ Message: `Failed to register commands from tool '${tool.metadata.name}': ${regError.message}`,
36832
+ Instructions: "This might be due to a command name conflict with existing commands."
36833
+ });
36834
+ context.exit(1);
36835
+ return;
36836
+ }
36837
+ await program.parseAsync(context.args);
36838
+ });
36839
+ }
36840
+ }
36841
+ var init_registerToolCommands = __esm(() => {
36842
+ init_toolLoader();
36843
+ });
36844
+
36845
+ // src/utils/resolveToolsDirectories.ts
36846
+ import { fileURLToPath } from "node:url";
36847
+ import { logger as logger20 } from "@uipath/common";
36848
+ import { getFileSystem as getFileSystem16 } from "@uipath/filesystem";
36849
+ async function resolveToolsDirectories(context) {
36850
+ if (context.capabilities.isBrowser) {
36851
+ logger20.debug("Browser mode — tools directory: /tools");
36852
+ return { toolsDirs: ["/tools"], toolsDir: "/tools" };
36853
+ }
36854
+ const currentFilePath = fileURLToPath(import.meta.url);
36855
+ const fs = getFileSystem16();
36856
+ const toolsDirs = await resolveToolsDirs(currentFilePath, fs.env.cwd());
36857
+ const toolsDir = toolsDirs[0];
36858
+ if (toolsDirs.length > 0) {
36859
+ return { toolsDirs, toolsDir };
36860
+ }
36861
+ logger20.warn("Unable to determine tools directory. Please ensure the CLI is installed correctly.");
36862
+ const { dirname, join } = fs.path;
36863
+ const isInstalledPackage = process.execPath.includes(join("@uipath", "cli", "dist", "uip"));
36864
+ if (isInstalledPackage) {
36865
+ const execDir = dirname(process.execPath);
36866
+ const packageDir = dirname(execDir);
36867
+ const fallbackDir2 = dirname(packageDir);
36868
+ logger20.debug(`Fallback (installed package): ${fallbackDir2}`);
36869
+ return { toolsDirs: [fallbackDir2], toolsDir: fallbackDir2 };
36870
+ }
36871
+ const fallbackDir = join(dirname(currentFilePath), "..");
36872
+ logger20.debug(`Fallback (development mode): ${fallbackDir}`);
36873
+ return { toolsDirs: [fallbackDir], toolsDir: fallbackDir };
36874
+ }
36875
+ var init_resolveToolsDirectories = __esm(() => {
36876
+ init_toolLoader();
34231
36877
  });
34232
36878
 
34233
36879
  // cli.ts
@@ -34235,20 +36881,16 @@ var exports_cli = {};
34235
36881
  __export(exports_cli, {
34236
36882
  run: () => run
34237
36883
  });
34238
- import { fileURLToPath } from "node:url";
34239
36884
  import {
36885
+ catchError as catchError19,
34240
36886
  configureLogger,
34241
- DEFAULT_LOG_LEVEL,
34242
- getOutputFormat as getOutputFormat2,
34243
- getOutputSink as getOutputSink2,
34244
36887
  LogLevel,
34245
- OutputFormatter as OutputFormatter13,
36888
+ logger as logger21,
34246
36889
  registerHelpAll,
34247
36890
  setOutputFilter,
34248
36891
  setOutputFormat,
34249
- setToolProvider,
34250
- telemetry,
34251
- telemetryFlushAndShutdown,
36892
+ setPackagerFactoryProvider,
36893
+ telemetryFlushAndShutdown as telemetryFlushAndShutdown2,
34252
36894
  telemetryInit
34253
36895
  } from "@uipath/common";
34254
36896
  import { Command as Command2 } from "commander";
@@ -34269,13 +36911,14 @@ async function buildProgram(context) {
34269
36911
  logLevel,
34270
36912
  logFile
34271
36913
  } = stripGlobalOptions(context.args);
36914
+ context.args = cleanedArgs;
34272
36915
  setOutputFormat(helpFormat);
34273
36916
  setOutputFilter(filter);
34274
36917
  configureLogger({
34275
36918
  ...logLevel !== undefined && { level: logLevel },
34276
36919
  ...logFile !== undefined && { logFile }
34277
36920
  });
34278
- await telemetryInit({ uip_version: package_default.version });
36921
+ logger21.debug(`CLI v${package_default.version} starting — output=${helpFormat}, logLevel=${logLevel !== undefined ? LogLevel[logLevel].toLowerCase() : "default"}, logFile=${logFile ?? "none"}`);
34279
36922
  program.exitOverride();
34280
36923
  program.configureOutput({
34281
36924
  writeOut: context.output.writeOut,
@@ -34285,280 +36928,75 @@ async function buildProgram(context) {
34285
36928
  getErrHelpWidth: context.output.getOutputWidth
34286
36929
  });
34287
36930
  program.configureHelp(createHelpConfiguration(context.capabilities.isBrowser));
34288
- program.addHelpText("after", () => {
34289
- if (getOutputFormat2() !== "table")
34290
- return "";
34291
- return `
34292
- Global Options:
34293
- ` + ` --output <table|json|yaml|plain> Output format (default: table for interactive, json otherwise)
34294
- ` + ` --output-filter <expression> JMESPath expression to filter output
34295
- ` + ` --log-level <debug|info|warn|error> Log level threshold (default: ${LogLevel[DEFAULT_LOG_LEVEL].toLowerCase()})
34296
- ` + " --log-file <path> Write logs to file instead of stderr";
34297
- });
34298
- try {
34299
- await storage.init();
34300
- } catch (error48) {
34301
- if (context.capabilities.isBrowser) {
34302
- context.output.writeErr(`Storage initialization failed: ${errorMessage(error48)}`);
36931
+ const storageAndToolsDirsPromise = (async () => {
36932
+ logger21.debug("Initializing storage...");
36933
+ const [storageError] = await catchError19(storage.init());
36934
+ if (storageError) {
36935
+ if (context.capabilities.isBrowser) {
36936
+ context.output.writeErr(`Storage initialization failed: ${errorMessage(storageError)}`);
36937
+ } else {
36938
+ throw storageError;
36939
+ }
34303
36940
  } else {
34304
- throw error48;
36941
+ logger21.debug("Storage initialized");
34305
36942
  }
34306
- }
36943
+ logger21.debug("Resolving tool directories...");
36944
+ const result = await resolveToolsDirectories(context);
36945
+ logger21.debug(`Resolved ${result.toolsDirs.length} tool directories: ${result.toolsDirs.join(", ") || "(none)"}`);
36946
+ return result;
36947
+ })();
36948
+ const [, { toolsDirs, toolsDir }] = await Promise.all([
36949
+ telemetryInit({ uip_version: package_default.version }).then(() => logger21.debug("Telemetry initialized")).catch((err) => logger21.warn(`Telemetry init failed (non-fatal): ${errorMessage(err)}`)),
36950
+ storageAndToolsDirsPromise
36951
+ ]);
36952
+ logger21.debug("Registering login/logout commands");
34307
36953
  registerLoginCommand(program, context);
34308
36954
  registerLogoutCommand(program, context);
34309
- let toolsDirs = [];
34310
- let toolsDir;
34311
- if (context.capabilities.isBrowser) {
34312
- toolsDir = "/tools";
34313
- toolsDirs = [toolsDir];
34314
- } else {
34315
- const { getFileSystem: getFileSystem13 } = await import("@uipath/filesystem");
34316
- const fs = getFileSystem13();
34317
- const { dirname, join } = fs.path;
34318
- const currentFilePath = fileURLToPath(import.meta.url);
34319
- let searchPath = dirname(currentFilePath);
34320
- const seen = new Set;
34321
- for (let i2 = 0;i2 < 10; i2++) {
34322
- const nodeModulesPath = join(searchPath, "node_modules", "@uipath");
34323
- try {
34324
- if (await fs.exists(nodeModulesPath)) {
34325
- if (!seen.has(nodeModulesPath)) {
34326
- seen.add(nodeModulesPath);
34327
- toolsDirs.push(nodeModulesPath);
34328
- }
34329
- }
34330
- } catch (_e) {}
34331
- const parentPath = dirname(searchPath);
34332
- if (parentPath === searchPath) {
34333
- break;
34334
- }
34335
- searchPath = parentPath;
34336
- }
34337
- searchPath = process.cwd();
34338
- for (let i2 = 0;i2 < 10; i2++) {
34339
- const nodeModulesPath = join(searchPath, "node_modules", "@uipath");
34340
- try {
34341
- if (!seen.has(nodeModulesPath) && await fs.exists(nodeModulesPath)) {
34342
- seen.add(nodeModulesPath);
34343
- toolsDirs.push(nodeModulesPath);
34344
- }
34345
- } catch (_e) {}
34346
- const parentPath = dirname(searchPath);
34347
- if (parentPath === searchPath)
34348
- break;
34349
- searchPath = parentPath;
34350
- }
34351
- toolsDir = toolsDirs[0];
34352
- if (toolsDirs.length === 0) {
34353
- context.output.writeErr(`Unable to determine tools directory. Please ensure the CLI is installed correctly.
34354
- `);
34355
- const isInstalledPackage = process.execPath.includes(join("@uipath", "cli", "dist", "uip"));
34356
- if (isInstalledPackage) {
34357
- const execDir = dirname(process.execPath);
34358
- const packageDir = dirname(execDir);
34359
- toolsDir = dirname(packageDir);
34360
- toolsDirs = [toolsDir];
34361
- } else {
34362
- const currentFileUrl = import.meta.url;
34363
- const currentFilePath2 = fileURLToPath(currentFileUrl);
34364
- toolsDir = join(dirname(currentFilePath2), "..");
34365
- toolsDirs = [toolsDir];
34366
- }
34367
- }
34368
- }
34369
- async function resolveInstallPath(packageName) {
34370
- if (context.capabilities.isBrowser) {
34371
- const path3 = packageName ? `/tools/${packageName.replace(/[/@]/g, "_")}` : "/tools";
34372
- return { path: path3, global: false };
34373
- }
34374
- const { getFileSystem: getFileSystem13 } = await import("@uipath/filesystem");
34375
- const fsLocal = getFileSystem13();
34376
- const { dirname: dirnameFn, join: joinFn } = fsLocal.path;
34377
- const { existsSync } = await import("node:fs");
34378
- if (toolsDir) {
34379
- const path3 = dirnameFn(dirnameFn(toolsDir));
34380
- let isGlobal = true;
34381
- const pkgJsonPath = joinFn(path3, "package.json");
34382
- if (existsSync(pkgJsonPath)) {
34383
- try {
34384
- const { readFileSync } = await import("node:fs");
34385
- const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
34386
- const deps = {
34387
- ...pkgJson.dependencies,
34388
- ...pkgJson.devDependencies
34389
- };
34390
- if (deps && "@uipath/cli" in deps) {
34391
- isGlobal = false;
34392
- }
34393
- } catch {}
34394
- }
34395
- return { path: path3, global: isGlobal };
34396
- }
34397
- let searchDir = process.cwd();
34398
- for (let i2 = 0;i2 < 10; i2++) {
34399
- const nodeModulesPath = joinFn(searchDir, "node_modules");
34400
- try {
34401
- if (await fsLocal.exists(nodeModulesPath)) {
34402
- return { path: searchDir, global: false };
34403
- }
34404
- } catch (_e) {}
34405
- const parentDir = dirnameFn(searchDir);
34406
- if (parentDir === searchDir)
34407
- break;
34408
- searchDir = parentDir;
34409
- }
34410
- throw new Error("Unable to determine install location. No node_modules found in parent directories.");
34411
- }
34412
- const initialTools = await discoverTools(toolsDirs);
34413
- const toolManager = new ToolManager(initialTools, toolsDirs, resolveInstallPath, getCliVersionPrefix());
34414
- setToolProvider((verb) => toolManager.ensureAvailable(verb));
34415
- if (!context.capabilities.isBrowser && toolsDir) {
34416
- const OPTS_WITH_VALUES = new Set(program.options.filter((o) => o.required || o.optional).flatMap((o) => [o.short, o.long].filter(Boolean)));
34417
- let requestedVerb;
34418
- const cliArgs = context.args.slice(2);
34419
- for (let i2 = 0;i2 < cliArgs.length; i2++) {
34420
- const a = cliArgs[i2];
34421
- if (OPTS_WITH_VALUES.has(a)) {
34422
- i2++;
34423
- continue;
34424
- }
34425
- if (a.startsWith("-"))
34426
- continue;
34427
- if (WHITELIST_BY_COMMAND.has(a))
34428
- requestedVerb = a;
34429
- break;
34430
- }
34431
- if (requestedVerb && !toolManager.isInstalled(requestedVerb)) {
34432
- try {
34433
- await toolManager.ensureAvailable(requestedVerb);
34434
- } catch (error48) {
34435
- OutputFormatter13.error({
34436
- Result: "Failure",
34437
- Message: `Failed to auto-install '${requestedVerb}': ${errorMessage(error48)}`,
34438
- Instructions: `Run 'uip tools install ${requestedVerb}' to install manually.`
34439
- });
34440
- context.exit(1);
34441
- }
34442
- }
34443
- }
34444
- for (const tool of toolManager.getTools()) {
34445
- try {
34446
- const toolCommand = program.command(tool.metadata.commandPrefix).description(tool.metadata.description);
34447
- await tool.registerCommands(toolCommand);
34448
- } catch (error48) {
34449
- context.output.writeErr(`❌ Failed to register commands from tool '${tool.metadata.name}': ${errorMessage(error48)}`);
34450
- context.output.writeErr(` This might be due to a command name conflict with existing commands.`);
34451
- context.exit(1);
34452
- }
34453
- }
36955
+ const resolveInstallPath = createInstallPathResolver(toolsDir, context.capabilities.isBrowser);
36956
+ logger21.debug("Discovering tool paths...");
36957
+ let discoveredTools = await discoverToolPaths(toolsDirs);
36958
+ logger21.debug(`Discovered ${discoveredTools.length} tools: ${discoveredTools.map((t) => t.commandPrefix).join(", ") || "(none)"}`);
36959
+ const toolManager = new ToolManager([], toolsDirs, resolveInstallPath, getCliVersionPrefix(), discoveredTools);
36960
+ setPackagerFactoryProvider((verb) => toolManager.ensurePackagerFactory(verb));
36961
+ if (toolsDir) {
36962
+ const installed = await autoInstallToolIfNeeded(context.args, program, toolManager, context);
36963
+ if (installed) {
36964
+ discoveredTools = await discoverToolPaths(toolsDirs);
36965
+ }
36966
+ }
36967
+ registerLazyToolCommands(program, discoveredTools, context);
34454
36968
  registerToolsCommand(program, context, {
34455
36969
  tools: toolManager.getTools(),
36970
+ discoveredTools,
34456
36971
  toolsDirs,
34457
36972
  resolveInstallPath,
34458
36973
  getCliVersionPrefix
34459
36974
  });
34460
36975
  if (!context.capabilities.isBrowser) {
36976
+ logger21.debug("Registering skills command");
34461
36977
  registerSkillsCommand(program);
34462
36978
  }
36979
+ logger21.debug("Registering MCP command");
34463
36980
  registerMcpCommand(program);
34464
36981
  registerHelpAll(program);
34465
36982
  for (const cmd of program.commands) {
34466
36983
  registerHelpAll(cmd);
34467
36984
  }
36985
+ logger21.debug("Program built successfully — ready to parse args");
34468
36986
  return { program, cleanedArgs };
34469
36987
  }
34470
- function stripGlobalOptions(args) {
34471
- const cleaned = [];
34472
- let format;
34473
- let filter;
34474
- let logLevel;
34475
- let logFile;
34476
- for (let i2 = 0;i2 < args.length; i2++) {
34477
- if (args[i2] === "--output-filter" && i2 + 1 < args.length) {
34478
- filter = args[i2 + 1];
34479
- i2++;
34480
- continue;
34481
- }
34482
- if (args[i2]?.startsWith("--output-filter=")) {
34483
- filter = args[i2].substring("--output-filter=".length);
34484
- continue;
34485
- }
34486
- if (args[i2] === "--output" && i2 + 1 < args.length) {
34487
- const v = args[i2 + 1];
34488
- if (VALID_FORMATS.includes(v)) {
34489
- format = v;
34490
- i2++;
34491
- continue;
34492
- }
34493
- }
34494
- if (args[i2]?.startsWith("--output=")) {
34495
- const v = args[i2].substring("--output=".length);
34496
- if (VALID_FORMATS.includes(v)) {
34497
- format = v;
34498
- continue;
34499
- }
34500
- }
34501
- if (args[i2] === "--log-level" && i2 + 1 < args.length) {
34502
- const parsed = VALID_LOG_LEVELS[args[i2 + 1].toLowerCase()];
34503
- if (parsed !== undefined) {
34504
- logLevel = parsed;
34505
- }
34506
- i2++;
34507
- continue;
34508
- }
34509
- if (args[i2]?.startsWith("--log-level=")) {
34510
- const parsed = VALID_LOG_LEVELS[args[i2].substring("--log-level=".length).toLowerCase()];
34511
- if (parsed !== undefined) {
34512
- logLevel = parsed;
34513
- }
34514
- continue;
34515
- }
34516
- if (args[i2] === "--log-file" && i2 + 1 < args.length) {
34517
- logFile = args[i2 + 1];
34518
- i2++;
34519
- continue;
34520
- }
34521
- if (args[i2]?.startsWith("--log-file=")) {
34522
- logFile = args[i2].substring("--log-file=".length);
34523
- continue;
34524
- }
34525
- cleaned.push(args[i2]);
34526
- }
34527
- const resolvedFormat = format ?? (getOutputSink2().capabilities.isInteractive ? "table" : "json");
34528
- return { args: cleaned, format: resolvedFormat, filter, logLevel, logFile };
34529
- }
34530
36988
  async function run(context) {
34531
36989
  const { program, cleanedArgs } = await buildProgram(context);
34532
- try {
34533
- await program.parseAsync(cleanedArgs);
34534
- } catch (error48) {
34535
- const e = error48;
34536
- if (e?.code?.startsWith("commander.")) {
34537
- if (e.code === "commander.helpDisplayed" || e.code === "commander.version" || e.message === "(outputHelp)") {
34538
- const eventName = e.code === "commander.version" ? CliTelemetryEvents.Version : CliTelemetryEvents.Help;
34539
- const command = cleanedArgs.slice(2).filter((a) => !a.startsWith("-")).join(" ") || "root";
34540
- telemetry.trackEvent(eventName, { command });
34541
- await telemetryFlushAndShutdown();
34542
- context.exit(e.exitCode ?? 0);
34543
- return;
34544
- }
34545
- OutputFormatter13.error({
34546
- Result: "ValidationError",
34547
- Message: e.message ?? String(error48),
34548
- Instructions: "Check command arguments and options. Use --help for usage information."
34549
- });
34550
- await telemetryFlushAndShutdown();
34551
- context.exit(e.exitCode ?? 1);
34552
- return;
34553
- }
34554
- await telemetryFlushAndShutdown();
34555
- context.exit(1);
36990
+ logger21.debug(`Parsing args: ${cleanedArgs.slice(2).join(" ")}`);
36991
+ const [parseError] = await catchError19(program.parseAsync(cleanedArgs));
36992
+ if (parseError) {
36993
+ await handleParseError(parseError, cleanedArgs, context);
34556
36994
  return;
34557
36995
  }
34558
- await telemetryFlushAndShutdown();
36996
+ logger21.debug("Command completed — flushing telemetry");
36997
+ await telemetryFlushAndShutdown2();
34559
36998
  context.exit(0);
34560
36999
  }
34561
- var VALID_FORMATS, VALID_LOG_LEVELS;
34562
37000
  var init_cli = __esm(() => {
34563
37001
  init_package();
34564
37002
  init_login();
@@ -34566,19 +37004,16 @@ var init_cli = __esm(() => {
34566
37004
  init_mcp2();
34567
37005
  init_skills();
34568
37006
  init_tools();
37007
+ init_installPath();
34569
37008
  init_storage();
34570
37009
  init_tool_manager();
34571
- init_toolService();
34572
- init_telemetry_events();
37010
+ init_autoInstall();
37011
+ init_globalOptions();
34573
37012
  init_helpFormatter();
37013
+ init_parseError();
37014
+ init_registerToolCommands();
37015
+ init_resolveToolsDirectories();
34574
37016
  init_toolLoader();
34575
- VALID_FORMATS = ["table", "json", "yaml", "plain"];
34576
- VALID_LOG_LEVELS = {
34577
- debug: 0,
34578
- info: 1,
34579
- warn: 2,
34580
- error: 3
34581
- };
34582
37017
  });
34583
37018
 
34584
37019
  // src/suppress-dep-warnings.ts
@@ -34593,7 +37028,12 @@ process.emitWarning = (...args) => {
34593
37028
 
34594
37029
  // index.ts
34595
37030
  init_cli();
34596
- import { configureLogger as configureLogger2 } from "@uipath/common";
37031
+ import {
37032
+ configureLogger as configureLogger2,
37033
+ createPollAbortController,
37034
+ installConsoleGuard,
37035
+ setProcessContextPollSignal
37036
+ } from "@uipath/common";
34597
37037
 
34598
37038
  // src/sinks/terminal-sink.ts
34599
37039
  class TerminalSink {
@@ -34613,7 +37053,7 @@ class TerminalSink {
34613
37053
  process.stderr.write(str2);
34614
37054
  }
34615
37055
  writeLog(str2) {
34616
- process.stdout.write(str2);
37056
+ process.stderr.write(str2);
34617
37057
  }
34618
37058
  static detectColor(isTTY) {
34619
37059
  if (process.env.NO_COLOR)
@@ -34627,6 +37067,9 @@ class TerminalSink {
34627
37067
  // index.ts
34628
37068
  import { fileURLToPath as fileURLToPath2 } from "node:url";
34629
37069
  configureLogger2({ sink: new TerminalSink });
37070
+ installConsoleGuard();
37071
+ var pollController = createPollAbortController();
37072
+ setProcessContextPollSignal(pollController.signal);
34630
37073
  var run2 = async (args) => {
34631
37074
  const context = {
34632
37075
  args,
@@ -34642,7 +37085,8 @@ var run2 = async (args) => {
34642
37085
  },
34643
37086
  capabilities: {
34644
37087
  isBrowser: false
34645
- }
37088
+ },
37089
+ pollSignal: pollController.signal
34646
37090
  };
34647
37091
  return run(context);
34648
37092
  };