@uipath/docsai-tool 0.1.8 → 0.1.10

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 (2) hide show
  1. package/dist/tool.js +35 -37
  2. package/package.json +6 -6
package/dist/tool.js CHANGED
@@ -4587,6 +4587,7 @@ var require_limitLength = __commonJS((exports) => {
4587
4587
  var require_pattern = __commonJS((exports) => {
4588
4588
  Object.defineProperty(exports, "__esModule", { value: true });
4589
4589
  var code_1 = require_code2();
4590
+ var util_1 = require_util();
4590
4591
  var codegen_1 = require_codegen();
4591
4592
  var error2 = {
4592
4593
  message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
@@ -4599,10 +4600,18 @@ var require_pattern = __commonJS((exports) => {
4599
4600
  $data: true,
4600
4601
  error: error2,
4601
4602
  code(cxt) {
4602
- const { data, $data, schema, schemaCode, it } = cxt;
4603
+ const { gen, data, $data, schema, schemaCode, it } = cxt;
4603
4604
  const u = it.opts.unicodeRegExp ? "u" : "";
4604
- const regExp = $data ? (0, codegen_1._)`(new RegExp(${schemaCode}, ${u}))` : (0, code_1.usePattern)(cxt, schema);
4605
- cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
4605
+ if ($data) {
4606
+ const { regExp } = it.opts.code;
4607
+ const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
4608
+ const valid = gen.let("valid");
4609
+ gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
4610
+ cxt.fail$data((0, codegen_1._)`!${valid}`);
4611
+ } else {
4612
+ const regExp = (0, code_1.usePattern)(cxt, schema);
4613
+ cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
4614
+ }
4606
4615
  }
4607
4616
  };
4608
4617
  exports.default = def;
@@ -6510,19 +6519,19 @@ var require_dist = __commonJS((exports, module) => {
6510
6519
  // package.json
6511
6520
  var package_default = {
6512
6521
  name: "@uipath/docsai-tool",
6513
- version: "0.1.8",
6522
+ version: "0.1.10",
6514
6523
  description: "Search UiPath documentation with AI-powered answers.",
6515
6524
  private: false,
6516
6525
  repository: {
6517
6526
  type: "git",
6518
- url: "https://github.com/UiPath/uipcli.git",
6527
+ url: "https://github.com/UiPath/cli.git",
6519
6528
  directory: "packages/docsai-tool"
6520
6529
  },
6521
6530
  publishConfig: {
6522
- registry: "https://registry.npmjs.org/"
6531
+ registry: "https://npm.pkg.github.com/@uipath"
6523
6532
  },
6524
6533
  keywords: [
6525
- "uipcli-tool"
6534
+ "cli-tool"
6526
6535
  ],
6527
6536
  type: "module",
6528
6537
  main: "./dist/tool.js",
@@ -6543,12 +6552,12 @@ var package_default = {
6543
6552
  },
6544
6553
  peerDependencies: {
6545
6554
  commander: "^14.0.3",
6546
- "@uipath/common": "^0.1.7",
6547
- "@uipath/auth": "^0.1.6"
6555
+ "@uipath/common": "^0.1.12",
6556
+ "@uipath/auth": "^0.1.9"
6548
6557
  },
6549
6558
  devDependencies: {
6550
6559
  "@modelcontextprotocol/sdk": "^1.26.0",
6551
- "@types/node": "^25.2.3",
6560
+ "@types/node": "^25.5.0",
6552
6561
  typescript: "^5"
6553
6562
  }
6554
6563
  };
@@ -6556,11 +6565,13 @@ var package_default = {
6556
6565
  // src/commands/ask.ts
6557
6566
  import {
6558
6567
  catchError,
6568
+ extractErrorMessageSync,
6559
6569
  getOutputFormat,
6560
6570
  getOutputSink,
6561
6571
  OutputFormatter,
6562
6572
  processContext
6563
6573
  } from "@uipath/common";
6574
+ import { Option } from "commander";
6564
6575
 
6565
6576
  // src/mcp-client.ts
6566
6577
  import { getLoginStatusAsync } from "@uipath/auth";
@@ -11622,7 +11633,7 @@ var AssertObjectSchema = custom((v) => v !== null && (typeof v === "object" || t
11622
11633
  var ProgressTokenSchema = union([string2(), number2().int()]);
11623
11634
  var CursorSchema = string2();
11624
11635
  var TaskCreationParamsSchema = looseObject({
11625
- ttl: union([number2(), _null3()]).optional(),
11636
+ ttl: number2().optional(),
11626
11637
  pollInterval: number2().optional()
11627
11638
  });
11628
11639
  var TaskMetadataSchema = object2({
@@ -11776,7 +11787,8 @@ var ClientCapabilitiesSchema = object2({
11776
11787
  roots: object2({
11777
11788
  listChanged: boolean2().optional()
11778
11789
  }).optional(),
11779
- tasks: ClientTasksCapabilitySchema.optional()
11790
+ tasks: ClientTasksCapabilitySchema.optional(),
11791
+ extensions: record(string2(), AssertObjectSchema).optional()
11780
11792
  });
11781
11793
  var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
11782
11794
  protocolVersion: string2(),
@@ -11801,7 +11813,8 @@ var ServerCapabilitiesSchema = object2({
11801
11813
  tools: object2({
11802
11814
  listChanged: boolean2().optional()
11803
11815
  }).optional(),
11804
- tasks: ServerTasksCapabilitySchema.optional()
11816
+ tasks: ServerTasksCapabilitySchema.optional(),
11817
+ extensions: record(string2(), AssertObjectSchema).optional()
11805
11818
  });
11806
11819
  var InitializeResultSchema = ResultSchema.extend({
11807
11820
  protocolVersion: string2(),
@@ -11917,6 +11930,7 @@ var ResourceSchema = object2({
11917
11930
  uri: string2(),
11918
11931
  description: optional(string2()),
11919
11932
  mimeType: optional(string2()),
11933
+ size: optional(number2()),
11920
11934
  annotations: AnnotationsSchema.optional(),
11921
11935
  _meta: optional(looseObject({}))
11922
11936
  });
@@ -15337,22 +15351,6 @@ async function createMcpClient(tenant) {
15337
15351
  return createDocsAIClient(client);
15338
15352
  }
15339
15353
 
15340
- // src/utils/error-handler.ts
15341
- function extractErrorMessage(error2) {
15342
- if (error2 instanceof Error) {
15343
- return error2.message;
15344
- }
15345
- if (typeof error2 === "object" && error2 !== null) {
15346
- if ("status" in error2 && error2.status === 401) {
15347
- return "Unauthorized. Run `uip login` to authenticate.";
15348
- }
15349
- if ("message" in error2 && typeof error2.message === "string") {
15350
- return error2.message;
15351
- }
15352
- }
15353
- return String(error2);
15354
- }
15355
-
15356
15354
  // src/commands/ask.ts
15357
15355
  function isDocsAISearchResponse(data) {
15358
15356
  return typeof data === "object" && data !== null && "text" in data && typeof data.text === "string" && "sources" in data && Array.isArray(data.sources);
@@ -15362,12 +15360,11 @@ function parseSearchResponse(content) {
15362
15360
  if (!textItem?.text) {
15363
15361
  return;
15364
15362
  }
15365
- try {
15366
- const parsed = JSON.parse(textItem.text);
15367
- return isDocsAISearchResponse(parsed) ? parsed : undefined;
15368
- } catch {
15363
+ const [error2, parsed] = catchError(() => JSON.parse(textItem.text));
15364
+ if (error2) {
15369
15365
  return;
15370
15366
  }
15367
+ return isDocsAISearchResponse(parsed) ? parsed : undefined;
15371
15368
  }
15372
15369
  function printReadableResponse(parsed) {
15373
15370
  const sink = getOutputSink();
@@ -15392,10 +15389,10 @@ function printReadableResponse(parsed) {
15392
15389
  write("");
15393
15390
  }
15394
15391
  var registerAskCommand = (program) => {
15395
- program.command("ask").description("Search UiPath documentation").argument("<query>", "The question to ask").option("-t, --tenant <tenant-name>", "Tenant (optional, defaults to value selected during auth)").trackedAction(processContext, async (query, options) => {
15392
+ program.command("ask").description("Search UiPath documentation").argument("<query>", "The question to ask").option("-t, --tenant <tenant-name>", "Tenant (optional, defaults to value selected during auth)").addOption(new Option("--source <source>", "Source to search: docs or technical_solution_articles").choices(["docs", "technical_solution_articles"]).default("docs")).trackedAction(processContext, async (query, options) => {
15396
15393
  const [clientError, client] = await catchError(createMcpClient(options.tenant));
15397
15394
  if (clientError) {
15398
- const errorMessage = extractErrorMessage(clientError);
15395
+ const errorMessage = extractErrorMessageSync(clientError);
15399
15396
  OutputFormatter.error({
15400
15397
  Result: "Failure",
15401
15398
  Message: "Error querying DocsAI",
@@ -15405,11 +15402,12 @@ var registerAskCommand = (program) => {
15405
15402
  return;
15406
15403
  }
15407
15404
  const [callError, result] = await catchError(client.callTool("SearchDocumentation", {
15408
- question: query
15405
+ question: query,
15406
+ sources: [options.source]
15409
15407
  }));
15410
15408
  await catchError(client.close());
15411
15409
  if (callError) {
15412
- const errorMessage = extractErrorMessage(callError);
15410
+ const errorMessage = extractErrorMessageSync(callError);
15413
15411
  OutputFormatter.error({
15414
15412
  Result: "Failure",
15415
15413
  Message: "Error querying DocsAI",
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@uipath/docsai-tool",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Search UiPath documentation with AI-powered answers.",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/UiPath/uipcli.git",
8
+ "url": "https://github.com/UiPath/cli.git",
9
9
  "directory": "packages/docsai-tool"
10
10
  },
11
11
  "publishConfig": {
12
12
  "registry": "https://registry.npmjs.org/"
13
13
  },
14
14
  "keywords": [
15
- "uipcli-tool"
15
+ "cli-tool"
16
16
  ],
17
17
  "type": "module",
18
18
  "main": "./dist/tool.js",
@@ -33,12 +33,12 @@
33
33
  },
34
34
  "peerDependencies": {
35
35
  "commander": "^14.0.3",
36
- "@uipath/common": "^0.1.7",
37
- "@uipath/auth": "^0.1.6"
36
+ "@uipath/common": "^0.1.12",
37
+ "@uipath/auth": "^0.1.9"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@modelcontextprotocol/sdk": "^1.26.0",
41
- "@types/node": "^25.2.3",
41
+ "@types/node": "^25.5.0",
42
42
  "typescript": "^5"
43
43
  }
44
44
  }