@uipath/docsai-tool 1.204.0-preview.216 → 1.204.0-preview.223

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.
@@ -5,13 +5,14 @@ compiled into its `dist/` output rather than installed alongside it.
5
5
  Their licences and copyright notices are reproduced here in full, as
6
6
  those licences require.
7
7
 
8
- 25 bundled dependencies:
8
+ 26 bundled dependencies:
9
9
 
10
- - @modelcontextprotocol/sdk@1.29.0 — MIT
10
+ - @modelcontextprotocol/sdk@1.32.0 — MIT
11
11
  - ajv@8.20.0 — MIT
12
12
  - ajv-formats@3.0.1 — MIT
13
13
  - bundle-name@4.1.0 — MIT
14
14
  - commander@14.0.3 — MIT
15
+ - content-type@1.0.5 — MIT
15
16
  - default-browser@5.5.0 — MIT
16
17
  - default-browser-id@5.0.1 — MIT
17
18
  - define-lazy-prop@3.0.0 — MIT
@@ -35,7 +36,7 @@ those licences require.
35
36
 
36
37
  ---
37
38
 
38
- ## @modelcontextprotocol/sdk@1.29.0
39
+ ## @modelcontextprotocol/sdk@1.32.0
39
40
 
40
41
  SPDX: MIT
41
42
 
@@ -174,6 +175,37 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
174
175
 
175
176
  ---
176
177
 
178
+ ## content-type@1.0.5
179
+
180
+ SPDX: MIT
181
+
182
+ ```
183
+ (The MIT License)
184
+
185
+ Copyright (c) 2015 Douglas Christopher Wilson
186
+
187
+ Permission is hereby granted, free of charge, to any person obtaining
188
+ a copy of this software and associated documentation files (the
189
+ 'Software'), to deal in the Software without restriction, including
190
+ without limitation the rights to use, copy, modify, merge, publish,
191
+ distribute, sublicense, and/or sell copies of the Software, and to
192
+ permit persons to whom the Software is furnished to do so, subject to
193
+ the following conditions:
194
+
195
+ The above copyright notice and this permission notice shall be
196
+ included in all copies or substantial portions of the Software.
197
+
198
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
199
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
200
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
201
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
202
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
203
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
204
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
205
+ ```
206
+
207
+ ---
208
+
177
209
  ## default-browser@5.5.0
178
210
 
179
211
  SPDX: MIT
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Command,
4
4
  metadata,
5
5
  registerCommands
6
- } from "./tool-3bjykajz.js";
6
+ } from "./tool-a3fbtxxb.js";
7
7
  import"./tool-1yh8g550.js";
8
8
 
9
9
  // src/index.ts
@@ -8984,12 +8984,118 @@ var require_dist = __commonJS(function(exports, module) {
8984
8984
  Object.defineProperty(exports, "__esModule", { value: true });
8985
8985
  exports.default = formatsPlugin;
8986
8986
  });
