@uipath/docsai-tool 1.203.0-preview.212 → 1.203.0-preview.222
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD-PARTY-NOTICES.md +35 -3
- package/dist/index.js +1 -1
- package/dist/{tool-rz5abrkh.js → tool-pv25tw1a.js} +321 -60
- package/dist/tool.js +1 -1
- package/package.json +2 -2
|
@@ -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
|
-
|
|
8
|
+
26 bundled dependencies:
|
|
9
9
|
|
|
10
|
-
- @modelcontextprotocol/sdk@1.
|
|
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.
|
|
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
|
@@ -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.203.0-preview.
|
|
9098
|
+
version: "1.203.0-preview.222",
|
|
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.
|
|
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"
|
|
@@ -20077,6 +20183,9 @@ class Protocol {
|
|
|
20077
20183
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
20078
20184
|
const handleTaskResult = async () => {
|
|
20079
20185
|
const taskId = request.params.taskId;
|
|
20186
|
+
if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
|
|
20187
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
20188
|
+
}
|
|
20080
20189
|
if (this._taskMessageQueue) {
|
|
20081
20190
|
let queuedMessage;
|
|
20082
20191
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -20107,12 +20216,12 @@ class Protocol {
|
|
|
20107
20216
|
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
20108
20217
|
}
|
|
20109
20218
|
if (!isTerminal(task.status)) {
|
|
20110
|
-
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
20219
|
+
await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
|
|
20111
20220
|
return await handleTaskResult();
|
|
20112
20221
|
}
|
|
20113
20222
|
if (isTerminal(task.status)) {
|
|
20114
20223
|
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
20115
|
-
this._clearTaskQueue(taskId);
|
|
20224
|
+
this._clearTaskQueue(taskId, extra.sessionId);
|
|
20116
20225
|
return {
|
|
20117
20226
|
...result,
|
|
20118
20227
|
_meta: {
|
|
@@ -20149,7 +20258,7 @@ class Protocol {
|
|
|
20149
20258
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
20150
20259
|
}
|
|
20151
20260
|
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
20152
|
-
this._clearTaskQueue(request.params.taskId);
|
|
20261
|
+
this._clearTaskQueue(request.params.taskId, extra.sessionId);
|
|
20153
20262
|
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
20154
20263
|
if (!cancelledTask) {
|
|
20155
20264
|
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
@@ -20272,6 +20381,19 @@ class Protocol {
|
|
|
20272
20381
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
20273
20382
|
const capturedTransport = this._transport;
|
|
20274
20383
|
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
20384
|
+
const sessionId = capturedTransport?.sessionId;
|
|
20385
|
+
const store = this._taskStore;
|
|
20386
|
+
let relatedTaskFound = true;
|
|
20387
|
+
let relatedTaskLookup;
|
|
20388
|
+
if (relatedTaskId && store && this._taskMessageQueue && sessionId !== undefined) {
|
|
20389
|
+
relatedTaskFound = false;
|
|
20390
|
+
relatedTaskLookup = (async () => {
|
|
20391
|
+
if (!await store.getTask(relatedTaskId, sessionId)) {
|
|
20392
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
|
|
20393
|
+
}
|
|
20394
|
+
relatedTaskFound = true;
|
|
20395
|
+
})();
|
|
20396
|
+
}
|
|
20275
20397
|
if (handler === undefined) {
|
|
20276
20398
|
const errorResponse = {
|
|
20277
20399
|
jsonrpc: "2.0",
|
|
@@ -20281,7 +20403,10 @@ class Protocol {
|
|
|
20281
20403
|
message: "Method not found"
|
|
20282
20404
|
}
|
|
20283
20405
|
};
|
|
20284
|
-
if (relatedTaskId &&
|
|
20406
|
+
if (relatedTaskId && relatedTaskLookup) {
|
|
20407
|
+
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
20408
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
|
|
20409
|
+
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
20285
20410
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
20286
20411
|
type: "error",
|
|
20287
20412
|
message: errorResponse,
|
|
@@ -20332,7 +20457,10 @@ class Protocol {
|
|
|
20332
20457
|
closeSSEStream: extra?.closeSSEStream,
|
|
20333
20458
|
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
20334
20459
|
};
|
|
20335
|
-
Promise.resolve().then(() => {
|
|
20460
|
+
(relatedTaskLookup ?? Promise.resolve()).then(() => {
|
|
20461
|
+
if (relatedTaskLookup && abortController.signal.aborted) {
|
|
20462
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
20463
|
+
}
|
|
20336
20464
|
if (taskCreationParams) {
|
|
20337
20465
|
this.assertTaskHandlerCapability(request.method);
|
|
20338
20466
|
}
|
|
@@ -20367,7 +20495,7 @@ class Protocol {
|
|
|
20367
20495
|
...error2["data"] !== undefined && { data: error2["data"] }
|
|
20368
20496
|
}
|
|
20369
20497
|
};
|
|
20370
|
-
if (relatedTaskId && this._taskMessageQueue) {
|
|
20498
|
+
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
20371
20499
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
20372
20500
|
type: "error",
|
|
20373
20501
|
message: errorResponse,
|
|
@@ -20755,7 +20883,7 @@ class Protocol {
|
|
|
20755
20883
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
20756
20884
|
}
|
|
20757
20885
|
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
20758
|
-
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
20886
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
|
|
20759
20887
|
}
|
|
20760
20888
|
async _clearTaskQueue(taskId, sessionId) {
|
|
20761
20889
|
if (this._taskMessageQueue) {
|
|
@@ -20774,10 +20902,10 @@ class Protocol {
|
|
|
20774
20902
|
}
|
|
20775
20903
|
}
|
|
20776
20904
|
}
|
|
20777
|
-
async _waitForTaskUpdate(taskId, signal) {
|
|
20905
|
+
async _waitForTaskUpdate(taskId, signal, sessionId) {
|
|
20778
20906
|
let interval = this._options?.defaultTaskPollInterval ?? 1000;
|
|
20779
20907
|
try {
|
|
20780
|
-
const task = await this._taskStore?.getTask(taskId);
|
|
20908
|
+
const task = await this._taskStore?.getTask(taskId, sessionId);
|
|
20781
20909
|
if (task?.pollInterval) {
|
|
20782
20910
|
interval = task.pollInterval;
|
|
20783
20911
|
}
|
|
@@ -21118,16 +21246,7 @@ class Client extends Protocol {
|
|
|
21118
21246
|
if (!methodSchema) {
|
|
21119
21247
|
throw new Error("Schema is missing a method literal");
|
|
21120
21248
|
}
|
|
21121
|
-
|
|
21122
|
-
if (isZ4Schema(methodSchema)) {
|
|
21123
|
-
const v4Schema = methodSchema;
|
|
21124
|
-
const v4Def = v4Schema._zod?.def;
|
|
21125
|
-
methodValue = v4Def?.value ?? v4Schema.value;
|
|
21126
|
-
} else {
|
|
21127
|
-
const v3Schema = methodSchema;
|
|
21128
|
-
const legacyDef = v3Schema._def;
|
|
21129
|
-
methodValue = legacyDef?.value ?? v3Schema.value;
|
|
21130
|
-
}
|
|
21249
|
+
const methodValue = getLiteralValue(methodSchema);
|
|
21131
21250
|
if (typeof methodValue !== "string") {
|
|
21132
21251
|
throw new Error("Schema method literal must be a string");
|
|
21133
21252
|
}
|
|
@@ -21488,6 +21607,23 @@ class Client extends Protocol {
|
|
|
21488
21607
|
}
|
|
21489
21608
|
}
|
|
21490
21609
|
|
|
21610
|
+
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
|
|
21611
|
+
var import_content_type = __toESM(require_content_type(), 1);
|
|
21612
|
+
function mediaTypeEssence(header) {
|
|
21613
|
+
if (!header) {
|
|
21614
|
+
return;
|
|
21615
|
+
}
|
|
21616
|
+
try {
|
|
21617
|
+
return import_content_type.default.parse(header).type;
|
|
21618
|
+
} catch {
|
|
21619
|
+
const essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
|
|
21620
|
+
if (essence === "" || header.slice(essence.length).includes(",")) {
|
|
21621
|
+
return;
|
|
21622
|
+
}
|
|
21623
|
+
return essence;
|
|
21624
|
+
}
|
|
21625
|
+
}
|
|
21626
|
+
|
|
21491
21627
|
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
|
|
21492
21628
|
function normalizeHeaders(headers) {
|
|
21493
21629
|
if (!headers)
|
|
@@ -21513,6 +21649,68 @@ function createFetchWithInit(baseFetch = fetch, baseInit) {
|
|
|
21513
21649
|
return baseFetch(url2, mergedInit);
|
|
21514
21650
|
};
|
|
21515
21651
|
}
|
|
21652
|
+
var MAX_REDIRECTS = 5;
|
|
21653
|
+
var REDIRECT_STATUSES = [301, 302, 303, 307, 308];
|
|
21654
|
+
function isWithinOrigin(from, to) {
|
|
21655
|
+
if (from.protocol === to.protocol && from.hostname === to.hostname && from.port === to.port) {
|
|
21656
|
+
return true;
|
|
21657
|
+
}
|
|
21658
|
+
return from.hostname === to.hostname && from.protocol === "http:" && from.port === "" && to.protocol === "https:" && to.port === "";
|
|
21659
|
+
}
|
|
21660
|
+
function redirectTarget(response, requestUrl) {
|
|
21661
|
+
const location = REDIRECT_STATUSES.includes(response.status) ? response.headers.get("location") : null;
|
|
21662
|
+
try {
|
|
21663
|
+
return location ? new URL(location, requestUrl) : undefined;
|
|
21664
|
+
} catch {
|
|
21665
|
+
return;
|
|
21666
|
+
}
|
|
21667
|
+
}
|
|
21668
|
+
function followWithinOrigin(baseFetch, url2, init, response, followed = 0) {
|
|
21669
|
+
const target = redirectTarget(response, url2);
|
|
21670
|
+
const keepsMethod = response.status === 307 || response.status === 308 || (init?.method ?? "GET").toUpperCase() === "GET";
|
|
21671
|
+
if (!target || followed === MAX_REDIRECTS || !keepsMethod) {
|
|
21672
|
+
return;
|
|
21673
|
+
}
|
|
21674
|
+
const from = new URL(url2);
|
|
21675
|
+
const addsUserinfo = (target.username || target.password) && (target.username !== from.username || target.password !== from.password);
|
|
21676
|
+
if (addsUserinfo || !isWithinOrigin(from, target)) {
|
|
21677
|
+
return;
|
|
21678
|
+
}
|
|
21679
|
+
return Promise.resolve(response.body?.cancel()).then(() => baseFetch(target, { ...init, redirect: "manual" })).then((next) => followWithinOrigin(baseFetch, target, init, next, followed + 1) ?? next);
|
|
21680
|
+
}
|
|
21681
|
+
var followingFetches = new WeakSet;
|
|
21682
|
+
function fetchLeavingRedirects(baseFetch) {
|
|
21683
|
+
const following = (url2, init) => (baseFetch ?? fetch)(url2, init);
|
|
21684
|
+
followingFetches.add(following);
|
|
21685
|
+
return following;
|
|
21686
|
+
}
|
|
21687
|
+
function fetchWithinOrigin(baseFetch = fetch) {
|
|
21688
|
+
if (followingFetches.has(baseFetch)) {
|
|
21689
|
+
return baseFetch;
|
|
21690
|
+
}
|
|
21691
|
+
return (url2, init) => {
|
|
21692
|
+
if (init?.redirect === "error" || init?.redirect === "manual") {
|
|
21693
|
+
return baseFetch(url2, init);
|
|
21694
|
+
}
|
|
21695
|
+
return Promise.resolve(baseFetch(url2, { ...init, redirect: "manual" })).then((response) => followWithinOrigin(baseFetch, url2, init, response) ?? response);
|
|
21696
|
+
};
|
|
21697
|
+
}
|
|
21698
|
+
function unfollowedRedirect(response, requestUrl) {
|
|
21699
|
+
if (response.type === "opaqueredirect") {
|
|
21700
|
+
return "Redirect not followed: this runtime does not expose the redirect target";
|
|
21701
|
+
}
|
|
21702
|
+
const from = response.url || requestUrl;
|
|
21703
|
+
const target = redirectTarget(response, from);
|
|
21704
|
+
if (!target) {
|
|
21705
|
+
return;
|
|
21706
|
+
}
|
|
21707
|
+
target.username = target.password = target.search = target.hash = "";
|
|
21708
|
+
if (target.protocol === "http:" && new URL(from).protocol === "https:") {
|
|
21709
|
+
target.protocol = "https:";
|
|
21710
|
+
return `Redirect to plain http not followed; try ${target.href} instead`;
|
|
21711
|
+
}
|
|
21712
|
+
return `Redirect to ${target.href} not followed`;
|
|
21713
|
+
}
|
|
21516
21714
|
|
|
21517
21715
|
// ../../node_modules/pkce-challenge/dist/index.node.js
|
|
21518
21716
|
var crypto2;
|
|
@@ -21656,7 +21854,8 @@ var OAuthTokensSchema = object2({
|
|
|
21656
21854
|
token_type: string2(),
|
|
21657
21855
|
expires_in: exports_coerce.number().optional(),
|
|
21658
21856
|
scope: string2().optional(),
|
|
21659
|
-
refresh_token: string2().optional()
|
|
21857
|
+
refresh_token: string2().optional(),
|
|
21858
|
+
issuer: string2().optional().catch(undefined)
|
|
21660
21859
|
}).strip();
|
|
21661
21860
|
var OAuthErrorResponseSchema = object2({
|
|
21662
21861
|
error: string2(),
|
|
@@ -21688,7 +21887,8 @@ var OAuthClientInformationSchema = object2({
|
|
|
21688
21887
|
client_id: string2(),
|
|
21689
21888
|
client_secret: string2().optional(),
|
|
21690
21889
|
client_id_issued_at: number2().optional(),
|
|
21691
|
-
client_secret_expires_at: number2().optional()
|
|
21890
|
+
client_secret_expires_at: number2().optional(),
|
|
21891
|
+
issuer: string2().optional().catch(undefined)
|
|
21692
21892
|
}).strip();
|
|
21693
21893
|
var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
|
|
21694
21894
|
var OAuthClientRegistrationErrorSchema = object2({
|
|
@@ -21900,10 +22100,30 @@ async function parseErrorResponse(input) {
|
|
|
21900
22100
|
const errorClass = OAUTH_ERRORS[error2] || ServerError;
|
|
21901
22101
|
return new errorClass(error_description || "", error_uri);
|
|
21902
22102
|
} catch (error2) {
|
|
21903
|
-
const
|
|
22103
|
+
const redirect = input instanceof Response ? unfollowedRedirect(input, input.url) : undefined;
|
|
22104
|
+
const errorMessage2 = `${statusCode ? `HTTP ${statusCode}: ` : ""}${redirect ?? `Invalid OAuth error response: ${error2}. Raw body: ${body}`}`;
|
|
21904
22105
|
return new ServerError(errorMessage2);
|
|
21905
22106
|
}
|
|
21906
22107
|
}
|
|
22108
|
+
function issuersMatch(a, b) {
|
|
22109
|
+
let [x, y] = [a, b];
|
|
22110
|
+
try {
|
|
22111
|
+
[x, y] = [new URL(a).href, new URL(b).href];
|
|
22112
|
+
} catch {}
|
|
22113
|
+
return x === y || x.endsWith("/") && x.slice(0, -1) === y || y.endsWith("/") && y.slice(0, -1) === x;
|
|
22114
|
+
}
|
|
22115
|
+
function discardIfIssuerMismatch(stored, issuer) {
|
|
22116
|
+
if (!stored)
|
|
22117
|
+
return;
|
|
22118
|
+
if (typeof stored.issuer !== "string")
|
|
22119
|
+
return stored.issuer == null ? stored : { ...stored, issuer: undefined };
|
|
22120
|
+
return issuersMatch(stored.issuer, issuer) ? stored : undefined;
|
|
22121
|
+
}
|
|
22122
|
+
var TokenResponseSchema = OAuthTokensSchema.omit({ issuer: true });
|
|
22123
|
+
var RegistrationResponseSchema = OAuthClientInformationFullSchema.omit({ issuer: true });
|
|
22124
|
+
function boundElsewhereError(stored, issuer) {
|
|
22125
|
+
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.");
|
|
22126
|
+
}
|
|
21907
22127
|
async function auth(provider, options) {
|
|
21908
22128
|
try {
|
|
21909
22129
|
return await authInternal(provider, options);
|
|
@@ -21956,9 +22176,23 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
21956
22176
|
authorizationServerMetadata: metadata
|
|
21957
22177
|
});
|
|
21958
22178
|
}
|
|
21959
|
-
const
|
|
22179
|
+
const issuer = String(authorizationServerUrl);
|
|
22180
|
+
const selectedResource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
22181
|
+
const resource = selectedResource && resourceMetadata && !provider.validateResourceURL ? resourceMetadata.resource : selectedResource;
|
|
21960
22182
|
const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
|
|
21961
|
-
|
|
22183
|
+
const storedClientInformation = await Promise.resolve(provider.clientInformation());
|
|
22184
|
+
let clientInformation = discardIfIssuerMismatch(storedClientInformation, issuer);
|
|
22185
|
+
const canRegisterAgain = provider.saveClientInformation !== undefined && !!provider.redirectUrl;
|
|
22186
|
+
if (storedClientInformation && !clientInformation && !canRegisterAgain) {
|
|
22187
|
+
throw boundElsewhereError(storedClientInformation, issuer);
|
|
22188
|
+
}
|
|
22189
|
+
const unstampedClientInformation = clientInformation?.issuer == null ? clientInformation : undefined;
|
|
22190
|
+
const bindClientInformation = async () => {
|
|
22191
|
+
try {
|
|
22192
|
+
if (unstampedClientInformation)
|
|
22193
|
+
await provider.saveClientInformation?.({ ...unstampedClientInformation, issuer });
|
|
22194
|
+
} catch {}
|
|
22195
|
+
};
|
|
21962
22196
|
if (!clientInformation) {
|
|
21963
22197
|
if (authorizationCode !== undefined) {
|
|
21964
22198
|
throw new Error("Existing OAuth client information is required when exchanging an authorization code");
|
|
@@ -21970,9 +22204,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
21970
22204
|
}
|
|
21971
22205
|
const shouldUseUrlBasedClientId = supportsUrlBasedClientId && clientMetadataUrl;
|
|
21972
22206
|
if (shouldUseUrlBasedClientId) {
|
|
21973
|
-
clientInformation = {
|
|
21974
|
-
client_id: clientMetadataUrl
|
|
21975
|
-
};
|
|
22207
|
+
clientInformation = { client_id: clientMetadataUrl, issuer };
|
|
21976
22208
|
await provider.saveClientInformation?.(clientInformation);
|
|
21977
22209
|
} else {
|
|
21978
22210
|
if (!provider.saveClientInformation) {
|
|
@@ -21984,8 +22216,8 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
21984
22216
|
scope: resolvedScope,
|
|
21985
22217
|
fetchFn
|
|
21986
22218
|
});
|
|
21987
|
-
|
|
21988
|
-
clientInformation
|
|
22219
|
+
clientInformation = { ...fullInformation, issuer };
|
|
22220
|
+
await provider.saveClientInformation(clientInformation);
|
|
21989
22221
|
}
|
|
21990
22222
|
}
|
|
21991
22223
|
const nonInteractiveFlow = !provider.redirectUrl;
|
|
@@ -21996,10 +22228,14 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
21996
22228
|
authorizationCode,
|
|
21997
22229
|
fetchFn
|
|
21998
22230
|
});
|
|
21999
|
-
await
|
|
22231
|
+
await bindClientInformation();
|
|
22232
|
+
await provider.saveTokens({ ...tokens2, issuer });
|
|
22000
22233
|
return "AUTHORIZED";
|
|
22001
22234
|
}
|
|
22002
|
-
const tokens = await provider.tokens();
|
|
22235
|
+
const tokens = discardIfIssuerMismatch(await provider.tokens(), issuer);
|
|
22236
|
+
if (tokens?.refresh_token && tokens.issuer == null) {
|
|
22237
|
+
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.");
|
|
22238
|
+
}
|
|
22003
22239
|
if (tokens?.refresh_token) {
|
|
22004
22240
|
try {
|
|
22005
22241
|
const newTokens = await refreshAuthorization(authorizationServerUrl, {
|
|
@@ -22010,7 +22246,8 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
22010
22246
|
addClientAuthentication: provider.addClientAuthentication,
|
|
22011
22247
|
fetchFn
|
|
22012
22248
|
});
|
|
22013
|
-
await
|
|
22249
|
+
await bindClientInformation();
|
|
22250
|
+
await provider.saveTokens({ ...newTokens, issuer });
|
|
22014
22251
|
return "AUTHORIZED";
|
|
22015
22252
|
} catch (error2) {
|
|
22016
22253
|
if (!(error2 instanceof OAuthError) || error2 instanceof ServerError) {} else {
|
|
@@ -22107,7 +22344,7 @@ async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn =
|
|
|
22107
22344
|
}
|
|
22108
22345
|
async function fetchWithCorsRetry(url2, headers, fetchFn = fetch) {
|
|
22109
22346
|
try {
|
|
22110
|
-
return await fetchFn(url2, { headers });
|
|
22347
|
+
return await fetchWithinOrigin(fetchFn)(url2, { headers });
|
|
22111
22348
|
} catch (error2) {
|
|
22112
22349
|
if (error2 instanceof TypeError) {
|
|
22113
22350
|
if (headers) {
|
|
@@ -22132,7 +22369,7 @@ async function tryMetadataDiscovery(url2, protocolVersion, fetchFn = fetch) {
|
|
|
22132
22369
|
return await fetchWithCorsRetry(url2, headers, fetchFn);
|
|
22133
22370
|
}
|
|
22134
22371
|
function shouldAttemptFallback(response, pathname) {
|
|
22135
|
-
return !response || response.
|
|
22372
|
+
return !response || !response.ok && response.status < 500 && pathname !== "/";
|
|
22136
22373
|
}
|
|
22137
22374
|
async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
|
|
22138
22375
|
const issuer = new URL(serverUrl);
|
|
@@ -22198,7 +22435,7 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
|
|
|
22198
22435
|
}
|
|
22199
22436
|
if (!response.ok) {
|
|
22200
22437
|
await response.body?.cancel();
|
|
22201
|
-
if (response.status
|
|
22438
|
+
if (response.status < 500) {
|
|
22202
22439
|
continue;
|
|
22203
22440
|
}
|
|
22204
22441
|
throw new Error(`HTTP ${response.status} trying to load ${type === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${endpointUrl}`);
|
|
@@ -22230,6 +22467,9 @@ async function discoverOAuthServerInfo(serverUrl, opts) {
|
|
|
22230
22467
|
resourceMetadata
|
|
22231
22468
|
};
|
|
22232
22469
|
}
|
|
22470
|
+
function resourceIndicatorToString(resource) {
|
|
22471
|
+
return typeof resource === "string" ? resource : resource.href;
|
|
22472
|
+
}
|
|
22233
22473
|
async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
|
|
22234
22474
|
let authorizationUrl;
|
|
22235
22475
|
if (metadata) {
|
|
@@ -22261,7 +22501,7 @@ async function startAuthorization(authorizationServerUrl, { metadata, clientInfo
|
|
|
22261
22501
|
authorizationUrl.searchParams.append("prompt", "consent");
|
|
22262
22502
|
}
|
|
22263
22503
|
if (resource) {
|
|
22264
|
-
authorizationUrl.searchParams.set("resource", resource
|
|
22504
|
+
authorizationUrl.searchParams.set("resource", resourceIndicatorToString(resource));
|
|
22265
22505
|
}
|
|
22266
22506
|
return { authorizationUrl, codeVerifier };
|
|
22267
22507
|
}
|
|
@@ -22280,7 +22520,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
|
|
|
22280
22520
|
Accept: "application/json"
|
|
22281
22521
|
});
|
|
22282
22522
|
if (resource) {
|
|
22283
|
-
tokenRequestParams.set("resource", resource
|
|
22523
|
+
tokenRequestParams.set("resource", resourceIndicatorToString(resource));
|
|
22284
22524
|
}
|
|
22285
22525
|
if (addClientAuthentication) {
|
|
22286
22526
|
await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata);
|
|
@@ -22289,7 +22529,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
|
|
|
22289
22529
|
const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
|
|
22290
22530
|
applyClientAuthentication(authMethod, clientInformation, headers, tokenRequestParams);
|
|
22291
22531
|
}
|
|
22292
|
-
const response = await (fetchFn ?? fetch)(tokenUrl, {
|
|
22532
|
+
const response = await fetchWithinOrigin(fetchFn ?? fetch)(tokenUrl, {
|
|
22293
22533
|
method: "POST",
|
|
22294
22534
|
headers,
|
|
22295
22535
|
body: tokenRequestParams
|
|
@@ -22297,7 +22537,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
|
|
|
22297
22537
|
if (!response.ok) {
|
|
22298
22538
|
throw await parseErrorResponse(response);
|
|
22299
22539
|
}
|
|
22300
|
-
return
|
|
22540
|
+
return TokenResponseSchema.parse(await response.json());
|
|
22301
22541
|
}
|
|
22302
22542
|
async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }) {
|
|
22303
22543
|
const tokenRequestParams = new URLSearchParams({
|
|
@@ -22315,6 +22555,15 @@ async function refreshAuthorization(authorizationServerUrl, { metadata, clientIn
|
|
|
22315
22555
|
return { refresh_token: refreshToken, ...tokens };
|
|
22316
22556
|
}
|
|
22317
22557
|
async function fetchToken(provider, authorizationServerUrl, { metadata, resource, authorizationCode, fetchFn } = {}) {
|
|
22558
|
+
const readClientInformation = async () => {
|
|
22559
|
+
const storedClientInformation = await provider.clientInformation();
|
|
22560
|
+
const checked = discardIfIssuerMismatch(storedClientInformation, String(authorizationServerUrl));
|
|
22561
|
+
if (storedClientInformation && !checked) {
|
|
22562
|
+
throw boundElsewhereError(storedClientInformation, String(authorizationServerUrl));
|
|
22563
|
+
}
|
|
22564
|
+
return checked;
|
|
22565
|
+
};
|
|
22566
|
+
let clientInformation = await readClientInformation();
|
|
22318
22567
|
const scope = provider.clientMetadata.scope;
|
|
22319
22568
|
let tokenRequestParams;
|
|
22320
22569
|
if (provider.prepareTokenRequest) {
|
|
@@ -22330,11 +22579,11 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
|
|
|
22330
22579
|
const codeVerifier = await provider.codeVerifier();
|
|
22331
22580
|
tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, provider.redirectUrl);
|
|
22332
22581
|
}
|
|
22333
|
-
|
|
22582
|
+
clientInformation ?? (clientInformation = await readClientInformation());
|
|
22334
22583
|
return executeTokenRequest(authorizationServerUrl, {
|
|
22335
22584
|
metadata,
|
|
22336
22585
|
tokenRequestParams,
|
|
22337
|
-
clientInformation
|
|
22586
|
+
clientInformation,
|
|
22338
22587
|
addClientAuthentication: provider.addClientAuthentication,
|
|
22339
22588
|
resource,
|
|
22340
22589
|
fetchFn
|
|
@@ -22350,7 +22599,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
|
|
|
22350
22599
|
} else {
|
|
22351
22600
|
registrationUrl = new URL("/register", authorizationServerUrl);
|
|
22352
22601
|
}
|
|
22353
|
-
const response = await (fetchFn ?? fetch)(registrationUrl, {
|
|
22602
|
+
const response = await fetchWithinOrigin(fetchFn ?? fetch)(registrationUrl, {
|
|
22354
22603
|
method: "POST",
|
|
22355
22604
|
headers: {
|
|
22356
22605
|
"Content-Type": "application/json"
|
|
@@ -22363,7 +22612,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
|
|
|
22363
22612
|
if (!response.ok) {
|
|
22364
22613
|
throw await parseErrorResponse(response);
|
|
22365
22614
|
}
|
|
22366
|
-
return
|
|
22615
|
+
return RegistrationResponseSchema.parse(await response.json());
|
|
22367
22616
|
}
|
|
22368
22617
|
|
|
22369
22618
|
// ../../node_modules/eventsource-parser/dist/index.js
|
|
@@ -22576,9 +22825,18 @@ class StreamableHTTPClientTransport {
|
|
|
22576
22825
|
this._authProvider = opts?.authProvider;
|
|
22577
22826
|
this._fetch = opts?.fetch;
|
|
22578
22827
|
this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
22828
|
+
this._followRedirects = opts?.redirectPolicy === "follow";
|
|
22829
|
+
if (this._followRedirects) {
|
|
22830
|
+
this._fetch = fetchLeavingRedirects(this._fetch);
|
|
22831
|
+
this._fetchWithInit = fetchLeavingRedirects(this._fetchWithInit);
|
|
22832
|
+
}
|
|
22579
22833
|
this._sessionId = opts?.sessionId;
|
|
22580
22834
|
this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
|
|
22581
22835
|
}
|
|
22836
|
+
_unfollowedRedirect(response, url2) {
|
|
22837
|
+
const text = unfollowedRedirect(response, url2);
|
|
22838
|
+
return text && !this._followRedirects ? `${text} (redirectPolicy: 'same-origin')` : text;
|
|
22839
|
+
}
|
|
22582
22840
|
async _authThenStart() {
|
|
22583
22841
|
if (!this._authProvider) {
|
|
22584
22842
|
throw new UnauthorizedError("No auth provider");
|
|
@@ -22628,11 +22886,13 @@ class StreamableHTTPClientTransport {
|
|
|
22628
22886
|
if (resumptionToken) {
|
|
22629
22887
|
headers.set("last-event-id", resumptionToken);
|
|
22630
22888
|
}
|
|
22631
|
-
const
|
|
22632
|
-
|
|
22633
|
-
|
|
22634
|
-
|
|
22635
|
-
|
|
22889
|
+
const fetchFn = this._fetch ?? fetch;
|
|
22890
|
+
const init = { method: "GET", headers, signal: this._abortController?.signal };
|
|
22891
|
+
let response = await fetchFn(this._url, this._followRedirects ? init : { ...init, redirect: "manual" });
|
|
22892
|
+
const followed = this._followRedirects ? undefined : followWithinOrigin(fetchFn, this._url, init, response);
|
|
22893
|
+
if (followed) {
|
|
22894
|
+
response = await followed;
|
|
22895
|
+
}
|
|
22636
22896
|
if (!response.ok) {
|
|
22637
22897
|
await response.body?.cancel();
|
|
22638
22898
|
if (response.status === 401 && this._authProvider) {
|
|
@@ -22641,7 +22901,7 @@ class StreamableHTTPClientTransport {
|
|
|
22641
22901
|
if (response.status === 405) {
|
|
22642
22902
|
return;
|
|
22643
22903
|
}
|
|
22644
|
-
throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${response.statusText}`);
|
|
22904
|
+
throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${this._unfollowedRedirect(response, this._url) ?? response.statusText}`);
|
|
22645
22905
|
}
|
|
22646
22906
|
this._handleSseStream(response.body, options, true);
|
|
22647
22907
|
} catch (error2) {
|
|
@@ -22789,7 +23049,7 @@ class StreamableHTTPClientTransport {
|
|
|
22789
23049
|
body: JSON.stringify(message),
|
|
22790
23050
|
signal: this._abortController?.signal
|
|
22791
23051
|
};
|
|
22792
|
-
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
23052
|
+
const response = await fetchWithinOrigin(this._fetch ?? fetch)(this._url, init);
|
|
22793
23053
|
const sessionId = response.headers.get("mcp-session-id");
|
|
22794
23054
|
if (sessionId) {
|
|
22795
23055
|
this._sessionId = sessionId;
|
|
@@ -22841,7 +23101,7 @@ class StreamableHTTPClientTransport {
|
|
|
22841
23101
|
return this.send(message);
|
|
22842
23102
|
}
|
|
22843
23103
|
}
|
|
22844
|
-
throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
|
|
23104
|
+
throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${this._unfollowedRedirect(response, this._url) ?? text}`);
|
|
22845
23105
|
}
|
|
22846
23106
|
this._hasCompletedAuthFlow = false;
|
|
22847
23107
|
this._lastUpscopingHeader = undefined;
|
|
@@ -22854,11 +23114,12 @@ class StreamableHTTPClientTransport {
|
|
|
22854
23114
|
}
|
|
22855
23115
|
const messages = Array.isArray(message) ? message : [message];
|
|
22856
23116
|
const hasRequests = messages.filter((msg) => ("method" in msg) && ("id" in msg) && msg.id !== undefined).length > 0;
|
|
22857
|
-
const
|
|
23117
|
+
const contentType2 = response.headers.get("content-type");
|
|
23118
|
+
const responseMediaType = mediaTypeEssence(contentType2);
|
|
22858
23119
|
if (hasRequests) {
|
|
22859
|
-
if (
|
|
23120
|
+
if (responseMediaType === "text/event-stream") {
|
|
22860
23121
|
this._handleSseStream(response.body, { onresumptiontoken }, false);
|
|
22861
|
-
} else if (
|
|
23122
|
+
} else if (responseMediaType === "application/json") {
|
|
22862
23123
|
const data = await response.json();
|
|
22863
23124
|
const responseMessages = Array.isArray(data) ? data.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data)];
|
|
22864
23125
|
for (const msg of responseMessages) {
|
|
@@ -22866,7 +23127,7 @@ class StreamableHTTPClientTransport {
|
|
|
22866
23127
|
}
|
|
22867
23128
|
} else {
|
|
22868
23129
|
await response.body?.cancel();
|
|
22869
|
-
throw new StreamableHTTPError(-1, `Unexpected content type: ${
|
|
23130
|
+
throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType2}`);
|
|
22870
23131
|
}
|
|
22871
23132
|
} else {
|
|
22872
23133
|
await response.body?.cancel();
|
|
@@ -22891,10 +23152,10 @@ class StreamableHTTPClientTransport {
|
|
|
22891
23152
|
headers,
|
|
22892
23153
|
signal: this._abortController?.signal
|
|
22893
23154
|
};
|
|
22894
|
-
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
23155
|
+
const response = await fetchWithinOrigin(this._fetch ?? fetch)(this._url, init);
|
|
22895
23156
|
await response.body?.cancel();
|
|
22896
23157
|
if (!response.ok && response.status !== 405) {
|
|
22897
|
-
throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
|
|
23158
|
+
throw new StreamableHTTPError(response.status, `Failed to terminate session: ${this._unfollowedRedirect(response, this._url) ?? response.statusText}`);
|
|
22898
23159
|
}
|
|
22899
23160
|
this._sessionId = undefined;
|
|
22900
23161
|
} catch (error2) {
|
|
@@ -23100,4 +23361,4 @@ var registerCommands = async (program2) => {
|
|
|
23100
23361
|
|
|
23101
23362
|
export { Command, metadata, registerCommands };
|
|
23102
23363
|
|
|
23103
|
-
//# debugId=
|
|
23364
|
+
//# debugId=90CDA8549CF3B5BB64756E2164756E21
|
package/dist/tool.js
CHANGED
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.203.0-preview.
|
|
5
|
+
"version": "1.203.0-preview.222",
|
|
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": "
|
|
30
|
+
"gitHead": "12a014419d2fcd64b661bf97ff2dfc8b26343115"
|
|
31
31
|
}
|