@uipath/docsai-tool 1.202.1-preview.220 → 1.202.1-preview.238
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-ag92wfdf.js → tool-cvznhv4e.js} +544 -66
- 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,11 +8984,117 @@ 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
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
8991
|
-
version: "1.202.1-preview.
|
|
9097
|
+
version: "1.202.1-preview.238",
|
|
8992
9098
|
description: "Search UiPath documentation with AI-powered answers.",
|
|
8993
9099
|
private: false,
|
|
8994
9100
|
repository: {
|
|
@@ -9024,7 +9130,7 @@ var package_default = {
|
|
|
9024
9130
|
devDependencies: {
|
|
9025
9131
|
"@uipath/auth": "workspace:*",
|
|
9026
9132
|
"@uipath/common": "workspace:*",
|
|
9027
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
9133
|
+
"@modelcontextprotocol/sdk": "^1.31.0",
|
|
9028
9134
|
"@types/node": "^25.5.2",
|
|
9029
9135
|
commander: "^14.0.3",
|
|
9030
9136
|
typescript: "^7.0.2"
|
|
@@ -11341,7 +11447,165 @@ class FilterImplicitLimitError extends Error {
|
|
|
11341
11447
|
this.instructions = "Pass --limit <n> to choose how many records the filter applies to. " + "To filter over all records, pass the command's maximum accepted --limit (see the option's description in --help).";
|
|
11342
11448
|
}
|
|
11343
11449
|
}
|
|
11344
|
-
function
|
|
11450
|
+
function countRecords(data) {
|
|
11451
|
+
if (Array.isArray(data))
|
|
11452
|
+
return data.length;
|
|
11453
|
+
return data == null ? 0 : 1;
|
|
11454
|
+
}
|
|
11455
|
+
function availableFields(data) {
|
|
11456
|
+
const records = Array.isArray(data) ? data : [data];
|
|
11457
|
+
const keys = new Set;
|
|
11458
|
+
for (const record of records) {
|
|
11459
|
+
if (record && typeof record === "object" && !Array.isArray(record)) {
|
|
11460
|
+
for (const key of Object.keys(record))
|
|
11461
|
+
keys.add(key);
|
|
11462
|
+
}
|
|
11463
|
+
}
|
|
11464
|
+
return [...keys];
|
|
11465
|
+
}
|
|
11466
|
+
function decodeQuotedIdentifier(whole, inner) {
|
|
11467
|
+
const [error, decoded] = catchError(() => JSON.parse(whole));
|
|
11468
|
+
if (!error && typeof decoded === "string")
|
|
11469
|
+
return decoded;
|
|
11470
|
+
return inner.replace(/\\(.)/g, "$1");
|
|
11471
|
+
}
|
|
11472
|
+
function referencedFields(filter) {
|
|
11473
|
+
const top = new Set;
|
|
11474
|
+
const nested = new Set;
|
|
11475
|
+
const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
|
|
11476
|
+
const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
|
|
11477
|
+
const quoted = [];
|
|
11478
|
+
const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
|
|
11479
|
+
const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
|
|
11480
|
+
if (!isAlias) {
|
|
11481
|
+
quoted.push({
|
|
11482
|
+
name: decodeQuotedIdentifier(whole, name),
|
|
11483
|
+
index,
|
|
11484
|
+
tail: isPathTail(withoutValueLiterals, index)
|
|
11485
|
+
});
|
|
11486
|
+
}
|
|
11487
|
+
return `"${" ".repeat(whole.length - 2)}"`;
|
|
11488
|
+
});
|
|
11489
|
+
const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
|
|
11490
|
+
const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
|
|
11491
|
+
const place = (name, index, tail) => {
|
|
11492
|
+
if (tail || index >= rootEnd)
|
|
11493
|
+
nested.add(name);
|
|
11494
|
+
else
|
|
11495
|
+
top.add(name);
|
|
11496
|
+
};
|
|
11497
|
+
for (const entry of quoted)
|
|
11498
|
+
place(entry.name, entry.index, entry.tail);
|
|
11499
|
+
const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
|
|
11500
|
+
const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
|
|
11501
|
+
for (const match of identifiers) {
|
|
11502
|
+
const [, name, trailing] = match;
|
|
11503
|
+
if (trailing || reserved.has(name))
|
|
11504
|
+
continue;
|
|
11505
|
+
place(name, match.index, isPathTail(withoutLiterals, match.index));
|
|
11506
|
+
}
|
|
11507
|
+
return {
|
|
11508
|
+
top: [...top],
|
|
11509
|
+
nested: [...nested].filter((name) => !top.has(name)),
|
|
11510
|
+
hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
|
|
11511
|
+
};
|
|
11512
|
+
}
|
|
11513
|
+
function appearsBelowTopLevel(data, name) {
|
|
11514
|
+
let budget = 2000;
|
|
11515
|
+
const visit = (value, depth) => {
|
|
11516
|
+
if (budget-- <= 0 || depth > 4)
|
|
11517
|
+
return false;
|
|
11518
|
+
if (value === null || typeof value !== "object")
|
|
11519
|
+
return false;
|
|
11520
|
+
if (Array.isArray(value))
|
|
11521
|
+
return value.some((entry) => visit(entry, depth));
|
|
11522
|
+
const record = value;
|
|
11523
|
+
if (depth > 0 && Object.hasOwn(record, name))
|
|
11524
|
+
return true;
|
|
11525
|
+
return Object.values(record).some((entry) => visit(entry, depth + 1));
|
|
11526
|
+
};
|
|
11527
|
+
return visit(data, 0);
|
|
11528
|
+
}
|
|
11529
|
+
function alwaysNullKeys(records) {
|
|
11530
|
+
const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
|
|
11531
|
+
if (objects.length === 0 || objects.length !== records.length)
|
|
11532
|
+
return [];
|
|
11533
|
+
const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
|
|
11534
|
+
if (keys.length === 0)
|
|
11535
|
+
return [];
|
|
11536
|
+
const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
|
|
11537
|
+
return nullKeys.length === keys.length ? nullKeys : [];
|
|
11538
|
+
}
|
|
11539
|
+
function carriesOnlyNulls(value) {
|
|
11540
|
+
if (value === null)
|
|
11541
|
+
return true;
|
|
11542
|
+
if (Array.isArray(value)) {
|
|
11543
|
+
return value.length > 0 && value.every(carriesOnlyNulls);
|
|
11544
|
+
}
|
|
11545
|
+
if (typeof value === "object" && value !== undefined) {
|
|
11546
|
+
const values = Object.values(value);
|
|
11547
|
+
return values.length > 0 && values.every(carriesOnlyNulls);
|
|
11548
|
+
}
|
|
11549
|
+
return false;
|
|
11550
|
+
}
|
|
11551
|
+
function nameList(names, cap2 = 12) {
|
|
11552
|
+
const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
|
|
11553
|
+
const rest = names.length - shown.length;
|
|
11554
|
+
return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
|
|
11555
|
+
}
|
|
11556
|
+
function buildFilterWarning(filter, data, outcome) {
|
|
11557
|
+
const present = availableFields(data);
|
|
11558
|
+
const refs = referencedFields(filter);
|
|
11559
|
+
const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
|
|
11560
|
+
const unchecked = refs.nested.filter((name) => !present.includes(name));
|
|
11561
|
+
const count = countRecords(data);
|
|
11562
|
+
const scope = `${count} record(s)`;
|
|
11563
|
+
const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
|
|
11564
|
+
const soundness = unchecked.length > 0 ? `${nameList(unchecked)} ${unchecked.length === 1 ? "reads" : "read"} below the top level, so ${unchecked.length === 1 ? "it was" : "they were"} not checked against the record keys` : refs.top.length > 0 ? "every field it names exists" : "";
|
|
11565
|
+
const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
|
|
11566
|
+
let detail;
|
|
11567
|
+
let lede;
|
|
11568
|
+
if (outcome.kind === "null-elements") {
|
|
11569
|
+
lede = "returned only null values";
|
|
11570
|
+
const projected = `all ${outcome.count} of the elements it projected are null`;
|
|
11571
|
+
if (unknown.length > 0) {
|
|
11572
|
+
detail = `${projected}, because ${isNotAField(unknown)}`;
|
|
11573
|
+
} else if (unchecked.length > 0) {
|
|
11574
|
+
detail = withSoundness(projected);
|
|
11575
|
+
} else {
|
|
11576
|
+
detail = `${projected}, and every field it names exists — a multi-select list ` + `(\`[A, B]\`) reads each entry against \`Data\` itself, so on a list ` + `result use \`[].[A, B]\` or \`[].{a: A, b: B}\` to read the records`;
|
|
11577
|
+
}
|
|
11578
|
+
} else if (outcome.kind === "null-rows") {
|
|
11579
|
+
lede = "returned only null values";
|
|
11580
|
+
const projected = `every value it projected is null on all ${outcome.count} row(s)`;
|
|
11581
|
+
detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
|
|
11582
|
+
} else if (outcome.kind === "null-values") {
|
|
11583
|
+
lede = "returned only null values";
|
|
11584
|
+
const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
|
|
11585
|
+
const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
|
|
11586
|
+
if (sameSet) {
|
|
11587
|
+
detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
|
|
11588
|
+
} else if (unknown.length > 0) {
|
|
11589
|
+
detail = `${projected}, because ${isNotAField(unknown)}`;
|
|
11590
|
+
} else {
|
|
11591
|
+
detail = withSoundness(`${projected} on all ${scope}`);
|
|
11592
|
+
}
|
|
11593
|
+
} else {
|
|
11594
|
+
lede = "returned nothing";
|
|
11595
|
+
if (unknown.length > 0) {
|
|
11596
|
+
detail = isNotAField(unknown);
|
|
11597
|
+
} else {
|
|
11598
|
+
const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
|
|
11599
|
+
detail = withSoundness(`${selection} — it read ${scope}`);
|
|
11600
|
+
}
|
|
11601
|
+
}
|
|
11602
|
+
const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
|
|
11603
|
+
return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
|
|
11604
|
+
}
|
|
11605
|
+
function appendWarning(existing, note) {
|
|
11606
|
+
return existing ? `${existing} ${note}` : note;
|
|
11607
|
+
}
|
|
11608
|
+
function applyFilter(data, filter, onWarning) {
|
|
11345
11609
|
const codec = requireJmespath();
|
|
11346
11610
|
let result;
|
|
11347
11611
|
try {
|
|
@@ -11349,9 +11613,34 @@ function applyFilter(data, filter) {
|
|
|
11349
11613
|
} catch (err) {
|
|
11350
11614
|
throw new FilterEvaluationError(filter, err);
|
|
11351
11615
|
}
|
|
11352
|
-
|
|
11616
|
+
const inputCount = countRecords(data);
|
|
11617
|
+
const warn = (outcome) => {
|
|
11618
|
+
if (inputCount === 0)
|
|
11619
|
+
return;
|
|
11620
|
+
const note = buildFilterWarning(filter, data, outcome);
|
|
11621
|
+
getOutputSink().writeErr(`[WARN] ${note}
|
|
11622
|
+
`);
|
|
11623
|
+
onWarning?.(note);
|
|
11624
|
+
};
|
|
11625
|
+
const warnIfAllNull = (records) => {
|
|
11626
|
+
const keys = alwaysNullKeys(records);
|
|
11627
|
+
if (keys.length > 0)
|
|
11628
|
+
warn({ kind: "null-values", keys });
|
|
11629
|
+
};
|
|
11630
|
+
if (result == null) {
|
|
11631
|
+
warn({ kind: "empty" });
|
|
11353
11632
|
return [];
|
|
11633
|
+
}
|
|
11354
11634
|
if (Array.isArray(result)) {
|
|
11635
|
+
if (result.length === 0) {
|
|
11636
|
+
warn({ kind: "empty" });
|
|
11637
|
+
} else if (result.every((entry) => entry === null)) {
|
|
11638
|
+
warn({ kind: "null-elements", count: result.length });
|
|
11639
|
+
} else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
|
|
11640
|
+
warn({ kind: "null-rows", count: result.length });
|
|
11641
|
+
} else {
|
|
11642
|
+
warnIfAllNull(result);
|
|
11643
|
+
}
|
|
11355
11644
|
if (result.length > 0 && typeof result[0] !== "object") {
|
|
11356
11645
|
const fieldMatch = filter.match(/\.(\w+)$/);
|
|
11357
11646
|
const key = fieldMatch ? fieldMatch[1] : "Value";
|
|
@@ -11359,10 +11648,30 @@ function applyFilter(data, filter) {
|
|
|
11359
11648
|
}
|
|
11360
11649
|
return result;
|
|
11361
11650
|
}
|
|
11362
|
-
if (typeof result === "object")
|
|
11651
|
+
if (typeof result === "object") {
|
|
11652
|
+
warnIfAllNull([result]);
|
|
11363
11653
|
return result;
|
|
11654
|
+
}
|
|
11364
11655
|
return { Value: result };
|
|
11365
11656
|
}
|
|
11657
|
+
function filterFailureData(envelope) {
|
|
11658
|
+
const filter = getOutputFilter();
|
|
11659
|
+
const data = envelope.Data;
|
|
11660
|
+
if (!filter || data == null)
|
|
11661
|
+
return;
|
|
11662
|
+
let note;
|
|
11663
|
+
const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
|
|
11664
|
+
note = n;
|
|
11665
|
+
}));
|
|
11666
|
+
if (filterError) {
|
|
11667
|
+
envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
|
|
11668
|
+
return;
|
|
11669
|
+
}
|
|
11670
|
+
envelope.Data = filtered;
|
|
11671
|
+
if (note) {
|
|
11672
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
11673
|
+
}
|
|
11674
|
+
}
|
|
11366
11675
|
function defaultErrorCodeForResult(result) {
|
|
11367
11676
|
switch (result) {
|
|
11368
11677
|
case RESULTS.AuthenticationError:
|
|
@@ -11445,8 +11754,14 @@ var OutputFormatter;
|
|
|
11445
11754
|
}
|
|
11446
11755
|
const filter = getOutputFilter();
|
|
11447
11756
|
if (filter) {
|
|
11448
|
-
|
|
11757
|
+
let note;
|
|
11758
|
+
const filtered = applyFilter(data.Data, filter, (n) => {
|
|
11759
|
+
note = n;
|
|
11760
|
+
});
|
|
11449
11761
|
data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
|
|
11762
|
+
if (note) {
|
|
11763
|
+
data.Warning = appendWarning(data.Warning, note);
|
|
11764
|
+
}
|
|
11450
11765
|
}
|
|
11451
11766
|
logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
|
|
11452
11767
|
}
|
|
@@ -11474,6 +11789,7 @@ var OutputFormatter;
|
|
|
11474
11789
|
delete envelope.TelemetryErrorClass;
|
|
11475
11790
|
delete envelope.TelemetryTerminalOutcome;
|
|
11476
11791
|
delete envelope.TelemetryTerminalSignal;
|
|
11792
|
+
filterFailureData(envelope);
|
|
11477
11793
|
if (!suppressTelemetry) {
|
|
11478
11794
|
telemetry.trackEvent(CommonTelemetryEvents.Error, {
|
|
11479
11795
|
result: data.Result,
|
|
@@ -11522,13 +11838,20 @@ var OutputFormatter;
|
|
|
11522
11838
|
OutputFormatter.log = log;
|
|
11523
11839
|
function formatToString(data) {
|
|
11524
11840
|
const filter = getOutputFilter();
|
|
11841
|
+
const envelope = data;
|
|
11525
11842
|
if ("Data" in data && data.Data != null) {
|
|
11526
11843
|
data.Data = normalizeDataKeys(data.Data);
|
|
11527
11844
|
if (filter) {
|
|
11528
|
-
|
|
11845
|
+
let note;
|
|
11846
|
+
data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
|
|
11847
|
+
note = n;
|
|
11848
|
+
}));
|
|
11849
|
+
if (note) {
|
|
11850
|
+
envelope.Warning = appendWarning(envelope.Warning, note);
|
|
11851
|
+
}
|
|
11529
11852
|
}
|
|
11530
11853
|
}
|
|
11531
|
-
const output = normalizeOutputKeys(
|
|
11854
|
+
const output = normalizeOutputKeys(envelope);
|
|
11532
11855
|
const lines = [];
|
|
11533
11856
|
const sink = getOutputSink();
|
|
11534
11857
|
printOutput(output, getOutputFormat(), (msg) => {
|
|
@@ -19844,6 +20167,9 @@ class Protocol {
|
|
|
19844
20167
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
19845
20168
|
const handleTaskResult = async () => {
|
|
19846
20169
|
const taskId = request.params.taskId;
|
|
20170
|
+
if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
|
|
20171
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
20172
|
+
}
|
|
19847
20173
|
if (this._taskMessageQueue) {
|
|
19848
20174
|
let queuedMessage;
|
|
19849
20175
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -19874,12 +20200,12 @@ class Protocol {
|
|
|
19874
20200
|
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
19875
20201
|
}
|
|
19876
20202
|
if (!isTerminal(task.status)) {
|
|
19877
|
-
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
20203
|
+
await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
|
|
19878
20204
|
return await handleTaskResult();
|
|
19879
20205
|
}
|
|
19880
20206
|
if (isTerminal(task.status)) {
|
|
19881
20207
|
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
19882
|
-
this._clearTaskQueue(taskId);
|
|
20208
|
+
this._clearTaskQueue(taskId, extra.sessionId);
|
|
19883
20209
|
return {
|
|
19884
20210
|
...result,
|
|
19885
20211
|
_meta: {
|
|
@@ -19916,7 +20242,7 @@ class Protocol {
|
|
|
19916
20242
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
19917
20243
|
}
|
|
19918
20244
|
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
19919
|
-
this._clearTaskQueue(request.params.taskId);
|
|
20245
|
+
this._clearTaskQueue(request.params.taskId, extra.sessionId);
|
|
19920
20246
|
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
19921
20247
|
if (!cancelledTask) {
|
|
19922
20248
|
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
@@ -20039,6 +20365,19 @@ class Protocol {
|
|
|
20039
20365
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
20040
20366
|
const capturedTransport = this._transport;
|
|
20041
20367
|
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
20368
|
+
const sessionId = capturedTransport?.sessionId;
|
|
20369
|
+
const store = this._taskStore;
|
|
20370
|
+
let relatedTaskFound = true;
|
|
20371
|
+
let relatedTaskLookup;
|
|
20372
|
+
if (relatedTaskId && store && this._taskMessageQueue && sessionId !== undefined) {
|
|
20373
|
+
relatedTaskFound = false;
|
|
20374
|
+
relatedTaskLookup = (async () => {
|
|
20375
|
+
if (!await store.getTask(relatedTaskId, sessionId)) {
|
|
20376
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
|
|
20377
|
+
}
|
|
20378
|
+
relatedTaskFound = true;
|
|
20379
|
+
})();
|
|
20380
|
+
}
|
|
20042
20381
|
if (handler === undefined) {
|
|
20043
20382
|
const errorResponse = {
|
|
20044
20383
|
jsonrpc: "2.0",
|
|
@@ -20048,7 +20387,10 @@ class Protocol {
|
|
|
20048
20387
|
message: "Method not found"
|
|
20049
20388
|
}
|
|
20050
20389
|
};
|
|
20051
|
-
if (relatedTaskId &&
|
|
20390
|
+
if (relatedTaskId && relatedTaskLookup) {
|
|
20391
|
+
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
20392
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
|
|
20393
|
+
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
20052
20394
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
20053
20395
|
type: "error",
|
|
20054
20396
|
message: errorResponse,
|
|
@@ -20099,7 +20441,10 @@ class Protocol {
|
|
|
20099
20441
|
closeSSEStream: extra?.closeSSEStream,
|
|
20100
20442
|
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
20101
20443
|
};
|
|
20102
|
-
Promise.resolve().then(() => {
|
|
20444
|
+
(relatedTaskLookup ?? Promise.resolve()).then(() => {
|
|
20445
|
+
if (relatedTaskLookup && abortController.signal.aborted) {
|
|
20446
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
20447
|
+
}
|
|
20103
20448
|
if (taskCreationParams) {
|
|
20104
20449
|
this.assertTaskHandlerCapability(request.method);
|
|
20105
20450
|
}
|
|
@@ -20134,7 +20479,7 @@ class Protocol {
|
|
|
20134
20479
|
...error2["data"] !== undefined && { data: error2["data"] }
|
|
20135
20480
|
}
|
|
20136
20481
|
};
|
|
20137
|
-
if (relatedTaskId && this._taskMessageQueue) {
|
|
20482
|
+
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
20138
20483
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
20139
20484
|
type: "error",
|
|
20140
20485
|
message: errorResponse,
|
|
@@ -20522,7 +20867,7 @@ class Protocol {
|
|
|
20522
20867
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
20523
20868
|
}
|
|
20524
20869
|
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
20525
|
-
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
20870
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
|
|
20526
20871
|
}
|
|
20527
20872
|
async _clearTaskQueue(taskId, sessionId) {
|
|
20528
20873
|
if (this._taskMessageQueue) {
|
|
@@ -20541,10 +20886,10 @@ class Protocol {
|
|
|
20541
20886
|
}
|
|
20542
20887
|
}
|
|
20543
20888
|
}
|
|
20544
|
-
async _waitForTaskUpdate(taskId, signal) {
|
|
20889
|
+
async _waitForTaskUpdate(taskId, signal, sessionId) {
|
|
20545
20890
|
let interval = this._options?.defaultTaskPollInterval ?? 1000;
|
|
20546
20891
|
try {
|
|
20547
|
-
const task = await this._taskStore?.getTask(taskId);
|
|
20892
|
+
const task = await this._taskStore?.getTask(taskId, sessionId);
|
|
20548
20893
|
if (task?.pollInterval) {
|
|
20549
20894
|
interval = task.pollInterval;
|
|
20550
20895
|
}
|
|
@@ -20885,16 +21230,7 @@ class Client extends Protocol {
|
|
|
20885
21230
|
if (!methodSchema) {
|
|
20886
21231
|
throw new Error("Schema is missing a method literal");
|
|
20887
21232
|
}
|
|
20888
|
-
|
|
20889
|
-
if (isZ4Schema(methodSchema)) {
|
|
20890
|
-
const v4Schema = methodSchema;
|
|
20891
|
-
const v4Def = v4Schema._zod?.def;
|
|
20892
|
-
methodValue = v4Def?.value ?? v4Schema.value;
|
|
20893
|
-
} else {
|
|
20894
|
-
const v3Schema = methodSchema;
|
|
20895
|
-
const legacyDef = v3Schema._def;
|
|
20896
|
-
methodValue = legacyDef?.value ?? v3Schema.value;
|
|
20897
|
-
}
|
|
21233
|
+
const methodValue = getLiteralValue(methodSchema);
|
|
20898
21234
|
if (typeof methodValue !== "string") {
|
|
20899
21235
|
throw new Error("Schema method literal must be a string");
|
|
20900
21236
|
}
|
|
@@ -21255,6 +21591,23 @@ class Client extends Protocol {
|
|
|
21255
21591
|
}
|
|
21256
21592
|
}
|
|
21257
21593
|
|
|
21594
|
+
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
|
|
21595
|
+
var import_content_type = __toESM(require_content_type(), 1);
|
|
21596
|
+
function mediaTypeEssence(header) {
|
|
21597
|
+
if (!header) {
|
|
21598
|
+
return;
|
|
21599
|
+
}
|
|
21600
|
+
try {
|
|
21601
|
+
return import_content_type.default.parse(header).type;
|
|
21602
|
+
} catch {
|
|
21603
|
+
const essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
|
|
21604
|
+
if (essence === "" || header.slice(essence.length).includes(",")) {
|
|
21605
|
+
return;
|
|
21606
|
+
}
|
|
21607
|
+
return essence;
|
|
21608
|
+
}
|
|
21609
|
+
}
|
|
21610
|
+
|
|
21258
21611
|
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
|
|
21259
21612
|
function normalizeHeaders(headers) {
|
|
21260
21613
|
if (!headers)
|
|
@@ -21280,6 +21633,68 @@ function createFetchWithInit(baseFetch = fetch, baseInit) {
|
|
|
21280
21633
|
return baseFetch(url2, mergedInit);
|
|
21281
21634
|
};
|
|
21282
21635
|
}
|
|
21636
|
+
var MAX_REDIRECTS = 5;
|
|
21637
|
+
var REDIRECT_STATUSES = [301, 302, 303, 307, 308];
|
|
21638
|
+
function isWithinOrigin(from, to) {
|
|
21639
|
+
if (from.protocol === to.protocol && from.hostname === to.hostname && from.port === to.port) {
|
|
21640
|
+
return true;
|
|
21641
|
+
}
|
|
21642
|
+
return from.hostname === to.hostname && from.protocol === "http:" && from.port === "" && to.protocol === "https:" && to.port === "";
|
|
21643
|
+
}
|
|
21644
|
+
function redirectTarget(response, requestUrl) {
|
|
21645
|
+
const location = REDIRECT_STATUSES.includes(response.status) ? response.headers.get("location") : null;
|
|
21646
|
+
try {
|
|
21647
|
+
return location ? new URL(location, requestUrl) : undefined;
|
|
21648
|
+
} catch {
|
|
21649
|
+
return;
|
|
21650
|
+
}
|
|
21651
|
+
}
|
|
21652
|
+
function followWithinOrigin(baseFetch, url2, init, response, followed = 0) {
|
|
21653
|
+
const target = redirectTarget(response, url2);
|
|
21654
|
+
const keepsMethod = response.status === 307 || response.status === 308 || (init?.method ?? "GET").toUpperCase() === "GET";
|
|
21655
|
+
if (!target || followed === MAX_REDIRECTS || !keepsMethod) {
|
|
21656
|
+
return;
|
|
21657
|
+
}
|
|
21658
|
+
const from = new URL(url2);
|
|
21659
|
+
const addsUserinfo = (target.username || target.password) && (target.username !== from.username || target.password !== from.password);
|
|
21660
|
+
if (addsUserinfo || !isWithinOrigin(from, target)) {
|
|
21661
|
+
return;
|
|
21662
|
+
}
|
|
21663
|
+
return Promise.resolve(response.body?.cancel()).then(() => baseFetch(target, { ...init, redirect: "manual" })).then((next) => followWithinOrigin(baseFetch, target, init, next, followed + 1) ?? next);
|
|
21664
|
+
}
|
|
21665
|
+
var followingFetches = new WeakSet;
|
|
21666
|
+
function fetchLeavingRedirects(baseFetch) {
|
|
21667
|
+
const following = (url2, init) => (baseFetch ?? fetch)(url2, init);
|
|
21668
|
+
followingFetches.add(following);
|
|
21669
|
+
return following;
|
|
21670
|
+
}
|
|
21671
|
+
function fetchWithinOrigin(baseFetch = fetch) {
|
|
21672
|
+
if (followingFetches.has(baseFetch)) {
|
|
21673
|
+
return baseFetch;
|
|
21674
|
+
}
|
|
21675
|
+
return (url2, init) => {
|
|
21676
|
+
if (init?.redirect === "error" || init?.redirect === "manual") {
|
|
21677
|
+
return baseFetch(url2, init);
|
|
21678
|
+
}
|
|
21679
|
+
return Promise.resolve(baseFetch(url2, { ...init, redirect: "manual" })).then((response) => followWithinOrigin(baseFetch, url2, init, response) ?? response);
|
|
21680
|
+
};
|
|
21681
|
+
}
|
|
21682
|
+
function unfollowedRedirect(response, requestUrl) {
|
|
21683
|
+
if (response.type === "opaqueredirect") {
|
|
21684
|
+
return "Redirect not followed: this runtime does not expose the redirect target";
|
|
21685
|
+
}
|
|
21686
|
+
const from = response.url || requestUrl;
|
|
21687
|
+
const target = redirectTarget(response, from);
|
|
21688
|
+
if (!target) {
|
|
21689
|
+
return;
|
|
21690
|
+
}
|
|
21691
|
+
target.username = target.password = target.search = target.hash = "";
|
|
21692
|
+
if (target.protocol === "http:" && new URL(from).protocol === "https:") {
|
|
21693
|
+
target.protocol = "https:";
|
|
21694
|
+
return `Redirect to plain http not followed; try ${target.href} instead`;
|
|
21695
|
+
}
|
|
21696
|
+
return `Redirect to ${target.href} not followed`;
|
|
21697
|
+
}
|
|
21283
21698
|
|
|
21284
21699
|
// ../../node_modules/pkce-challenge/dist/index.node.js
|
|
21285
21700
|
var crypto2;
|
|
@@ -21423,7 +21838,8 @@ var OAuthTokensSchema = object2({
|
|
|
21423
21838
|
token_type: string2(),
|
|
21424
21839
|
expires_in: exports_coerce.number().optional(),
|
|
21425
21840
|
scope: string2().optional(),
|
|
21426
|
-
refresh_token: string2().optional()
|
|
21841
|
+
refresh_token: string2().optional(),
|
|
21842
|
+
issuer: string2().optional().catch(undefined)
|
|
21427
21843
|
}).strip();
|
|
21428
21844
|
var OAuthErrorResponseSchema = object2({
|
|
21429
21845
|
error: string2(),
|
|
@@ -21455,7 +21871,8 @@ var OAuthClientInformationSchema = object2({
|
|
|
21455
21871
|
client_id: string2(),
|
|
21456
21872
|
client_secret: string2().optional(),
|
|
21457
21873
|
client_id_issued_at: number2().optional(),
|
|
21458
|
-
client_secret_expires_at: number2().optional()
|
|
21874
|
+
client_secret_expires_at: number2().optional(),
|
|
21875
|
+
issuer: string2().optional().catch(undefined)
|
|
21459
21876
|
}).strip();
|
|
21460
21877
|
var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
|
|
21461
21878
|
var OAuthClientRegistrationErrorSchema = object2({
|
|
@@ -21667,10 +22084,30 @@ async function parseErrorResponse(input) {
|
|
|
21667
22084
|
const errorClass = OAUTH_ERRORS[error2] || ServerError;
|
|
21668
22085
|
return new errorClass(error_description || "", error_uri);
|
|
21669
22086
|
} catch (error2) {
|
|
21670
|
-
const
|
|
22087
|
+
const redirect = input instanceof Response ? unfollowedRedirect(input, input.url) : undefined;
|
|
22088
|
+
const errorMessage2 = `${statusCode ? `HTTP ${statusCode}: ` : ""}${redirect ?? `Invalid OAuth error response: ${error2}. Raw body: ${body}`}`;
|
|
21671
22089
|
return new ServerError(errorMessage2);
|
|
21672
22090
|
}
|
|
21673
22091
|
}
|
|
22092
|
+
function issuersMatch(a, b) {
|
|
22093
|
+
let [x, y] = [a, b];
|
|
22094
|
+
try {
|
|
22095
|
+
[x, y] = [new URL(a).href, new URL(b).href];
|
|
22096
|
+
} catch {}
|
|
22097
|
+
return x === y || x.endsWith("/") && x.slice(0, -1) === y || y.endsWith("/") && y.slice(0, -1) === x;
|
|
22098
|
+
}
|
|
22099
|
+
function discardIfIssuerMismatch(stored, issuer) {
|
|
22100
|
+
if (!stored)
|
|
22101
|
+
return;
|
|
22102
|
+
if (typeof stored.issuer !== "string")
|
|
22103
|
+
return stored.issuer == null ? stored : { ...stored, issuer: undefined };
|
|
22104
|
+
return issuersMatch(stored.issuer, issuer) ? stored : undefined;
|
|
22105
|
+
}
|
|
22106
|
+
var TokenResponseSchema = OAuthTokensSchema.omit({ issuer: true });
|
|
22107
|
+
var RegistrationResponseSchema = OAuthClientInformationFullSchema.omit({ issuer: true });
|
|
22108
|
+
function boundElsewhereError(stored, issuer) {
|
|
22109
|
+
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.");
|
|
22110
|
+
}
|
|
21674
22111
|
async function auth(provider, options) {
|
|
21675
22112
|
try {
|
|
21676
22113
|
return await authInternal(provider, options);
|
|
@@ -21723,9 +22160,23 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
21723
22160
|
authorizationServerMetadata: metadata
|
|
21724
22161
|
});
|
|
21725
22162
|
}
|
|
21726
|
-
const
|
|
22163
|
+
const issuer = String(authorizationServerUrl);
|
|
22164
|
+
const selectedResource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
22165
|
+
const resource = selectedResource && resourceMetadata && !provider.validateResourceURL ? resourceMetadata.resource : selectedResource;
|
|
21727
22166
|
const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
|
|
21728
|
-
|
|
22167
|
+
const storedClientInformation = await Promise.resolve(provider.clientInformation());
|
|
22168
|
+
let clientInformation = discardIfIssuerMismatch(storedClientInformation, issuer);
|
|
22169
|
+
const canRegisterAgain = provider.saveClientInformation !== undefined && !!provider.redirectUrl;
|
|
22170
|
+
if (storedClientInformation && !clientInformation && !canRegisterAgain) {
|
|
22171
|
+
throw boundElsewhereError(storedClientInformation, issuer);
|
|
22172
|
+
}
|
|
22173
|
+
const unstampedClientInformation = clientInformation?.issuer == null ? clientInformation : undefined;
|
|
22174
|
+
const bindClientInformation = async () => {
|
|
22175
|
+
try {
|
|
22176
|
+
if (unstampedClientInformation)
|
|
22177
|
+
await provider.saveClientInformation?.({ ...unstampedClientInformation, issuer });
|
|
22178
|
+
} catch {}
|
|
22179
|
+
};
|
|
21729
22180
|
if (!clientInformation) {
|
|
21730
22181
|
if (authorizationCode !== undefined) {
|
|
21731
22182
|
throw new Error("Existing OAuth client information is required when exchanging an authorization code");
|
|
@@ -21737,9 +22188,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
21737
22188
|
}
|
|
21738
22189
|
const shouldUseUrlBasedClientId = supportsUrlBasedClientId && clientMetadataUrl;
|
|
21739
22190
|
if (shouldUseUrlBasedClientId) {
|
|
21740
|
-
clientInformation = {
|
|
21741
|
-
client_id: clientMetadataUrl
|
|
21742
|
-
};
|
|
22191
|
+
clientInformation = { client_id: clientMetadataUrl, issuer };
|
|
21743
22192
|
await provider.saveClientInformation?.(clientInformation);
|
|
21744
22193
|
} else {
|
|
21745
22194
|
if (!provider.saveClientInformation) {
|
|
@@ -21751,8 +22200,8 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
21751
22200
|
scope: resolvedScope,
|
|
21752
22201
|
fetchFn
|
|
21753
22202
|
});
|
|
21754
|
-
|
|
21755
|
-
clientInformation
|
|
22203
|
+
clientInformation = { ...fullInformation, issuer };
|
|
22204
|
+
await provider.saveClientInformation(clientInformation);
|
|
21756
22205
|
}
|
|
21757
22206
|
}
|
|
21758
22207
|
const nonInteractiveFlow = !provider.redirectUrl;
|
|
@@ -21763,10 +22212,14 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
21763
22212
|
authorizationCode,
|
|
21764
22213
|
fetchFn
|
|
21765
22214
|
});
|
|
21766
|
-
await
|
|
22215
|
+
await bindClientInformation();
|
|
22216
|
+
await provider.saveTokens({ ...tokens2, issuer });
|
|
21767
22217
|
return "AUTHORIZED";
|
|
21768
22218
|
}
|
|
21769
|
-
const tokens = await provider.tokens();
|
|
22219
|
+
const tokens = discardIfIssuerMismatch(await provider.tokens(), issuer);
|
|
22220
|
+
if (tokens?.refresh_token && tokens.issuer == null) {
|
|
22221
|
+
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.");
|
|
22222
|
+
}
|
|
21770
22223
|
if (tokens?.refresh_token) {
|
|
21771
22224
|
try {
|
|
21772
22225
|
const newTokens = await refreshAuthorization(authorizationServerUrl, {
|
|
@@ -21777,7 +22230,8 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
21777
22230
|
addClientAuthentication: provider.addClientAuthentication,
|
|
21778
22231
|
fetchFn
|
|
21779
22232
|
});
|
|
21780
|
-
await
|
|
22233
|
+
await bindClientInformation();
|
|
22234
|
+
await provider.saveTokens({ ...newTokens, issuer });
|
|
21781
22235
|
return "AUTHORIZED";
|
|
21782
22236
|
} catch (error2) {
|
|
21783
22237
|
if (!(error2 instanceof OAuthError) || error2 instanceof ServerError) {} else {
|
|
@@ -21874,7 +22328,7 @@ async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn =
|
|
|
21874
22328
|
}
|
|
21875
22329
|
async function fetchWithCorsRetry(url2, headers, fetchFn = fetch) {
|
|
21876
22330
|
try {
|
|
21877
|
-
return await fetchFn(url2, { headers });
|
|
22331
|
+
return await fetchWithinOrigin(fetchFn)(url2, { headers });
|
|
21878
22332
|
} catch (error2) {
|
|
21879
22333
|
if (error2 instanceof TypeError) {
|
|
21880
22334
|
if (headers) {
|
|
@@ -21899,7 +22353,7 @@ async function tryMetadataDiscovery(url2, protocolVersion, fetchFn = fetch) {
|
|
|
21899
22353
|
return await fetchWithCorsRetry(url2, headers, fetchFn);
|
|
21900
22354
|
}
|
|
21901
22355
|
function shouldAttemptFallback(response, pathname) {
|
|
21902
|
-
return !response || response.
|
|
22356
|
+
return !response || !response.ok && response.status < 500 && pathname !== "/";
|
|
21903
22357
|
}
|
|
21904
22358
|
async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
|
|
21905
22359
|
const issuer = new URL(serverUrl);
|
|
@@ -21965,7 +22419,7 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
|
|
|
21965
22419
|
}
|
|
21966
22420
|
if (!response.ok) {
|
|
21967
22421
|
await response.body?.cancel();
|
|
21968
|
-
if (response.status
|
|
22422
|
+
if (response.status < 500) {
|
|
21969
22423
|
continue;
|
|
21970
22424
|
}
|
|
21971
22425
|
throw new Error(`HTTP ${response.status} trying to load ${type === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${endpointUrl}`);
|
|
@@ -21997,6 +22451,9 @@ async function discoverOAuthServerInfo(serverUrl, opts) {
|
|
|
21997
22451
|
resourceMetadata
|
|
21998
22452
|
};
|
|
21999
22453
|
}
|
|
22454
|
+
function resourceIndicatorToString(resource) {
|
|
22455
|
+
return typeof resource === "string" ? resource : resource.href;
|
|
22456
|
+
}
|
|
22000
22457
|
async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
|
|
22001
22458
|
let authorizationUrl;
|
|
22002
22459
|
if (metadata) {
|
|
@@ -22028,7 +22485,7 @@ async function startAuthorization(authorizationServerUrl, { metadata, clientInfo
|
|
|
22028
22485
|
authorizationUrl.searchParams.append("prompt", "consent");
|
|
22029
22486
|
}
|
|
22030
22487
|
if (resource) {
|
|
22031
|
-
authorizationUrl.searchParams.set("resource", resource
|
|
22488
|
+
authorizationUrl.searchParams.set("resource", resourceIndicatorToString(resource));
|
|
22032
22489
|
}
|
|
22033
22490
|
return { authorizationUrl, codeVerifier };
|
|
22034
22491
|
}
|
|
@@ -22047,7 +22504,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
|
|
|
22047
22504
|
Accept: "application/json"
|
|
22048
22505
|
});
|
|
22049
22506
|
if (resource) {
|
|
22050
|
-
tokenRequestParams.set("resource", resource
|
|
22507
|
+
tokenRequestParams.set("resource", resourceIndicatorToString(resource));
|
|
22051
22508
|
}
|
|
22052
22509
|
if (addClientAuthentication) {
|
|
22053
22510
|
await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata);
|
|
@@ -22056,7 +22513,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
|
|
|
22056
22513
|
const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
|
|
22057
22514
|
applyClientAuthentication(authMethod, clientInformation, headers, tokenRequestParams);
|
|
22058
22515
|
}
|
|
22059
|
-
const response = await (fetchFn ?? fetch)(tokenUrl, {
|
|
22516
|
+
const response = await fetchWithinOrigin(fetchFn ?? fetch)(tokenUrl, {
|
|
22060
22517
|
method: "POST",
|
|
22061
22518
|
headers,
|
|
22062
22519
|
body: tokenRequestParams
|
|
@@ -22064,7 +22521,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
|
|
|
22064
22521
|
if (!response.ok) {
|
|
22065
22522
|
throw await parseErrorResponse(response);
|
|
22066
22523
|
}
|
|
22067
|
-
return
|
|
22524
|
+
return TokenResponseSchema.parse(await response.json());
|
|
22068
22525
|
}
|
|
22069
22526
|
async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }) {
|
|
22070
22527
|
const tokenRequestParams = new URLSearchParams({
|
|
@@ -22082,6 +22539,15 @@ async function refreshAuthorization(authorizationServerUrl, { metadata, clientIn
|
|
|
22082
22539
|
return { refresh_token: refreshToken, ...tokens };
|
|
22083
22540
|
}
|
|
22084
22541
|
async function fetchToken(provider, authorizationServerUrl, { metadata, resource, authorizationCode, fetchFn } = {}) {
|
|
22542
|
+
const readClientInformation = async () => {
|
|
22543
|
+
const storedClientInformation = await provider.clientInformation();
|
|
22544
|
+
const checked = discardIfIssuerMismatch(storedClientInformation, String(authorizationServerUrl));
|
|
22545
|
+
if (storedClientInformation && !checked) {
|
|
22546
|
+
throw boundElsewhereError(storedClientInformation, String(authorizationServerUrl));
|
|
22547
|
+
}
|
|
22548
|
+
return checked;
|
|
22549
|
+
};
|
|
22550
|
+
let clientInformation = await readClientInformation();
|
|
22085
22551
|
const scope = provider.clientMetadata.scope;
|
|
22086
22552
|
let tokenRequestParams;
|
|
22087
22553
|
if (provider.prepareTokenRequest) {
|
|
@@ -22097,11 +22563,11 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
|
|
|
22097
22563
|
const codeVerifier = await provider.codeVerifier();
|
|
22098
22564
|
tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, provider.redirectUrl);
|
|
22099
22565
|
}
|
|
22100
|
-
|
|
22566
|
+
clientInformation ?? (clientInformation = await readClientInformation());
|
|
22101
22567
|
return executeTokenRequest(authorizationServerUrl, {
|
|
22102
22568
|
metadata,
|
|
22103
22569
|
tokenRequestParams,
|
|
22104
|
-
clientInformation
|
|
22570
|
+
clientInformation,
|
|
22105
22571
|
addClientAuthentication: provider.addClientAuthentication,
|
|
22106
22572
|
resource,
|
|
22107
22573
|
fetchFn
|
|
@@ -22117,7 +22583,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
|
|
|
22117
22583
|
} else {
|
|
22118
22584
|
registrationUrl = new URL("/register", authorizationServerUrl);
|
|
22119
22585
|
}
|
|
22120
|
-
const response = await (fetchFn ?? fetch)(registrationUrl, {
|
|
22586
|
+
const response = await fetchWithinOrigin(fetchFn ?? fetch)(registrationUrl, {
|
|
22121
22587
|
method: "POST",
|
|
22122
22588
|
headers: {
|
|
22123
22589
|
"Content-Type": "application/json"
|
|
@@ -22130,7 +22596,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
|
|
|
22130
22596
|
if (!response.ok) {
|
|
22131
22597
|
throw await parseErrorResponse(response);
|
|
22132
22598
|
}
|
|
22133
|
-
return
|
|
22599
|
+
return RegistrationResponseSchema.parse(await response.json());
|
|
22134
22600
|
}
|
|
22135
22601
|
|
|
22136
22602
|
// ../../node_modules/eventsource-parser/dist/index.js
|
|
@@ -22343,9 +22809,18 @@ class StreamableHTTPClientTransport {
|
|
|
22343
22809
|
this._authProvider = opts?.authProvider;
|
|
22344
22810
|
this._fetch = opts?.fetch;
|
|
22345
22811
|
this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
22812
|
+
this._followRedirects = opts?.redirectPolicy === "follow";
|
|
22813
|
+
if (this._followRedirects) {
|
|
22814
|
+
this._fetch = fetchLeavingRedirects(this._fetch);
|
|
22815
|
+
this._fetchWithInit = fetchLeavingRedirects(this._fetchWithInit);
|
|
22816
|
+
}
|
|
22346
22817
|
this._sessionId = opts?.sessionId;
|
|
22347
22818
|
this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
|
|
22348
22819
|
}
|
|
22820
|
+
_unfollowedRedirect(response, url2) {
|
|
22821
|
+
const text = unfollowedRedirect(response, url2);
|
|
22822
|
+
return text && !this._followRedirects ? `${text} (redirectPolicy: 'same-origin')` : text;
|
|
22823
|
+
}
|
|
22349
22824
|
async _authThenStart() {
|
|
22350
22825
|
if (!this._authProvider) {
|
|
22351
22826
|
throw new UnauthorizedError("No auth provider");
|
|
@@ -22395,11 +22870,13 @@ class StreamableHTTPClientTransport {
|
|
|
22395
22870
|
if (resumptionToken) {
|
|
22396
22871
|
headers.set("last-event-id", resumptionToken);
|
|
22397
22872
|
}
|
|
22398
|
-
const
|
|
22399
|
-
|
|
22400
|
-
|
|
22401
|
-
|
|
22402
|
-
|
|
22873
|
+
const fetchFn = this._fetch ?? fetch;
|
|
22874
|
+
const init = { method: "GET", headers, signal: this._abortController?.signal };
|
|
22875
|
+
let response = await fetchFn(this._url, this._followRedirects ? init : { ...init, redirect: "manual" });
|
|
22876
|
+
const followed = this._followRedirects ? undefined : followWithinOrigin(fetchFn, this._url, init, response);
|
|
22877
|
+
if (followed) {
|
|
22878
|
+
response = await followed;
|
|
22879
|
+
}
|
|
22403
22880
|
if (!response.ok) {
|
|
22404
22881
|
await response.body?.cancel();
|
|
22405
22882
|
if (response.status === 401 && this._authProvider) {
|
|
@@ -22408,7 +22885,7 @@ class StreamableHTTPClientTransport {
|
|
|
22408
22885
|
if (response.status === 405) {
|
|
22409
22886
|
return;
|
|
22410
22887
|
}
|
|
22411
|
-
throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${response.statusText}`);
|
|
22888
|
+
throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${this._unfollowedRedirect(response, this._url) ?? response.statusText}`);
|
|
22412
22889
|
}
|
|
22413
22890
|
this._handleSseStream(response.body, options, true);
|
|
22414
22891
|
} catch (error2) {
|
|
@@ -22556,7 +23033,7 @@ class StreamableHTTPClientTransport {
|
|
|
22556
23033
|
body: JSON.stringify(message),
|
|
22557
23034
|
signal: this._abortController?.signal
|
|
22558
23035
|
};
|
|
22559
|
-
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
23036
|
+
const response = await fetchWithinOrigin(this._fetch ?? fetch)(this._url, init);
|
|
22560
23037
|
const sessionId = response.headers.get("mcp-session-id");
|
|
22561
23038
|
if (sessionId) {
|
|
22562
23039
|
this._sessionId = sessionId;
|
|
@@ -22608,7 +23085,7 @@ class StreamableHTTPClientTransport {
|
|
|
22608
23085
|
return this.send(message);
|
|
22609
23086
|
}
|
|
22610
23087
|
}
|
|
22611
|
-
throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
|
|
23088
|
+
throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${this._unfollowedRedirect(response, this._url) ?? text}`);
|
|
22612
23089
|
}
|
|
22613
23090
|
this._hasCompletedAuthFlow = false;
|
|
22614
23091
|
this._lastUpscopingHeader = undefined;
|
|
@@ -22621,11 +23098,12 @@ class StreamableHTTPClientTransport {
|
|
|
22621
23098
|
}
|
|
22622
23099
|
const messages = Array.isArray(message) ? message : [message];
|
|
22623
23100
|
const hasRequests = messages.filter((msg) => ("method" in msg) && ("id" in msg) && msg.id !== undefined).length > 0;
|
|
22624
|
-
const
|
|
23101
|
+
const contentType2 = response.headers.get("content-type");
|
|
23102
|
+
const responseMediaType = mediaTypeEssence(contentType2);
|
|
22625
23103
|
if (hasRequests) {
|
|
22626
|
-
if (
|
|
23104
|
+
if (responseMediaType === "text/event-stream") {
|
|
22627
23105
|
this._handleSseStream(response.body, { onresumptiontoken }, false);
|
|
22628
|
-
} else if (
|
|
23106
|
+
} else if (responseMediaType === "application/json") {
|
|
22629
23107
|
const data = await response.json();
|
|
22630
23108
|
const responseMessages = Array.isArray(data) ? data.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data)];
|
|
22631
23109
|
for (const msg of responseMessages) {
|
|
@@ -22633,7 +23111,7 @@ class StreamableHTTPClientTransport {
|
|
|
22633
23111
|
}
|
|
22634
23112
|
} else {
|
|
22635
23113
|
await response.body?.cancel();
|
|
22636
|
-
throw new StreamableHTTPError(-1, `Unexpected content type: ${
|
|
23114
|
+
throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType2}`);
|
|
22637
23115
|
}
|
|
22638
23116
|
} else {
|
|
22639
23117
|
await response.body?.cancel();
|
|
@@ -22658,10 +23136,10 @@ class StreamableHTTPClientTransport {
|
|
|
22658
23136
|
headers,
|
|
22659
23137
|
signal: this._abortController?.signal
|
|
22660
23138
|
};
|
|
22661
|
-
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
23139
|
+
const response = await fetchWithinOrigin(this._fetch ?? fetch)(this._url, init);
|
|
22662
23140
|
await response.body?.cancel();
|
|
22663
23141
|
if (!response.ok && response.status !== 405) {
|
|
22664
|
-
throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
|
|
23142
|
+
throw new StreamableHTTPError(response.status, `Failed to terminate session: ${this._unfollowedRedirect(response, this._url) ?? response.statusText}`);
|
|
22665
23143
|
}
|
|
22666
23144
|
this._sessionId = undefined;
|
|
22667
23145
|
} catch (error2) {
|
|
@@ -22867,4 +23345,4 @@ var registerCommands = async (program2) => {
|
|
|
22867
23345
|
|
|
22868
23346
|
export { Command, metadata, registerCommands };
|
|
22869
23347
|
|
|
22870
|
-
//# debugId=
|
|
23348
|
+
//# debugId=7FD41024BA25A69464756E2164756E21
|
package/dist/tool.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/docsai-tool",
|
|
3
3
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
4
|
-
"version": "1.202.1-preview.
|
|
4
|
+
"version": "1.202.1-preview.238",
|
|
5
5
|
"description": "Search UiPath documentation with AI-powered answers.",
|
|
6
6
|
"private": false,
|
|
7
7
|
"repository": {
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"files": [
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "537e43df1d3583633cfd3a0b88634f9ce3ba9d6b"
|
|
30
30
|
}
|