8987
+
8988
+ // ../../node_modules/content-type/index.js
8989
+ var require_content_type = __commonJS(function(exports) {
8990
+ /*!
8991
+ * content-type
8992
+ * Copyright(c) 2015 Douglas Christopher Wilson
8993
+ * MIT Licensed
8994
+ */
8995
+ var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
8996
+ var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
8997
+ var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
8998
+ var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
8999
+ var QUOTE_REGEXP = /([\\"])/g;
9000
+ var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
9001
+ exports.format = format;
9002
+ exports.parse = parse5;
9003
+ function format(obj) {
9004
+ if (!obj || typeof obj !== "object") {
9005
+ throw new TypeError("argument obj is required");
9006
+ }
9007
+ var parameters = obj.parameters;
9008
+ var type = obj.type;
9009
+ if (!type || !TYPE_REGEXP.test(type)) {
9010
+ throw new TypeError("invalid type");
9011
+ }
9012
+ var string5 = type;
9013
+ if (parameters && typeof parameters === "object") {
9014
+ var param;
9015
+ var params = Object.keys(parameters).sort();
9016
+ for (var i = 0;i < params.length; i++) {
9017
+ param = params[i];
9018
+ if (!TOKEN_REGEXP.test(param)) {
9019
+ throw new TypeError("invalid parameter name");
9020
+ }
9021
+ string5 += "; " + param + "=" + qstring(parameters[param]);
9022
+ }
9023
+ }
9024
+ return string5;
9025
+ }
9026
+ function parse5(string5) {
9027
+ if (!string5) {
9028
+ throw new TypeError("argument string is required");
9029
+ }
9030
+ var header = typeof string5 === "object" ? getcontenttype(string5) : string5;
9031
+ if (typeof header !== "string") {
9032
+ throw new TypeError("argument string is required to be a string");
9033
+ }
9034
+ var index = header.indexOf(";");
9035
+ var type = index !== -1 ? header.slice(0, index).trim() : header.trim();
9036
+ if (!TYPE_REGEXP.test(type)) {
9037
+ throw new TypeError("invalid media type");
9038
+ }
9039
+ var obj = new ContentType(type.toLowerCase());
9040
+ if (index !== -1) {
9041
+ var key;
9042
+ var match;
9043
+ var value;
9044
+ PARAM_REGEXP.lastIndex = index;
9045
+ while (match = PARAM_REGEXP.exec(header)) {
9046
+ if (match.index !== index) {
9047
+ throw new TypeError("invalid parameter format");
9048
+ }
9049
+ index += match[0].length;
9050
+ key = match[1].toLowerCase();
9051
+ value = match[2];
9052
+ if (value.charCodeAt(0) === 34) {
9053
+ value = value.slice(1, -1);
9054
+ if (value.indexOf("\\") !== -1) {
9055
+ value = value.replace(QESC_REGEXP, "$1");
9056
+ }
9057
+ }
9058
+ obj.parameters[key] = value;
9059
+ }
9060
+ if (index !== header.length) {
9061
+ throw new TypeError("invalid parameter format");
9062
+ }
9063
+ }
9064
+ return obj;
9065
+ }
9066
+ function getcontenttype(obj) {
9067
+ var header;
9068
+ if (typeof obj.getHeader === "function") {
9069
+ header = obj.getHeader("content-type");
9070
+ } else if (typeof obj.headers === "object") {
9071
+ header = obj.headers && obj.headers["content-type"];
9072
+ }
9073
+ if (typeof header !== "string") {
9074
+ throw new TypeError("content-type header is missing from object");
9075
+ }
9076
+ return header;
9077
+ }
9078
+ function qstring(val) {
9079
+ var str = String(val);
9080
+ if (TOKEN_REGEXP.test(str)) {
9081
+ return str;
9082
+ }
9083
+ if (str.length > 0 && !TEXT_REGEXP.test(str)) {
9084
+ throw new TypeError("invalid parameter value");
9085
+ }
9086
+ return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"';
9087
+ }
9088
+ function ContentType(type) {
9089
+ this.parameters = Object.create(null);
9090
+ this.type = type;
9091
+ }
9092
+ });
8987
9093
  // package.json
8988
9094
  var package_default = {
8989
9095
  name: "@uipath/docsai-tool",
8990
9096
  author: "UiPath",
8991
9097
  license: "SEE LICENSE IN LICENSE.txt",
8992
- version: "1.204.0-preview.216",
9098
+ version: "1.204.0-preview.223",
8993
9099
  description: "Search UiPath documentation with AI-powered answers.",
8994
9100
  private: false,
8995
9101
  repository: {
@@ -9025,7 +9131,7 @@ var package_default = {
9025
9131
  devDependencies: {
9026
9132
  "@uipath/auth": "workspace:*",
9027
9133
  "@uipath/common": "workspace:*",
9028
- "@modelcontextprotocol/sdk": "^1.26.0",
9134
+ "@modelcontextprotocol/sdk": "^1.31.0",
9029
9135
  "@types/node": "^25.5.2",
9030
9136
  commander: "^14.0.3",
9031
9137
  typescript: "^7.0.2"
@@ -20606,6 +20712,9 @@ class Protocol {
20606
20712
  this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
20607
20713
  const handleTaskResult = async () => {
20608
20714
  const taskId = request.params.taskId;
20715
+ if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
20716
+ throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
20717
+ }
20609
20718
  if (this._taskMessageQueue) {
20610
20719
  let queuedMessage;
20611
20720
  while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
@@ -20636,12 +20745,12 @@ class Protocol {
20636
20745
  throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
20637
20746
  }
20638
20747
  if (!isTerminal(task.status)) {
20639
- await this._waitForTaskUpdate(taskId, extra.signal);
20748
+ await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
20640
20749
  return await handleTaskResult();
20641
20750
  }
20642
20751
  if (isTerminal(task.status)) {
20643
20752
  const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
20644
- this._clearTaskQueue(taskId);
20753
+ this._clearTaskQueue(taskId, extra.sessionId);
20645
20754
  return {
20646
20755
  ...result,
20647
20756
  _meta: {
@@ -20678,7 +20787,7 @@ class Protocol {
20678
20787
  throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
20679
20788
  }
20680
20789
  await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
20681
- this._clearTaskQueue(request.params.taskId);
20790
+ this._clearTaskQueue(request.params.taskId, extra.sessionId);
20682
20791
  const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
20683
20792
  if (!cancelledTask) {
20684
20793
  throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
@@ -20801,6 +20910,19 @@ class Protocol {
20801
20910
  const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
20802
20911
  const capturedTransport = this._transport;
20803
20912
  const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
20913
+ const sessionId = capturedTransport?.sessionId;
20914
+ const store = this._taskStore;
20915
+ let relatedTaskFound = true;
20916
+ let relatedTaskLookup;
20917
+ if (relatedTaskId && store && this._taskMessageQueue && sessionId !== undefined) {
20918
+ relatedTaskFound = false;
20919
+ relatedTaskLookup = (async () => {
20920
+ if (!await store.getTask(relatedTaskId, sessionId)) {
20921
+ throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
20922
+ }
20923
+ relatedTaskFound = true;
20924
+ })();
20925
+ }
20804
20926
  if (handler === undefined) {
20805
20927
  const errorResponse = {
20806
20928
  jsonrpc: "2.0",
@@ -20810,7 +20932,10 @@ class Protocol {
20810
20932
  message: "Method not found"
20811
20933
  }
20812
20934
  };
20813
- if (relatedTaskId && this._taskMessageQueue) {
20935
+ if (relatedTaskId && relatedTaskLookup) {
20936
+ const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
20937
+ relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
20938
+ } else if (relatedTaskId && this._taskMessageQueue) {
20814
20939
  this._enqueueTaskMessage(relatedTaskId, {
20815
20940
  type: "error",
20816
20941
  message: errorResponse,
@@ -20861,7 +20986,10 @@ class Protocol {
20861
20986
  closeSSEStream: extra?.closeSSEStream,
20862
20987
  closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
20863
20988
  };
20864
- Promise.resolve().then(() => {
20989
+ (relatedTaskLookup ?? Promise.resolve()).then(() => {
20990
+ if (relatedTaskLookup && abortController.signal.aborted) {
20991
+ throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
20992
+ }
20865
20993
  if (taskCreationParams) {
20866
20994
  this.assertTaskHandlerCapability(request.method);
20867
20995
  }
@@ -20896,7 +21024,7 @@ class Protocol {
20896
21024
  ...error2["data"] !== undefined && { data: error2["data"] }
20897
21025
  }
20898
21026
  };
20899
- if (relatedTaskId && this._taskMessageQueue) {
21027
+ if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
20900
21028
  await this._enqueueTaskMessage(relatedTaskId, {
20901
21029
  type: "error",
20902
21030
  message: errorResponse,
@@ -21284,7 +21412,7 @@ class Protocol {
21284
21412
  throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
21285
21413
  }
21286
21414
  const maxQueueSize = this._options?.maxTaskQueueSize;
21287
- await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
21415
+ await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
21288
21416
  }
21289
21417
  async _clearTaskQueue(taskId, sessionId) {
21290
21418
  if (this._taskMessageQueue) {
@@ -21303,10 +21431,10 @@ class Protocol {
21303
21431
  }
21304
21432
  }
21305
21433
  }
21306
- async _waitForTaskUpdate(taskId, signal) {
21434
+ async _waitForTaskUpdate(taskId, signal, sessionId) {
21307
21435
  let interval = this._options?.defaultTaskPollInterval ?? 1000;
21308
21436
  try {
21309
- const task = await this._taskStore?.getTask(taskId);
21437
+ const task = await this._taskStore?.getTask(taskId, sessionId);
21310
21438
  if (task?.pollInterval) {
21311
21439
  interval = task.pollInterval;
21312
21440
  }
@@ -21647,16 +21775,7 @@ class Client extends Protocol {
21647
21775
  if (!methodSchema) {
21648
21776
  throw new Error("Schema is missing a method literal");
21649
21777
  }
21650
- let methodValue;
21651
- if (isZ4Schema(methodSchema)) {
21652
- const v4Schema = methodSchema;
21653
- const v4Def = v4Schema._zod?.def;
21654
- methodValue = v4Def?.value ?? v4Schema.value;
21655
- } else {
21656
- const v3Schema = methodSchema;
21657
- const legacyDef = v3Schema._def;
21658
- methodValue = legacyDef?.value ?? v3Schema.value;
21659
- }
21778
+ const methodValue = getLiteralValue(methodSchema);
21660
21779
  if (typeof methodValue !== "string") {
21661
21780
  throw new Error("Schema method literal must be a string");
21662
21781
  }
@@ -22017,6 +22136,23 @@ class Client extends Protocol {
22017
22136
  }
22018
22137
  }
22019
22138
 
22139
+ // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
22140
+ var import_content_type = __toESM(require_content_type(), 1);
22141
+ function mediaTypeEssence(header) {
22142
+ if (!header) {
22143
+ return;
22144
+ }
22145
+ try {
22146
+ return import_content_type.default.parse(header).type;
22147
+ } catch {
22148
+ const essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
22149
+ if (essence === "" || header.slice(essence.length).includes(",")) {
22150
+ return;
22151
+ }
22152
+ return essence;
22153
+ }
22154
+ }
22155
+
22020
22156
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
22021
22157
  function normalizeHeaders(headers) {
22022
22158
  if (!headers)
@@ -22042,6 +22178,68 @@ function createFetchWithInit(baseFetch = fetch, baseInit) {
22042
22178
  return baseFetch(url2, mergedInit);
22043
22179
  };
22044
22180
  }
22181
+ var MAX_REDIRECTS = 5;
22182
+ var REDIRECT_STATUSES = [301, 302, 303, 307, 308];
22183
+ function isWithinOrigin(from, to) {
22184
+ if (from.protocol === to.protocol && from.hostname === to.hostname && from.port === to.port) {
22185
+ return true;
22186
+ }
22187
+ return from.hostname === to.hostname && from.protocol === "http:" && from.port === "" && to.protocol === "https:" && to.port === "";
22188
+ }
22189
+ function redirectTarget(response, requestUrl) {
22190
+ const location = REDIRECT_STATUSES.includes(response.status) ? response.headers.get("location") : null;
22191
+ try {
22192
+ return location ? new URL(location, requestUrl) : undefined;
22193
+ } catch {
22194
+ return;
22195
+ }
22196
+ }
22197
+ function followWithinOrigin(baseFetch, url2, init, response, followed = 0) {
22198
+ const target = redirectTarget(response, url2);
22199
+ const keepsMethod = response.status === 307 || response.status === 308 || (init?.method ?? "GET").toUpperCase() === "GET";
22200
+ if (!target || followed === MAX_REDIRECTS || !keepsMethod) {
22201
+ return;
22202
+ }
22203
+ const from = new URL(url2);
22204
+ const addsUserinfo = (target.username || target.password) && (target.username !== from.username || target.password !== from.password);
22205
+ if (addsUserinfo || !isWithinOrigin(from, target)) {
22206
+ return;
22207
+ }
22208
+ return Promise.resolve(response.body?.cancel()).then(() => baseFetch(target, { ...init, redirect: "manual" })).then((next) => followWithinOrigin(baseFetch, target, init, next, followed + 1) ?? next);
22209
+ }
22210
+ var followingFetches = new WeakSet;
22211
+ function fetchLeavingRedirects(baseFetch) {
22212
+ const following = (url2, init) => (baseFetch ?? fetch)(url2, init);
22213
+ followingFetches.add(following);
22214
+ return following;
22215
+ }
22216
+ function fetchWithinOrigin(baseFetch = fetch) {
22217
+ if (followingFetches.has(baseFetch)) {
22218
+ return baseFetch;
22219
+ }
22220
+ return (url2, init) => {
22221
+ if (init?.redirect === "error" || init?.redirect === "manual") {
22222
+ return baseFetch(url2, init);
22223
+ }
22224
+ return Promise.resolve(baseFetch(url2, { ...init, redirect: "manual" })).then((response) => followWithinOrigin(baseFetch, url2, init, response) ?? response);
22225
+ };
22226
+ }
22227
+ function unfollowedRedirect(response, requestUrl) {
22228
+ if (response.type === "opaqueredirect") {
22229
+ return "Redirect not followed: this runtime does not expose the redirect target";
22230
+ }
22231
+ const from = response.url || requestUrl;
22232
+ const target = redirectTarget(response, from);
22233
+ if (!target) {
22234
+ return;
22235
+ }
22236
+ target.username = target.password = target.search = target.hash = "";
22237
+ if (target.protocol === "http:" && new URL(from).protocol === "https:") {
22238
+ target.protocol = "https:";
22239
+ return `Redirect to plain http not followed; try ${target.href} instead`;
22240
+ }
22241
+ return `Redirect to ${target.href} not followed`;
22242
+ }
22045
22243
 
22046
22244
  // ../../node_modules/pkce-challenge/dist/index.node.js
22047
22245
  var crypto2;
@@ -22185,7 +22383,8 @@ var OAuthTokensSchema = object2({
22185
22383
  token_type: string2(),
22186
22384
  expires_in: exports_coerce.number().optional(),
22187
22385
  scope: string2().optional(),
22188
- refresh_token: string2().optional()
22386
+ refresh_token: string2().optional(),
22387
+ issuer: string2().optional().catch(undefined)
22189
22388
  }).strip();
22190
22389
  var OAuthErrorResponseSchema = object2({
22191
22390
  error: string2(),
@@ -22217,7 +22416,8 @@ var OAuthClientInformationSchema = object2({
22217
22416
  client_id: string2(),
22218
22417
  client_secret: string2().optional(),
22219
22418
  client_id_issued_at: number2().optional(),
22220
- client_secret_expires_at: number2().optional()
22419
+ client_secret_expires_at: number2().optional(),
22420
+ issuer: string2().optional().catch(undefined)
22221
22421
  }).strip();
22222
22422
  var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
22223
22423
  var OAuthClientRegistrationErrorSchema = object2({
@@ -22429,10 +22629,30 @@ async function parseErrorResponse(input) {
22429
22629
  const errorClass = OAUTH_ERRORS[error2] || ServerError;
22430
22630
  return new errorClass(error_description || "", error_uri);
22431
22631
  } catch (error2) {
22432
- const errorMessage2 = `${statusCode ? `HTTP ${statusCode}: ` : ""}Invalid OAuth error response: ${error2}. Raw body: ${body}`;
22632
+ const redirect = input instanceof Response ? unfollowedRedirect(input, input.url) : undefined;
22633
+ const errorMessage2 = `${statusCode ? `HTTP ${statusCode}: ` : ""}${redirect ?? `Invalid OAuth error response: ${error2}. Raw body: ${body}`}`;
22433
22634
  return new ServerError(errorMessage2);
22434
22635
  }
22435
22636
  }
22637
+ function issuersMatch(a, b) {
22638
+ let [x, y] = [a, b];
22639
+ try {
22640
+ [x, y] = [new URL(a).href, new URL(b).href];
22641
+ } catch {}
22642
+ return x === y || x.endsWith("/") && x.slice(0, -1) === y || y.endsWith("/") && y.slice(0, -1) === x;
22643
+ }
22644
+ function discardIfIssuerMismatch(stored, issuer) {
22645
+ if (!stored)
22646
+ return;
22647
+ if (typeof stored.issuer !== "string")
22648
+ return stored.issuer == null ? stored : { ...stored, issuer: undefined };
22649
+ return issuersMatch(stored.issuer, issuer) ? stored : undefined;
22650
+ }
22651
+ var TokenResponseSchema = OAuthTokensSchema.omit({ issuer: true });
22652
+ var RegistrationResponseSchema = OAuthClientInformationFullSchema.omit({ issuer: true });
22653
+ function boundElsewhereError(stored, issuer) {
22654
+ return new Error(`OAuth client information is bound to authorization server ${stored.issuer} and is not presented to ${issuer}. ` + "Clear the stored client information, or correct `expectedIssuer`, if the authorization server has moved.");
22655
+ }
22436
22656
  async function auth(provider, options) {
22437
22657
  try {
22438
22658
  return await authInternal(provider, options);
@@ -22485,9 +22705,23 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
22485
22705
  authorizationServerMetadata: metadata
22486
22706
  });
22487
22707
  }
22488
- const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
22708
+ const issuer = String(authorizationServerUrl);
22709
+ const selectedResource = await selectResourceURL(serverUrl, provider, resourceMetadata);
22710
+ const resource = selectedResource && resourceMetadata && !provider.validateResourceURL ? resourceMetadata.resource : selectedResource;
22489
22711
  const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
22490
- let clientInformation = await Promise.resolve(provider.clientInformation());
22712
+ const storedClientInformation = await Promise.resolve(provider.clientInformation());
22713
+ let clientInformation = discardIfIssuerMismatch(storedClientInformation, issuer);
22714
+ const canRegisterAgain = provider.saveClientInformation !== undefined && !!provider.redirectUrl;
22715
+ if (storedClientInformation && !clientInformation && !canRegisterAgain) {
22716
+ throw boundElsewhereError(storedClientInformation, issuer);
22717
+ }
22718
+ const unstampedClientInformation = clientInformation?.issuer == null ? clientInformation : undefined;
22719
+ const bindClientInformation = async () => {
22720
+ try {
22721
+ if (unstampedClientInformation)
22722
+ await provider.saveClientInformation?.({ ...unstampedClientInformation, issuer });
22723
+ } catch {}
22724
+ };
22491
22725
  if (!clientInformation) {
22492
22726
  if (authorizationCode !== undefined) {
22493
22727
  throw new Error("Existing OAuth client information is required when exchanging an authorization code");
@@ -22499,9 +22733,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
22499
22733
  }
22500
22734
  const shouldUseUrlBasedClientId = supportsUrlBasedClientId && clientMetadataUrl;
22501
22735
  if (shouldUseUrlBasedClientId) {
22502
- clientInformation = {
22503
- client_id: clientMetadataUrl
22504
- };
22736
+ clientInformation = { client_id: clientMetadataUrl, issuer };
22505
22737
  await provider.saveClientInformation?.(clientInformation);
22506
22738
  } else {
22507
22739
  if (!provider.saveClientInformation) {
@@ -22513,8 +22745,8 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
22513
22745
  scope: resolvedScope,
22514
22746
  fetchFn
22515
22747
  });
22516
- await provider.saveClientInformation(fullInformation);
22517
- clientInformation = fullInformation;
22748
+ clientInformation = { ...fullInformation, issuer };
22749
+ await provider.saveClientInformation(clientInformation);
22518
22750
  }
22519
22751
  }
22520
22752
  const nonInteractiveFlow = !provider.redirectUrl;
@@ -22525,10 +22757,14 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
22525
22757
  authorizationCode,
22526
22758
  fetchFn
22527
22759
  });
22528
- await provider.saveTokens(tokens2);
22760
+ await bindClientInformation();
22761
+ await provider.saveTokens({ ...tokens2, issuer });
22529
22762
  return "AUTHORIZED";
22530
22763
  }
22531
- const tokens = await provider.tokens();
22764
+ const tokens = discardIfIssuerMismatch(await provider.tokens(), issuer);
22765
+ if (tokens?.refresh_token && tokens.issuer == null) {
22766
+ console.warn("[mcp-sdk] stored OAuth tokens have no 'issuer' property (saved by an earlier version, or by a provider that " + "does not keep it) and are used as-is; make sure your OAuthClientProvider stores what saveTokens() and " + "saveClientInformation() receive unchanged.");
22767
+ }
22532
22768
  if (tokens?.refresh_token) {
22533
22769
  try {
22534
22770
  const newTokens = await refreshAuthorization(authorizationServerUrl, {
@@ -22539,7 +22775,8 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
22539
22775
  addClientAuthentication: provider.addClientAuthentication,
22540
22776
  fetchFn
22541
22777
  });
22542
- await provider.saveTokens(newTokens);
22778
+ await bindClientInformation();
22779
+ await provider.saveTokens({ ...newTokens, issuer });
22543
22780
  return "AUTHORIZED";
22544
22781
  } catch (error2) {
22545
22782
  if (!(error2 instanceof OAuthError) || error2 instanceof ServerError) {} else {
@@ -22636,7 +22873,7 @@ async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn =
22636
22873
  }
22637
22874
  async function fetchWithCorsRetry(url2, headers, fetchFn = fetch) {
22638
22875
  try {
22639
- return await fetchFn(url2, { headers });
22876
+ return await fetchWithinOrigin(fetchFn)(url2, { headers });
22640
22877
  } catch (error2) {
22641
22878
  if (error2 instanceof TypeError) {
22642
22879
  if (headers) {
@@ -22661,7 +22898,7 @@ async function tryMetadataDiscovery(url2, protocolVersion, fetchFn = fetch) {
22661
22898
  return await fetchWithCorsRetry(url2, headers, fetchFn);
22662
22899
  }
22663
22900
  function shouldAttemptFallback(response, pathname) {
22664
- return !response || response.status >= 400 && response.status < 500 && pathname !== "/";
22901
+ return !response || !response.ok && response.status < 500 && pathname !== "/";
22665
22902
  }
22666
22903
  async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
22667
22904
  const issuer = new URL(serverUrl);
@@ -22727,7 +22964,7 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
22727
22964
  }
22728
22965
  if (!response.ok) {
22729
22966
  await response.body?.cancel();
22730
- if (response.status >= 400 && response.status < 500) {
22967
+ if (response.status < 500) {
22731
22968
  continue;
22732
22969
  }
22733
22970
  throw new Error(`HTTP ${response.status} trying to load ${type === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${endpointUrl}`);
@@ -22759,6 +22996,9 @@ async function discoverOAuthServerInfo(serverUrl, opts) {
22759
22996
  resourceMetadata
22760
22997
  };
22761
22998
  }
22999
+ function resourceIndicatorToString(resource) {
23000
+ return typeof resource === "string" ? resource : resource.href;
23001
+ }
22762
23002
  async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
22763
23003
  let authorizationUrl;
22764
23004
  if (metadata) {
@@ -22790,7 +23030,7 @@ async function startAuthorization(authorizationServerUrl, { metadata, clientInfo
22790
23030
  authorizationUrl.searchParams.append("prompt", "consent");
22791
23031
  }
22792
23032
  if (resource) {
22793
- authorizationUrl.searchParams.set("resource", resource.href);
23033
+ authorizationUrl.searchParams.set("resource", resourceIndicatorToString(resource));
22794
23034
  }
22795
23035
  return { authorizationUrl, codeVerifier };
22796
23036
  }
@@ -22809,7 +23049,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
22809
23049
  Accept: "application/json"
22810
23050
  });
22811
23051
  if (resource) {
22812
- tokenRequestParams.set("resource", resource.href);
23052
+ tokenRequestParams.set("resource", resourceIndicatorToString(resource));
22813
23053
  }
22814
23054
  if (addClientAuthentication) {
22815
23055
  await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata);
@@ -22818,7 +23058,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
22818
23058
  const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
22819
23059
  applyClientAuthentication(authMethod, clientInformation, headers, tokenRequestParams);
22820
23060
  }
22821
- const response = await (fetchFn ?? fetch)(tokenUrl, {
23061
+ const response = await fetchWithinOrigin(fetchFn ?? fetch)(tokenUrl, {
22822
23062
  method: "POST",
22823
23063
  headers,
22824
23064
  body: tokenRequestParams
@@ -22826,7 +23066,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
22826
23066
  if (!response.ok) {
22827
23067
  throw await parseErrorResponse(response);
22828
23068
  }
22829
- return OAuthTokensSchema.parse(await response.json());
23069
+ return TokenResponseSchema.parse(await response.json());
22830
23070
  }
22831
23071
  async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }) {
22832
23072
  const tokenRequestParams = new URLSearchParams({
@@ -22844,6 +23084,15 @@ async function refreshAuthorization(authorizationServerUrl, { metadata, clientIn
22844
23084
  return { refresh_token: refreshToken, ...tokens };
22845
23085
  }
22846
23086
  async function fetchToken(provider, authorizationServerUrl, { metadata, resource, authorizationCode, fetchFn } = {}) {
23087
+ const readClientInformation = async () => {
23088
+ const storedClientInformation = await provider.clientInformation();
23089
+ const checked = discardIfIssuerMismatch(storedClientInformation, String(authorizationServerUrl));
23090
+ if (storedClientInformation && !checked) {
23091
+ throw boundElsewhereError(storedClientInformation, String(authorizationServerUrl));
23092
+ }
23093
+ return checked;
23094
+ };
23095
+ let clientInformation = await readClientInformation();
22847
23096
  const scope = provider.clientMetadata.scope;
22848
23097
  let tokenRequestParams;
22849
23098
  if (provider.prepareTokenRequest) {
@@ -22859,11 +23108,11 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
22859
23108
  const codeVerifier = await provider.codeVerifier();
22860
23109
  tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, provider.redirectUrl);
22861
23110
  }
22862
- const clientInformation = await provider.clientInformation();
23111
+ clientInformation ?? (clientInformation = await readClientInformation());
22863
23112
  return executeTokenRequest(authorizationServerUrl, {
22864
23113
  metadata,
22865
23114
  tokenRequestParams,
22866
- clientInformation: clientInformation ?? undefined,
23115
+ clientInformation,
22867
23116
  addClientAuthentication: provider.addClientAuthentication,
22868
23117
  resource,
22869
23118
  fetchFn
@@ -22879,7 +23128,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
22879
23128
  } else {
22880
23129
  registrationUrl = new URL("/register", authorizationServerUrl);
22881
23130
  }
22882
- const response = await (fetchFn ?? fetch)(registrationUrl, {
23131
+ const response = await fetchWithinOrigin(fetchFn ?? fetch)(registrationUrl, {
22883
23132
  method: "POST",
22884
23133
  headers: {
22885
23134
  "Content-Type": "application/json"
@@ -22892,7 +23141,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
22892
23141
  if (!response.ok) {
22893
23142
  throw await parseErrorResponse(response);
22894
23143
  }
22895
- return OAuthClientInformationFullSchema.parse(await response.json());
23144
+ return RegistrationResponseSchema.parse(await response.json());
22896
23145
  }
22897
23146
 
22898
23147
  // ../../node_modules/eventsource-parser/dist/index.js
@@ -23105,9 +23354,18 @@ class StreamableHTTPClientTransport {
23105
23354
  this._authProvider = opts?.authProvider;
23106
23355
  this._fetch = opts?.fetch;
23107
23356
  this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
23357
+ this._followRedirects = opts?.redirectPolicy === "follow";
23358
+ if (this._followRedirects) {
23359
+ this._fetch = fetchLeavingRedirects(this._fetch);
23360
+ this._fetchWithInit = fetchLeavingRedirects(this._fetchWithInit);
23361
+ }
23108
23362
  this._sessionId = opts?.sessionId;
23109
23363
  this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
23110
23364
  }
23365
+ _unfollowedRedirect(response, url2) {
23366
+ const text = unfollowedRedirect(response, url2);
23367
+ return text && !this._followRedirects ? `${text} (redirectPolicy: 'same-origin')` : text;
23368
+ }
23111
23369
  async _authThenStart() {
23112
23370
  if (!this._authProvider) {
23113
23371
  throw new UnauthorizedError("No auth provider");
@@ -23157,11 +23415,13 @@ class StreamableHTTPClientTransport {
23157
23415
  if (resumptionToken) {
23158
23416
  headers.set("last-event-id", resumptionToken);
23159
23417
  }
23160
- const response = await (this._fetch ?? fetch)(this._url, {
23161
- method: "GET",
23162
- headers,
23163
- signal: this._abortController?.signal
23164
- });
23418
+ const fetchFn = this._fetch ?? fetch;
23419
+ const init = { method: "GET", headers, signal: this._abortController?.signal };
23420
+ let response = await fetchFn(this._url, this._followRedirects ? init : { ...init, redirect: "manual" });
23421
+ const followed = this._followRedirects ? undefined : followWithinOrigin(fetchFn, this._url, init, response);
23422
+ if (followed) {
23423
+ response = await followed;
23424
+ }
23165
23425
  if (!response.ok) {
23166
23426
  await response.body?.cancel();
23167
23427
  if (response.status === 401 && this._authProvider) {
@@ -23170,7 +23430,7 @@ class StreamableHTTPClientTransport {
23170
23430
  if (response.status === 405) {
23171
23431
  return;
23172
23432
  }
23173
- throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${response.statusText}`);
23433
+ throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${this._unfollowedRedirect(response, this._url) ?? response.statusText}`);
23174
23434
  }
23175
23435
  this._handleSseStream(response.body, options, true);
23176
23436
  } catch (error2) {
@@ -23318,7 +23578,7 @@ class StreamableHTTPClientTransport {
23318
23578
  body: JSON.stringify(message),
23319
23579
  signal: this._abortController?.signal
23320
23580
  };
23321
- const response = await (this._fetch ?? fetch)(this._url, init);
23581
+ const response = await fetchWithinOrigin(this._fetch ?? fetch)(this._url, init);
23322
23582
  const sessionId = response.headers.get("mcp-session-id");
23323
23583
  if (sessionId) {
23324
23584
  this._sessionId = sessionId;
@@ -23370,7 +23630,7 @@ class StreamableHTTPClientTransport {
23370
23630
  return this.send(message);
23371
23631
  }
23372
23632
  }
23373
- throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
23633
+ throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${this._unfollowedRedirect(response, this._url) ?? text}`);
23374
23634
  }
23375
23635
  this._hasCompletedAuthFlow = false;
23376
23636
  this._lastUpscopingHeader = undefined;
@@ -23383,11 +23643,12 @@ class StreamableHTTPClientTransport {
23383
23643
  }
23384
23644
  const messages = Array.isArray(message) ? message : [message];
23385
23645
  const hasRequests = messages.filter((msg) => ("method" in msg) && ("id" in msg) && msg.id !== undefined).length > 0;
23386
- const contentType = response.headers.get("content-type");
23646
+ const contentType2 = response.headers.get("content-type");
23647
+ const responseMediaType = mediaTypeEssence(contentType2);
23387
23648
  if (hasRequests) {
23388
- if (contentType?.includes("text/event-stream")) {
23649
+ if (responseMediaType === "text/event-stream") {
23389
23650
  this._handleSseStream(response.body, { onresumptiontoken }, false);
23390
- } else if (contentType?.includes("application/json")) {
23651
+ } else if (responseMediaType === "application/json") {
23391
23652
  const data = await response.json();
23392
23653
  const responseMessages = Array.isArray(data) ? data.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data)];
23393
23654
  for (const msg of responseMessages) {
@@ -23395,7 +23656,7 @@ class StreamableHTTPClientTransport {
23395
23656
  }
23396
23657
  } else {
23397
23658
  await response.body?.cancel();
23398
- throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType}`);
23659
+ throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType2}`);
23399
23660
  }
23400
23661
  } else {
23401
23662
  await response.body?.cancel();
@@ -23420,10 +23681,10 @@ class StreamableHTTPClientTransport {
23420
23681
  headers,
23421
23682
  signal: this._abortController?.signal
23422
23683
  };
23423
- const response = await (this._fetch ?? fetch)(this._url, init);
23684
+ const response = await fetchWithinOrigin(this._fetch ?? fetch)(this._url, init);
23424
23685
  await response.body?.cancel();
23425
23686
  if (!response.ok && response.status !== 405) {
23426
- throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
23687
+ throw new StreamableHTTPError(response.status, `Failed to terminate session: ${this._unfollowedRedirect(response, this._url) ?? response.statusText}`);
23427
23688
  }
23428
23689
  this._sessionId = undefined;
23429
23690
  } catch (error2) {
@@ -23629,4 +23890,4 @@ var registerCommands = async (program2) => {
23629
23890
 
23630
23891
  export { Command, metadata, registerCommands };
23631
23892
 
23632
- //# debugId=AD1580727AC88BFA64756E2164756E21
23893
+ //# debugId=294DBF2098960FF464756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-3bjykajz.js";
4
+ } from "./tool-a3fbtxxb.js";
5
5
  import"./tool-1yh8g550.js";
6
6
  export {
7
7
  metadata,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/docsai-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.204.0-preview.216",
5
+ "version": "1.204.0-preview.223",
6
6
  "description": "Search UiPath documentation with AI-powered answers.",
7
7
  "private": false,
8
8
  "repository": {
@@ -27,5 +27,5 @@
27
27
  "files": [
28
28
  "dist"
29
29
  ],
30
- "gitHead": "d5a0a7645cd7a15109fab5cc8280ed5ebbcaea23"
30
+ "gitHead": "a9198f6984a9f1ee6a27db7592a99a8e886e82f0"
31
31
  }