rainskills 0.1.0 → 0.1.2
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/README.md +156 -420
- package/SKILL.md +37 -7
- package/agents/openai.yaml +2 -2
- package/bin/rainskills-tools.js +712 -0
- package/bin/rainskills.js +1109 -4
- package/install.sh +536 -63
- package/marketplace/rainskills/.claude-plugin/plugin.json +2 -2
- package/marketplace/rainskills/.codex-plugin/plugin.json +5 -5
- package/marketplace/rainskills/skills/rainskills/SKILL.md +38 -8
- package/package.json +14 -5
- package/pi/rainskills-mcp.ts +214 -1850
- package/rainbond-app-assistant/SKILL.md +123 -49
- package/rainbond-app-assistant/evals/01-linked-topology-missing.response.md +3 -3
- package/rainbond-app-assistant/evals/02-linked-topology-building.response.md +3 -3
- package/rainbond-app-assistant/evals/03-runtime-healthy-delivery-unknown.response.md +3 -3
- package/rainbond-app-assistant/evals/04-delivered-stop-without-promotion.expected.yaml +1 -1
- package/rainbond-app-assistant/evals/04-delivered-stop-without-promotion.response.md +1 -1
- package/rainbond-app-assistant/evals/05-delivered-explicit-dev-to-test.response.md +3 -3
- package/rainbond-app-assistant/evals/06-manual-validation-stop.expected.yaml +1 -1
- package/rainbond-app-assistant/evals/06-manual-validation-stop.response.md +3 -3
- package/rainbond-app-assistant/evals/07-cluster-capacity-blocked.response.md +4 -4
- package/rainbond-app-assistant/evals/08-code-build-handoff-stop.response.md +2 -2
- package/rainbond-app-assistant/evals/09-source-backed-failure-no-fallback.response.md +2 -2
- package/rainbond-app-assistant/evals/10-identity-ambiguous-stop.response.md +3 -3
- package/rainbond-app-assistant/evals/12-complex-suite-needs-descriptor-stop.response.md +2 -2
- package/rainbond-app-assistant/evals/13-explicit-git-url-locks-source.response.md +2 -2
- package/rainbond-app-assistant/evals/14-strategy-switch-cleans-residue.response.md +2 -2
- package/rainbond-app-assistant/evals/15-turn-discipline-reuse-alias.response.md +2 -2
- package/rainbond-app-assistant/references/operational-reference.md +77 -0
- package/rainbond-app-assistant/references/output-contract.md +454 -0
- package/rainbond-app-assistant/references/product-object-model.md +1558 -0
- package/rainbond-app-assistant/references/workflow-rules.md +343 -0
- package/rainbond-app-assistant/schemas/app-assistant-result.schema.yaml +6 -1
- package/rainbond-app-version-assistant/SKILL.md +57 -18
- package/rainbond-delivery-verifier/SKILL.md +86 -13
- package/rainbond-env-sync/SKILL.md +52 -11
- package/rainbond-fullstack-bootstrap/SKILL.md +79 -11
- package/rainbond-fullstack-bootstrap/evals/01-reuse-only.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/02-deferred-dependency.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/03-capacity-blocked.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/04-template-skip.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/05-source-ambiguity-stop.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/06-external-artifact-unreachable.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/07-provider-connection-contract.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/08-explicit-dependency-after-manual-components.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/09-inferred-provider-consumer-gate.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/10-compose-service-name-not-hostname.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/11-reverse-proxy-not-dropped.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/12-optional-services-disclose-not-deploy.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/13-env-reference-dependency-completeness.response.md +1 -1
- package/rainbond-fullstack-bootstrap/evals/14-client-package-upload.expected.yaml +1 -1
- package/rainbond-fullstack-bootstrap/evals/14-client-package-upload.response.md +3 -3
- package/rainbond-fullstack-bootstrap/evals/15-unfinished-dockerfile-recovery.expected.yaml +25 -0
- package/rainbond-fullstack-bootstrap/evals/15-unfinished-dockerfile-recovery.response.md +44 -0
- package/rainbond-fullstack-bootstrap/evals/16-complete-cnb-recreate-confirmed.expected.yaml +25 -0
- package/rainbond-fullstack-bootstrap/evals/16-complete-cnb-recreate-confirmed.response.md +44 -0
- package/rainbond-fullstack-bootstrap/modules/10-context-loading.md +8 -8
- package/rainbond-fullstack-bootstrap/modules/30-creation-rules.md +10 -10
- package/rainbond-fullstack-bootstrap/modules/40-source-and-package-rules.md +13 -9
- package/rainbond-fullstack-bootstrap/modules/50-workflow-and-convergence.md +6 -6
- package/rainbond-fullstack-bootstrap/modules/60-verification-and-handoffs.md +4 -4
- package/rainbond-fullstack-bootstrap/modules/70-output-contract.md +3 -3
- package/rainbond-fullstack-bootstrap/references/quick-reference.md +6 -6
- package/rainbond-fullstack-bootstrap/references/source-build-parameter-guide.md +6 -6
- package/rainbond-fullstack-bootstrap/references/sql-init-recipe.md +3 -3
- package/rainbond-fullstack-bootstrap/schemas/bootstrap-result.schema.yaml +3 -2
- package/rainbond-fullstack-bootstrap/scripts/upload_local_package.py +1 -1
- package/rainbond-fullstack-bootstrap/scripts/validate_bootstrap_output.py +2 -2
- package/rainbond-fullstack-troubleshooter/SKILL.md +103 -13
- package/rainbond-fullstack-troubleshooter/evals/10-config-file-configmap-missing.expected.yaml +21 -0
- package/rainbond-fullstack-troubleshooter/evals/10-config-file-configmap-missing.response.md +51 -0
- package/rainbond-fullstack-troubleshooter/references/operational-reference.md +70 -0
- package/rainbond-fullstack-troubleshooter/references/output-contract.md +259 -0
- package/rainbond-fullstack-troubleshooter/references/root-cause-rules.md +210 -0
- package/rainbond-fullstack-troubleshooter/schemas/troubleshoot-result.schema.yaml +3 -1
- package/rainbond-fullstack-troubleshooter/scripts/validate_troubleshoot_output.py +22 -1
- package/rainbond-platform-installer/SKILL.md +73 -9
- package/rainbond-platform-installer/agents/openai.yaml +2 -2
- package/rainbond-platform-installer/references/installation-policy.json +35 -1
- package/rainbond-platform-installer/references/installation-policy.md +33 -8
- package/rainbond-platform-installer/references/troubleshooting.md +3 -2
- package/rainbond-platform-installer/scripts/auto-update.js +495 -0
- package/rainbond-platform-installer/scripts/console-origin.js +159 -0
- package/rainbond-platform-installer/scripts/environment-credentials.js +225 -0
- package/rainbond-platform-installer/scripts/environment-registry.js +349 -0
- package/rainbond-platform-installer/scripts/existing-kubernetes-installer.js +1370 -0
- package/rainbond-platform-installer/scripts/host-cluster-installer.js +2143 -0
- package/rainbond-platform-installer/scripts/local-runtime-commands.js +180 -0
- package/rainbond-platform-installer/scripts/local-runtime.js +18 -0
- package/rainbond-platform-installer/scripts/mcp-router.js +212 -0
- package/rainbond-platform-installer/scripts/mcp-server.js +79 -0
- package/rainbond-platform-installer/scripts/platform-installer.js +694 -255
- package/rainbond-platform-installer/scripts/platform-routing.js +326 -0
- package/rainbond-platform-installer/scripts/runtime-credentials.js +163 -0
- package/rainbond-platform-installer/scripts/runtime-intents.js +251 -0
- package/rainbond-platform-installer/scripts/runtime-operations.js +383 -0
- package/rainbond-platform-installer/scripts/runtime-state.js +656 -0
- package/rainbond-platform-installer/scripts/secure-state.js +59 -13
- package/rainbond-platform-installer/scripts/ssh-key-setup.js +242 -0
- package/rainbond-platform-installer/scripts/telemetry.js +244 -0
- package/rainbond-platform-installer/scripts/user-message.js +125 -0
- package/rainbond-platform-installer/scripts/windows-auth.js +1 -1
- package/rainbond-platform-installer/scripts/windows-client-config.js +101 -22
- package/rainbond-platform-installer/scripts/windows-onboarding.js +179 -83
- package/rainbond-platform-installer/scripts/windows-platform.js +3 -3
- package/rainbond-platform-installer/scripts/windows-platform.ps1 +264 -28
- package/rainbond-platform-installer/scripts/windows-read-user-environment.ps1 +16 -0
- package/rainbond-platform-query/SKILL.md +88 -0
- package/rainbond-platform-query/agents/openai.yaml +4 -0
- package/rainbond-platform-query/evals/01-current-enterprise.expected.yaml +10 -0
- package/rainbond-project-init/SKILL.md +68 -9
- package/rainbond-project-init/references/manifest-rules.md +487 -0
- package/rainbond-project-init/references/operational-reference.md +74 -0
- package/rainbond-project-init/references/output-contract.md +272 -0
- package/rainbond-project-init/references/workflow-and-verification.md +85 -0
- package/rainbond-template-installer/SKILL.md +80 -16
package/pi/rainskills-mcp.ts
CHANGED
|
@@ -3225,8 +3225,8 @@ var require_utils = __commonJS({
|
|
|
3225
3225
|
}
|
|
3226
3226
|
return ind;
|
|
3227
3227
|
}
|
|
3228
|
-
function removeDotSegments(
|
|
3229
|
-
let input =
|
|
3228
|
+
function removeDotSegments(path) {
|
|
3229
|
+
let input = path;
|
|
3230
3230
|
const output = [];
|
|
3231
3231
|
let nextSlash = -1;
|
|
3232
3232
|
let len = 0;
|
|
@@ -3478,8 +3478,8 @@ var require_schemes = __commonJS({
|
|
|
3478
3478
|
wsComponent.secure = void 0;
|
|
3479
3479
|
}
|
|
3480
3480
|
if (wsComponent.resourceName) {
|
|
3481
|
-
const [
|
|
3482
|
-
wsComponent.path =
|
|
3481
|
+
const [path, query] = wsComponent.resourceName.split("?");
|
|
3482
|
+
wsComponent.path = path && path !== "/" ? path : void 0;
|
|
3483
3483
|
wsComponent.query = query;
|
|
3484
3484
|
wsComponent.resourceName = void 0;
|
|
3485
3485
|
}
|
|
@@ -6605,7 +6605,7 @@ var require_formats = __commonJS({
|
|
|
6605
6605
|
}
|
|
6606
6606
|
exports.fullFormats = {
|
|
6607
6607
|
// date: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
6608
|
-
date: fmtDef(
|
|
6608
|
+
date: fmtDef(date3, compareDate),
|
|
6609
6609
|
// date-time: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
6610
6610
|
time: fmtDef(getTime(true), compareTime),
|
|
6611
6611
|
"date-time": fmtDef(getDateTime(true), compareDateTime),
|
|
@@ -6671,7 +6671,7 @@ var require_formats = __commonJS({
|
|
|
6671
6671
|
}
|
|
6672
6672
|
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
6673
6673
|
var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
6674
|
-
function
|
|
6674
|
+
function date3(str) {
|
|
6675
6675
|
const matches = DATE.exec(str);
|
|
6676
6676
|
if (!matches)
|
|
6677
6677
|
return false;
|
|
@@ -6740,7 +6740,7 @@ var require_formats = __commonJS({
|
|
|
6740
6740
|
const time3 = getTime(strictTimeZone);
|
|
6741
6741
|
return function date_time(str) {
|
|
6742
6742
|
const dateTime = str.split(DATE_TIME_SEPARATOR);
|
|
6743
|
-
return dateTime.length === 2 &&
|
|
6743
|
+
return dateTime.length === 2 && date3(dateTime[0]) && time3(dateTime[1]);
|
|
6744
6744
|
};
|
|
6745
6745
|
}
|
|
6746
6746
|
function compareDateTime(dt1, dt2) {
|
|
@@ -6898,12 +6898,12 @@ var require_dist = __commonJS({
|
|
|
6898
6898
|
throw new Error(`Unknown format "${name}"`);
|
|
6899
6899
|
return f;
|
|
6900
6900
|
};
|
|
6901
|
-
function addFormats(ajv, list,
|
|
6901
|
+
function addFormats(ajv, list, fs, exportName) {
|
|
6902
6902
|
var _a3;
|
|
6903
6903
|
var _b;
|
|
6904
6904
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
6905
6905
|
for (const f of list)
|
|
6906
|
-
ajv.addFormat(f,
|
|
6906
|
+
ajv.addFormat(f, fs[f]);
|
|
6907
6907
|
}
|
|
6908
6908
|
module.exports = exports = formatsPlugin;
|
|
6909
6909
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -6911,120 +6911,11 @@ var require_dist = __commonJS({
|
|
|
6911
6911
|
}
|
|
6912
6912
|
});
|
|
6913
6913
|
|
|
6914
|
-
// node_modules/content-type/index.js
|
|
6915
|
-
var require_content_type = __commonJS({
|
|
6916
|
-
"node_modules/content-type/index.js"(exports) {
|
|
6917
|
-
"use strict";
|
|
6918
|
-
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
|
|
6919
|
-
var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
|
|
6920
|
-
var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
6921
|
-
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
|
|
6922
|
-
var QUOTE_REGEXP = /([\\"])/g;
|
|
6923
|
-
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
6924
|
-
exports.format = format;
|
|
6925
|
-
exports.parse = parse3;
|
|
6926
|
-
function format(obj) {
|
|
6927
|
-
if (!obj || typeof obj !== "object") {
|
|
6928
|
-
throw new TypeError("argument obj is required");
|
|
6929
|
-
}
|
|
6930
|
-
var parameters = obj.parameters;
|
|
6931
|
-
var type = obj.type;
|
|
6932
|
-
if (!type || !TYPE_REGEXP.test(type)) {
|
|
6933
|
-
throw new TypeError("invalid type");
|
|
6934
|
-
}
|
|
6935
|
-
var string4 = type;
|
|
6936
|
-
if (parameters && typeof parameters === "object") {
|
|
6937
|
-
var param;
|
|
6938
|
-
var params = Object.keys(parameters).sort();
|
|
6939
|
-
for (var i = 0; i < params.length; i++) {
|
|
6940
|
-
param = params[i];
|
|
6941
|
-
if (!TOKEN_REGEXP.test(param)) {
|
|
6942
|
-
throw new TypeError("invalid parameter name");
|
|
6943
|
-
}
|
|
6944
|
-
string4 += "; " + param + "=" + qstring(parameters[param]);
|
|
6945
|
-
}
|
|
6946
|
-
}
|
|
6947
|
-
return string4;
|
|
6948
|
-
}
|
|
6949
|
-
function parse3(string4) {
|
|
6950
|
-
if (!string4) {
|
|
6951
|
-
throw new TypeError("argument string is required");
|
|
6952
|
-
}
|
|
6953
|
-
var header = typeof string4 === "object" ? getcontenttype(string4) : string4;
|
|
6954
|
-
if (typeof header !== "string") {
|
|
6955
|
-
throw new TypeError("argument string is required to be a string");
|
|
6956
|
-
}
|
|
6957
|
-
var index = header.indexOf(";");
|
|
6958
|
-
var type = index !== -1 ? header.slice(0, index).trim() : header.trim();
|
|
6959
|
-
if (!TYPE_REGEXP.test(type)) {
|
|
6960
|
-
throw new TypeError("invalid media type");
|
|
6961
|
-
}
|
|
6962
|
-
var obj = new ContentType(type.toLowerCase());
|
|
6963
|
-
if (index !== -1) {
|
|
6964
|
-
var key;
|
|
6965
|
-
var match;
|
|
6966
|
-
var value;
|
|
6967
|
-
PARAM_REGEXP.lastIndex = index;
|
|
6968
|
-
while (match = PARAM_REGEXP.exec(header)) {
|
|
6969
|
-
if (match.index !== index) {
|
|
6970
|
-
throw new TypeError("invalid parameter format");
|
|
6971
|
-
}
|
|
6972
|
-
index += match[0].length;
|
|
6973
|
-
key = match[1].toLowerCase();
|
|
6974
|
-
value = match[2];
|
|
6975
|
-
if (value.charCodeAt(0) === 34) {
|
|
6976
|
-
value = value.slice(1, -1);
|
|
6977
|
-
if (value.indexOf("\\") !== -1) {
|
|
6978
|
-
value = value.replace(QESC_REGEXP, "$1");
|
|
6979
|
-
}
|
|
6980
|
-
}
|
|
6981
|
-
obj.parameters[key] = value;
|
|
6982
|
-
}
|
|
6983
|
-
if (index !== header.length) {
|
|
6984
|
-
throw new TypeError("invalid parameter format");
|
|
6985
|
-
}
|
|
6986
|
-
}
|
|
6987
|
-
return obj;
|
|
6988
|
-
}
|
|
6989
|
-
function getcontenttype(obj) {
|
|
6990
|
-
var header;
|
|
6991
|
-
if (typeof obj.getHeader === "function") {
|
|
6992
|
-
header = obj.getHeader("content-type");
|
|
6993
|
-
} else if (typeof obj.headers === "object") {
|
|
6994
|
-
header = obj.headers && obj.headers["content-type"];
|
|
6995
|
-
}
|
|
6996
|
-
if (typeof header !== "string") {
|
|
6997
|
-
throw new TypeError("content-type header is missing from object");
|
|
6998
|
-
}
|
|
6999
|
-
return header;
|
|
7000
|
-
}
|
|
7001
|
-
function qstring(val) {
|
|
7002
|
-
var str = String(val);
|
|
7003
|
-
if (TOKEN_REGEXP.test(str)) {
|
|
7004
|
-
return str;
|
|
7005
|
-
}
|
|
7006
|
-
if (str.length > 0 && !TEXT_REGEXP.test(str)) {
|
|
7007
|
-
throw new TypeError("invalid parameter value");
|
|
7008
|
-
}
|
|
7009
|
-
return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"';
|
|
7010
|
-
}
|
|
7011
|
-
function ContentType(type) {
|
|
7012
|
-
this.parameters = /* @__PURE__ */ Object.create(null);
|
|
7013
|
-
this.type = type;
|
|
7014
|
-
}
|
|
7015
|
-
}
|
|
7016
|
-
});
|
|
7017
|
-
|
|
7018
6914
|
// src/pi/rainskills-mcp.ts
|
|
7019
|
-
import
|
|
7020
|
-
import os from "node:os";
|
|
7021
|
-
import path from "node:path";
|
|
6915
|
+
import { spawn } from "node:child_process";
|
|
7022
6916
|
|
|
7023
6917
|
// node_modules/zod/v4/core/core.js
|
|
7024
6918
|
var _a;
|
|
7025
|
-
var NEVER = /* @__PURE__ */ Object.freeze({
|
|
7026
|
-
status: "aborted"
|
|
7027
|
-
});
|
|
7028
6919
|
// @__NO_SIDE_EFFECTS__
|
|
7029
6920
|
function $constructor(name, initializer3, params) {
|
|
7030
6921
|
function init(inst, def) {
|
|
@@ -7264,10 +7155,10 @@ function mergeDefs(...defs) {
|
|
|
7264
7155
|
function cloneDef(schema) {
|
|
7265
7156
|
return mergeDefs(schema._zod.def);
|
|
7266
7157
|
}
|
|
7267
|
-
function getElementAtPath(obj,
|
|
7268
|
-
if (!
|
|
7158
|
+
function getElementAtPath(obj, path) {
|
|
7159
|
+
if (!path)
|
|
7269
7160
|
return obj;
|
|
7270
|
-
return
|
|
7161
|
+
return path.reduce((acc, key) => acc?.[key], obj);
|
|
7271
7162
|
}
|
|
7272
7163
|
function promiseAllObject(promisesObj) {
|
|
7273
7164
|
const keys = Object.keys(promisesObj);
|
|
@@ -7676,11 +7567,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
7676
7567
|
}
|
|
7677
7568
|
return false;
|
|
7678
7569
|
}
|
|
7679
|
-
function prefixIssues(
|
|
7570
|
+
function prefixIssues(path, issues) {
|
|
7680
7571
|
return issues.map((iss) => {
|
|
7681
7572
|
var _a3;
|
|
7682
7573
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
7683
|
-
iss.path.unshift(
|
|
7574
|
+
iss.path.unshift(path);
|
|
7684
7575
|
return iss;
|
|
7685
7576
|
});
|
|
7686
7577
|
}
|
|
@@ -7827,16 +7718,16 @@ function flattenError(error2, mapper = (issue2) => issue2.message) {
|
|
|
7827
7718
|
}
|
|
7828
7719
|
function formatError(error2, mapper = (issue2) => issue2.message) {
|
|
7829
7720
|
const fieldErrors = { _errors: [] };
|
|
7830
|
-
const processError = (error3,
|
|
7721
|
+
const processError = (error3, path = []) => {
|
|
7831
7722
|
for (const issue2 of error3.issues) {
|
|
7832
7723
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
7833
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
7724
|
+
issue2.errors.map((issues) => processError({ issues }, [...path, ...issue2.path]));
|
|
7834
7725
|
} else if (issue2.code === "invalid_key") {
|
|
7835
|
-
processError({ issues: issue2.issues }, [...
|
|
7726
|
+
processError({ issues: issue2.issues }, [...path, ...issue2.path]);
|
|
7836
7727
|
} else if (issue2.code === "invalid_element") {
|
|
7837
|
-
processError({ issues: issue2.issues }, [...
|
|
7728
|
+
processError({ issues: issue2.issues }, [...path, ...issue2.path]);
|
|
7838
7729
|
} else {
|
|
7839
|
-
const fullpath = [...
|
|
7730
|
+
const fullpath = [...path, ...issue2.path];
|
|
7840
7731
|
if (fullpath.length === 0) {
|
|
7841
7732
|
fieldErrors._errors.push(mapper(issue2));
|
|
7842
7733
|
} else {
|
|
@@ -7991,7 +7882,6 @@ var string = (params) => {
|
|
|
7991
7882
|
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
7992
7883
|
return new RegExp(`^${regex}$`);
|
|
7993
7884
|
};
|
|
7994
|
-
var bigint = /^-?\d+n?$/;
|
|
7995
7885
|
var integer = /^-?\d+$/;
|
|
7996
7886
|
var number = /^-?\d+(?:\.\d+)?$/;
|
|
7997
7887
|
var boolean = /^(?:true|false)$/i;
|
|
@@ -8614,10 +8504,10 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
|
8614
8504
|
return;
|
|
8615
8505
|
}
|
|
8616
8506
|
}
|
|
8617
|
-
const
|
|
8507
|
+
const url = new URL(trimmed);
|
|
8618
8508
|
if (def.hostname) {
|
|
8619
8509
|
def.hostname.lastIndex = 0;
|
|
8620
|
-
if (!def.hostname.test(
|
|
8510
|
+
if (!def.hostname.test(url.hostname)) {
|
|
8621
8511
|
payload.issues.push({
|
|
8622
8512
|
code: "invalid_format",
|
|
8623
8513
|
format: "url",
|
|
@@ -8631,7 +8521,7 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
|
8631
8521
|
}
|
|
8632
8522
|
if (def.protocol) {
|
|
8633
8523
|
def.protocol.lastIndex = 0;
|
|
8634
|
-
if (!def.protocol.test(
|
|
8524
|
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
|
|
8635
8525
|
payload.issues.push({
|
|
8636
8526
|
code: "invalid_format",
|
|
8637
8527
|
format: "url",
|
|
@@ -8644,7 +8534,7 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
|
8644
8534
|
}
|
|
8645
8535
|
}
|
|
8646
8536
|
if (def.normalize) {
|
|
8647
|
-
payload.value =
|
|
8537
|
+
payload.value = url.href;
|
|
8648
8538
|
} else {
|
|
8649
8539
|
payload.value = trimmed;
|
|
8650
8540
|
}
|
|
@@ -8899,26 +8789,6 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
|
8899
8789
|
return payload;
|
|
8900
8790
|
};
|
|
8901
8791
|
});
|
|
8902
|
-
var $ZodBigInt = /* @__PURE__ */ $constructor("$ZodBigInt", (inst, def) => {
|
|
8903
|
-
$ZodType.init(inst, def);
|
|
8904
|
-
inst._zod.pattern = bigint;
|
|
8905
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
8906
|
-
if (def.coerce)
|
|
8907
|
-
try {
|
|
8908
|
-
payload.value = BigInt(payload.value);
|
|
8909
|
-
} catch (_) {
|
|
8910
|
-
}
|
|
8911
|
-
if (typeof payload.value === "bigint")
|
|
8912
|
-
return payload;
|
|
8913
|
-
payload.issues.push({
|
|
8914
|
-
expected: "bigint",
|
|
8915
|
-
code: "invalid_type",
|
|
8916
|
-
input: payload.value,
|
|
8917
|
-
inst
|
|
8918
|
-
});
|
|
8919
|
-
return payload;
|
|
8920
|
-
};
|
|
8921
|
-
});
|
|
8922
8792
|
var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
|
|
8923
8793
|
$ZodType.init(inst, def);
|
|
8924
8794
|
inst._zod.pattern = _null;
|
|
@@ -8936,10 +8806,6 @@ var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
|
|
|
8936
8806
|
return payload;
|
|
8937
8807
|
};
|
|
8938
8808
|
});
|
|
8939
|
-
var $ZodAny = /* @__PURE__ */ $constructor("$ZodAny", (inst, def) => {
|
|
8940
|
-
$ZodType.init(inst, def);
|
|
8941
|
-
inst._zod.parse = (payload) => payload;
|
|
8942
|
-
});
|
|
8943
8809
|
var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
8944
8810
|
$ZodType.init(inst, def);
|
|
8945
8811
|
inst._zod.parse = (payload) => payload;
|
|
@@ -8956,30 +8822,6 @@ var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
|
8956
8822
|
return payload;
|
|
8957
8823
|
};
|
|
8958
8824
|
});
|
|
8959
|
-
var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
8960
|
-
$ZodType.init(inst, def);
|
|
8961
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
8962
|
-
if (def.coerce) {
|
|
8963
|
-
try {
|
|
8964
|
-
payload.value = new Date(payload.value);
|
|
8965
|
-
} catch (_err) {
|
|
8966
|
-
}
|
|
8967
|
-
}
|
|
8968
|
-
const input = payload.value;
|
|
8969
|
-
const isDate = input instanceof Date;
|
|
8970
|
-
const isValidDate = isDate && !Number.isNaN(input.getTime());
|
|
8971
|
-
if (isValidDate)
|
|
8972
|
-
return payload;
|
|
8973
|
-
payload.issues.push({
|
|
8974
|
-
expected: "date",
|
|
8975
|
-
code: "invalid_type",
|
|
8976
|
-
input,
|
|
8977
|
-
...isDate ? { received: "Invalid Date" } : {},
|
|
8978
|
-
inst
|
|
8979
|
-
});
|
|
8980
|
-
return payload;
|
|
8981
|
-
};
|
|
8982
|
-
});
|
|
8983
8825
|
function handleArrayResult(result, final, index) {
|
|
8984
8826
|
if (result.issues.length) {
|
|
8985
8827
|
final.issues.push(...prefixIssues(index, result.issues));
|
|
@@ -10132,14 +9974,6 @@ function _string(Class2, params) {
|
|
|
10132
9974
|
});
|
|
10133
9975
|
}
|
|
10134
9976
|
// @__NO_SIDE_EFFECTS__
|
|
10135
|
-
function _coercedString(Class2, params) {
|
|
10136
|
-
return new Class2({
|
|
10137
|
-
type: "string",
|
|
10138
|
-
coerce: true,
|
|
10139
|
-
...normalizeParams(params)
|
|
10140
|
-
});
|
|
10141
|
-
}
|
|
10142
|
-
// @__NO_SIDE_EFFECTS__
|
|
10143
9977
|
function _email(Class2, params) {
|
|
10144
9978
|
return new Class2({
|
|
10145
9979
|
type: "string",
|
|
@@ -10411,15 +10245,6 @@ function _number(Class2, params) {
|
|
|
10411
10245
|
});
|
|
10412
10246
|
}
|
|
10413
10247
|
// @__NO_SIDE_EFFECTS__
|
|
10414
|
-
function _coercedNumber(Class2, params) {
|
|
10415
|
-
return new Class2({
|
|
10416
|
-
type: "number",
|
|
10417
|
-
coerce: true,
|
|
10418
|
-
checks: [],
|
|
10419
|
-
...normalizeParams(params)
|
|
10420
|
-
});
|
|
10421
|
-
}
|
|
10422
|
-
// @__NO_SIDE_EFFECTS__
|
|
10423
10248
|
function _int(Class2, params) {
|
|
10424
10249
|
return new Class2({
|
|
10425
10250
|
type: "number",
|
|
@@ -10437,22 +10262,6 @@ function _boolean(Class2, params) {
|
|
|
10437
10262
|
});
|
|
10438
10263
|
}
|
|
10439
10264
|
// @__NO_SIDE_EFFECTS__
|
|
10440
|
-
function _coercedBoolean(Class2, params) {
|
|
10441
|
-
return new Class2({
|
|
10442
|
-
type: "boolean",
|
|
10443
|
-
coerce: true,
|
|
10444
|
-
...normalizeParams(params)
|
|
10445
|
-
});
|
|
10446
|
-
}
|
|
10447
|
-
// @__NO_SIDE_EFFECTS__
|
|
10448
|
-
function _coercedBigint(Class2, params) {
|
|
10449
|
-
return new Class2({
|
|
10450
|
-
type: "bigint",
|
|
10451
|
-
coerce: true,
|
|
10452
|
-
...normalizeParams(params)
|
|
10453
|
-
});
|
|
10454
|
-
}
|
|
10455
|
-
// @__NO_SIDE_EFFECTS__
|
|
10456
10265
|
function _null2(Class2, params) {
|
|
10457
10266
|
return new Class2({
|
|
10458
10267
|
type: "null",
|
|
@@ -10460,12 +10269,6 @@ function _null2(Class2, params) {
|
|
|
10460
10269
|
});
|
|
10461
10270
|
}
|
|
10462
10271
|
// @__NO_SIDE_EFFECTS__
|
|
10463
|
-
function _any(Class2) {
|
|
10464
|
-
return new Class2({
|
|
10465
|
-
type: "any"
|
|
10466
|
-
});
|
|
10467
|
-
}
|
|
10468
|
-
// @__NO_SIDE_EFFECTS__
|
|
10469
10272
|
function _unknown(Class2) {
|
|
10470
10273
|
return new Class2({
|
|
10471
10274
|
type: "unknown"
|
|
@@ -10479,14 +10282,6 @@ function _never(Class2, params) {
|
|
|
10479
10282
|
});
|
|
10480
10283
|
}
|
|
10481
10284
|
// @__NO_SIDE_EFFECTS__
|
|
10482
|
-
function _coercedDate(Class2, params) {
|
|
10483
|
-
return new Class2({
|
|
10484
|
-
type: "date",
|
|
10485
|
-
coerce: true,
|
|
10486
|
-
...normalizeParams(params)
|
|
10487
|
-
});
|
|
10488
|
-
}
|
|
10489
|
-
// @__NO_SIDE_EFFECTS__
|
|
10490
10285
|
function _lt(value, params) {
|
|
10491
10286
|
return new $ZodCheckLessThan({
|
|
10492
10287
|
check: "less_than",
|
|
@@ -11134,11 +10929,6 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
11134
10929
|
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
11135
10930
|
json.type = "boolean";
|
|
11136
10931
|
};
|
|
11137
|
-
var bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
11138
|
-
if (ctx.unrepresentable === "throw") {
|
|
11139
|
-
throw new Error("BigInt cannot be represented in JSON Schema");
|
|
11140
|
-
}
|
|
11141
|
-
};
|
|
11142
10932
|
var nullProcessor = (_schema, ctx, json, _params) => {
|
|
11143
10933
|
if (ctx.target === "openapi-3.0") {
|
|
11144
10934
|
json.type = "string";
|
|
@@ -11151,15 +10941,8 @@ var nullProcessor = (_schema, ctx, json, _params) => {
|
|
|
11151
10941
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
11152
10942
|
json.not = {};
|
|
11153
10943
|
};
|
|
11154
|
-
var anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
11155
|
-
};
|
|
11156
10944
|
var unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
11157
10945
|
};
|
|
11158
|
-
var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
11159
|
-
if (ctx.unrepresentable === "throw") {
|
|
11160
|
-
throw new Error("Date cannot be represented in JSON Schema");
|
|
11161
|
-
}
|
|
11162
|
-
};
|
|
11163
10946
|
var enumProcessor = (schema, _ctx, json, _params) => {
|
|
11164
10947
|
const def = schema._zod.def;
|
|
11165
10948
|
const values = getEnumValues(def.entries);
|
|
@@ -11836,9 +11619,6 @@ var ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
|
|
|
11836
11619
|
$ZodURL.init(inst, def);
|
|
11837
11620
|
ZodStringFormat.init(inst, def);
|
|
11838
11621
|
});
|
|
11839
|
-
function url(params) {
|
|
11840
|
-
return _url(ZodURL, params);
|
|
11841
|
-
}
|
|
11842
11622
|
var ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
|
|
11843
11623
|
$ZodEmoji.init(inst, def);
|
|
11844
11624
|
ZodStringFormat.init(inst, def);
|
|
@@ -11975,28 +11755,6 @@ var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
|
11975
11755
|
function boolean2(params) {
|
|
11976
11756
|
return _boolean(ZodBoolean, params);
|
|
11977
11757
|
}
|
|
11978
|
-
var ZodBigInt = /* @__PURE__ */ $constructor("ZodBigInt", (inst, def) => {
|
|
11979
|
-
$ZodBigInt.init(inst, def);
|
|
11980
|
-
ZodType.init(inst, def);
|
|
11981
|
-
inst._zod.processJSONSchema = (ctx, json, params) => bigintProcessor(inst, ctx, json, params);
|
|
11982
|
-
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
11983
|
-
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
11984
|
-
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
11985
|
-
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
11986
|
-
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
11987
|
-
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
11988
|
-
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
11989
|
-
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
11990
|
-
inst.positive = (params) => inst.check(_gt(BigInt(0), params));
|
|
11991
|
-
inst.negative = (params) => inst.check(_lt(BigInt(0), params));
|
|
11992
|
-
inst.nonpositive = (params) => inst.check(_lte(BigInt(0), params));
|
|
11993
|
-
inst.nonnegative = (params) => inst.check(_gte(BigInt(0), params));
|
|
11994
|
-
inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
|
|
11995
|
-
const bag = inst._zod.bag;
|
|
11996
|
-
inst.minValue = bag.minimum ?? null;
|
|
11997
|
-
inst.maxValue = bag.maximum ?? null;
|
|
11998
|
-
inst.format = bag.format ?? null;
|
|
11999
|
-
});
|
|
12000
11758
|
var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
12001
11759
|
$ZodNull.init(inst, def);
|
|
12002
11760
|
ZodType.init(inst, def);
|
|
@@ -12005,14 +11763,6 @@ var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
|
12005
11763
|
function _null3(params) {
|
|
12006
11764
|
return _null2(ZodNull, params);
|
|
12007
11765
|
}
|
|
12008
|
-
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
12009
|
-
$ZodAny.init(inst, def);
|
|
12010
|
-
ZodType.init(inst, def);
|
|
12011
|
-
inst._zod.processJSONSchema = (ctx, json, params) => anyProcessor(inst, ctx, json, params);
|
|
12012
|
-
});
|
|
12013
|
-
function any() {
|
|
12014
|
-
return _any(ZodAny);
|
|
12015
|
-
}
|
|
12016
11766
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
12017
11767
|
$ZodUnknown.init(inst, def);
|
|
12018
11768
|
ZodType.init(inst, def);
|
|
@@ -12029,16 +11779,6 @@ var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
|
12029
11779
|
function never(params) {
|
|
12030
11780
|
return _never(ZodNever, params);
|
|
12031
11781
|
}
|
|
12032
|
-
var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
|
|
12033
|
-
$ZodDate.init(inst, def);
|
|
12034
|
-
ZodType.init(inst, def);
|
|
12035
|
-
inst._zod.processJSONSchema = (ctx, json, params) => dateProcessor(inst, ctx, json, params);
|
|
12036
|
-
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
12037
|
-
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
12038
|
-
const c = inst._zod.bag;
|
|
12039
|
-
inst.minDate = c.minimum ? new Date(c.minimum) : null;
|
|
12040
|
-
inst.maxDate = c.maximum ? new Date(c.maximum) : null;
|
|
12041
|
-
});
|
|
12042
11782
|
var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
12043
11783
|
$ZodArray.init(inst, def);
|
|
12044
11784
|
ZodType.init(inst, def);
|
|
@@ -12444,49 +12184,6 @@ function preprocess(fn, schema) {
|
|
|
12444
12184
|
});
|
|
12445
12185
|
}
|
|
12446
12186
|
|
|
12447
|
-
// node_modules/zod/v4/classic/compat.js
|
|
12448
|
-
var ZodIssueCode = {
|
|
12449
|
-
invalid_type: "invalid_type",
|
|
12450
|
-
too_big: "too_big",
|
|
12451
|
-
too_small: "too_small",
|
|
12452
|
-
invalid_format: "invalid_format",
|
|
12453
|
-
not_multiple_of: "not_multiple_of",
|
|
12454
|
-
unrecognized_keys: "unrecognized_keys",
|
|
12455
|
-
invalid_union: "invalid_union",
|
|
12456
|
-
invalid_key: "invalid_key",
|
|
12457
|
-
invalid_element: "invalid_element",
|
|
12458
|
-
invalid_value: "invalid_value",
|
|
12459
|
-
custom: "custom"
|
|
12460
|
-
};
|
|
12461
|
-
var ZodFirstPartyTypeKind;
|
|
12462
|
-
/* @__PURE__ */ (function(ZodFirstPartyTypeKind2) {
|
|
12463
|
-
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
12464
|
-
|
|
12465
|
-
// node_modules/zod/v4/classic/coerce.js
|
|
12466
|
-
var coerce_exports = {};
|
|
12467
|
-
__export(coerce_exports, {
|
|
12468
|
-
bigint: () => bigint2,
|
|
12469
|
-
boolean: () => boolean3,
|
|
12470
|
-
date: () => date3,
|
|
12471
|
-
number: () => number3,
|
|
12472
|
-
string: () => string3
|
|
12473
|
-
});
|
|
12474
|
-
function string3(params) {
|
|
12475
|
-
return _coercedString(ZodString, params);
|
|
12476
|
-
}
|
|
12477
|
-
function number3(params) {
|
|
12478
|
-
return _coercedNumber(ZodNumber, params);
|
|
12479
|
-
}
|
|
12480
|
-
function boolean3(params) {
|
|
12481
|
-
return _coercedBoolean(ZodBoolean, params);
|
|
12482
|
-
}
|
|
12483
|
-
function bigint2(params) {
|
|
12484
|
-
return _coercedBigint(ZodBigInt, params);
|
|
12485
|
-
}
|
|
12486
|
-
function date3(params) {
|
|
12487
|
-
return _coercedDate(ZodDate, params);
|
|
12488
|
-
}
|
|
12489
|
-
|
|
12490
12187
|
// node_modules/zod/v4/classic/external.js
|
|
12491
12188
|
config(en_default());
|
|
12492
12189
|
|
|
@@ -12891,7 +12588,6 @@ var InitializedNotificationSchema = NotificationSchema.extend({
|
|
|
12891
12588
|
method: literal("notifications/initialized"),
|
|
12892
12589
|
params: NotificationsParamsSchema.optional()
|
|
12893
12590
|
});
|
|
12894
|
-
var isInitializedNotification = (value) => InitializedNotificationSchema.safeParse(value).success;
|
|
12895
12591
|
var PingRequestSchema = RequestSchema.extend({
|
|
12896
12592
|
method: literal("ping"),
|
|
12897
12593
|
params: BaseRequestParamsSchema.optional()
|
|
@@ -15764,1548 +15460,216 @@ var Client = class extends Protocol {
|
|
|
15764
15460
|
}
|
|
15765
15461
|
};
|
|
15766
15462
|
|
|
15767
|
-
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/
|
|
15768
|
-
var
|
|
15769
|
-
|
|
15770
|
-
|
|
15771
|
-
|
|
15463
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
15464
|
+
var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
|
|
15465
|
+
var ReadBuffer = class {
|
|
15466
|
+
constructor(options) {
|
|
15467
|
+
this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
|
|
15772
15468
|
}
|
|
15773
|
-
|
|
15774
|
-
|
|
15775
|
-
|
|
15776
|
-
|
|
15777
|
-
|
|
15778
|
-
return void 0;
|
|
15469
|
+
append(chunk) {
|
|
15470
|
+
const newSize = (this._buffer?.length ?? 0) + chunk.length;
|
|
15471
|
+
if (newSize > this._maxBufferSize) {
|
|
15472
|
+
this.clear();
|
|
15473
|
+
throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
|
|
15779
15474
|
}
|
|
15780
|
-
|
|
15781
|
-
}
|
|
15782
|
-
}
|
|
15783
|
-
|
|
15784
|
-
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
|
|
15785
|
-
function normalizeHeaders(headers) {
|
|
15786
|
-
if (!headers)
|
|
15787
|
-
return {};
|
|
15788
|
-
if (headers instanceof Headers) {
|
|
15789
|
-
return Object.fromEntries(headers.entries());
|
|
15790
|
-
}
|
|
15791
|
-
if (Array.isArray(headers)) {
|
|
15792
|
-
return Object.fromEntries(headers);
|
|
15475
|
+
this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
|
|
15793
15476
|
}
|
|
15794
|
-
|
|
15795
|
-
|
|
15796
|
-
|
|
15797
|
-
if (!baseInit) {
|
|
15798
|
-
return baseFetch;
|
|
15799
|
-
}
|
|
15800
|
-
return async (url2, init) => {
|
|
15801
|
-
const mergedInit = {
|
|
15802
|
-
...baseInit,
|
|
15803
|
-
...init,
|
|
15804
|
-
// Headers need special handling - merge instead of replace
|
|
15805
|
-
headers: init?.headers ? { ...normalizeHeaders(baseInit.headers), ...normalizeHeaders(init.headers) } : baseInit.headers
|
|
15806
|
-
};
|
|
15807
|
-
return baseFetch(url2, mergedInit);
|
|
15808
|
-
};
|
|
15809
|
-
}
|
|
15810
|
-
|
|
15811
|
-
// node_modules/pkce-challenge/dist/index.node.js
|
|
15812
|
-
var crypto;
|
|
15813
|
-
crypto = globalThis.crypto?.webcrypto ?? // Node.js [18-16] REPL
|
|
15814
|
-
globalThis.crypto ?? // Node.js >18
|
|
15815
|
-
import("node:crypto").then((m) => m.webcrypto);
|
|
15816
|
-
async function getRandomValues(size) {
|
|
15817
|
-
return (await crypto).getRandomValues(new Uint8Array(size));
|
|
15818
|
-
}
|
|
15819
|
-
async function random(size) {
|
|
15820
|
-
const mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
|
|
15821
|
-
const evenDistCutoff = Math.pow(2, 8) - Math.pow(2, 8) % mask.length;
|
|
15822
|
-
let result = "";
|
|
15823
|
-
while (result.length < size) {
|
|
15824
|
-
const randomBytes = await getRandomValues(size - result.length);
|
|
15825
|
-
for (const randomByte of randomBytes) {
|
|
15826
|
-
if (randomByte < evenDistCutoff) {
|
|
15827
|
-
result += mask[randomByte % mask.length];
|
|
15828
|
-
}
|
|
15477
|
+
readMessage() {
|
|
15478
|
+
if (!this._buffer) {
|
|
15479
|
+
return null;
|
|
15829
15480
|
}
|
|
15830
|
-
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
async function generateVerifier(length) {
|
|
15834
|
-
return await random(length);
|
|
15835
|
-
}
|
|
15836
|
-
async function generateChallenge(code_verifier) {
|
|
15837
|
-
const buffer = await (await crypto).subtle.digest("SHA-256", new TextEncoder().encode(code_verifier));
|
|
15838
|
-
return btoa(String.fromCharCode(...new Uint8Array(buffer))).replace(/\//g, "_").replace(/\+/g, "-").replace(/=/g, "");
|
|
15839
|
-
}
|
|
15840
|
-
async function pkceChallenge(length) {
|
|
15841
|
-
if (!length)
|
|
15842
|
-
length = 43;
|
|
15843
|
-
if (length < 43 || length > 128) {
|
|
15844
|
-
throw `Expected a length between 43 and 128. Received ${length}.`;
|
|
15845
|
-
}
|
|
15846
|
-
const verifier = await generateVerifier(length);
|
|
15847
|
-
const challenge = await generateChallenge(verifier);
|
|
15848
|
-
return {
|
|
15849
|
-
code_verifier: verifier,
|
|
15850
|
-
code_challenge: challenge
|
|
15851
|
-
};
|
|
15852
|
-
}
|
|
15853
|
-
|
|
15854
|
-
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js
|
|
15855
|
-
var SafeUrlSchema = url().superRefine((val, ctx) => {
|
|
15856
|
-
if (!URL.canParse(val)) {
|
|
15857
|
-
ctx.addIssue({
|
|
15858
|
-
code: ZodIssueCode.custom,
|
|
15859
|
-
message: "URL must be parseable",
|
|
15860
|
-
fatal: true
|
|
15861
|
-
});
|
|
15862
|
-
return NEVER;
|
|
15863
|
-
}
|
|
15864
|
-
}).refine((url2) => {
|
|
15865
|
-
const u = new URL(url2);
|
|
15866
|
-
return u.protocol !== "javascript:" && u.protocol !== "data:" && u.protocol !== "vbscript:";
|
|
15867
|
-
}, { message: "URL cannot use javascript:, data:, or vbscript: scheme" });
|
|
15868
|
-
var OAuthProtectedResourceMetadataSchema = looseObject({
|
|
15869
|
-
resource: string2().url(),
|
|
15870
|
-
authorization_servers: array(SafeUrlSchema).optional(),
|
|
15871
|
-
jwks_uri: string2().url().optional(),
|
|
15872
|
-
scopes_supported: array(string2()).optional(),
|
|
15873
|
-
bearer_methods_supported: array(string2()).optional(),
|
|
15874
|
-
resource_signing_alg_values_supported: array(string2()).optional(),
|
|
15875
|
-
resource_name: string2().optional(),
|
|
15876
|
-
resource_documentation: string2().optional(),
|
|
15877
|
-
resource_policy_uri: string2().url().optional(),
|
|
15878
|
-
resource_tos_uri: string2().url().optional(),
|
|
15879
|
-
tls_client_certificate_bound_access_tokens: boolean2().optional(),
|
|
15880
|
-
authorization_details_types_supported: array(string2()).optional(),
|
|
15881
|
-
dpop_signing_alg_values_supported: array(string2()).optional(),
|
|
15882
|
-
dpop_bound_access_tokens_required: boolean2().optional()
|
|
15883
|
-
});
|
|
15884
|
-
var OAuthMetadataSchema = looseObject({
|
|
15885
|
-
issuer: string2(),
|
|
15886
|
-
authorization_endpoint: SafeUrlSchema,
|
|
15887
|
-
token_endpoint: SafeUrlSchema,
|
|
15888
|
-
registration_endpoint: SafeUrlSchema.optional(),
|
|
15889
|
-
scopes_supported: array(string2()).optional(),
|
|
15890
|
-
response_types_supported: array(string2()),
|
|
15891
|
-
response_modes_supported: array(string2()).optional(),
|
|
15892
|
-
grant_types_supported: array(string2()).optional(),
|
|
15893
|
-
token_endpoint_auth_methods_supported: array(string2()).optional(),
|
|
15894
|
-
token_endpoint_auth_signing_alg_values_supported: array(string2()).optional(),
|
|
15895
|
-
service_documentation: SafeUrlSchema.optional(),
|
|
15896
|
-
revocation_endpoint: SafeUrlSchema.optional(),
|
|
15897
|
-
revocation_endpoint_auth_methods_supported: array(string2()).optional(),
|
|
15898
|
-
revocation_endpoint_auth_signing_alg_values_supported: array(string2()).optional(),
|
|
15899
|
-
introspection_endpoint: string2().optional(),
|
|
15900
|
-
introspection_endpoint_auth_methods_supported: array(string2()).optional(),
|
|
15901
|
-
introspection_endpoint_auth_signing_alg_values_supported: array(string2()).optional(),
|
|
15902
|
-
code_challenge_methods_supported: array(string2()).optional(),
|
|
15903
|
-
client_id_metadata_document_supported: boolean2().optional()
|
|
15904
|
-
});
|
|
15905
|
-
var OpenIdProviderMetadataSchema = looseObject({
|
|
15906
|
-
issuer: string2(),
|
|
15907
|
-
authorization_endpoint: SafeUrlSchema,
|
|
15908
|
-
token_endpoint: SafeUrlSchema,
|
|
15909
|
-
userinfo_endpoint: SafeUrlSchema.optional(),
|
|
15910
|
-
jwks_uri: SafeUrlSchema,
|
|
15911
|
-
registration_endpoint: SafeUrlSchema.optional(),
|
|
15912
|
-
scopes_supported: array(string2()).optional(),
|
|
15913
|
-
response_types_supported: array(string2()),
|
|
15914
|
-
response_modes_supported: array(string2()).optional(),
|
|
15915
|
-
grant_types_supported: array(string2()).optional(),
|
|
15916
|
-
acr_values_supported: array(string2()).optional(),
|
|
15917
|
-
subject_types_supported: array(string2()),
|
|
15918
|
-
id_token_signing_alg_values_supported: array(string2()),
|
|
15919
|
-
id_token_encryption_alg_values_supported: array(string2()).optional(),
|
|
15920
|
-
id_token_encryption_enc_values_supported: array(string2()).optional(),
|
|
15921
|
-
userinfo_signing_alg_values_supported: array(string2()).optional(),
|
|
15922
|
-
userinfo_encryption_alg_values_supported: array(string2()).optional(),
|
|
15923
|
-
userinfo_encryption_enc_values_supported: array(string2()).optional(),
|
|
15924
|
-
request_object_signing_alg_values_supported: array(string2()).optional(),
|
|
15925
|
-
request_object_encryption_alg_values_supported: array(string2()).optional(),
|
|
15926
|
-
request_object_encryption_enc_values_supported: array(string2()).optional(),
|
|
15927
|
-
token_endpoint_auth_methods_supported: array(string2()).optional(),
|
|
15928
|
-
token_endpoint_auth_signing_alg_values_supported: array(string2()).optional(),
|
|
15929
|
-
display_values_supported: array(string2()).optional(),
|
|
15930
|
-
claim_types_supported: array(string2()).optional(),
|
|
15931
|
-
claims_supported: array(string2()).optional(),
|
|
15932
|
-
service_documentation: string2().optional(),
|
|
15933
|
-
claims_locales_supported: array(string2()).optional(),
|
|
15934
|
-
ui_locales_supported: array(string2()).optional(),
|
|
15935
|
-
claims_parameter_supported: boolean2().optional(),
|
|
15936
|
-
request_parameter_supported: boolean2().optional(),
|
|
15937
|
-
request_uri_parameter_supported: boolean2().optional(),
|
|
15938
|
-
require_request_uri_registration: boolean2().optional(),
|
|
15939
|
-
op_policy_uri: SafeUrlSchema.optional(),
|
|
15940
|
-
op_tos_uri: SafeUrlSchema.optional(),
|
|
15941
|
-
client_id_metadata_document_supported: boolean2().optional()
|
|
15942
|
-
});
|
|
15943
|
-
var OpenIdProviderDiscoveryMetadataSchema = object2({
|
|
15944
|
-
...OpenIdProviderMetadataSchema.shape,
|
|
15945
|
-
...OAuthMetadataSchema.pick({
|
|
15946
|
-
code_challenge_methods_supported: true
|
|
15947
|
-
}).shape
|
|
15948
|
-
});
|
|
15949
|
-
var OAuthTokensSchema = object2({
|
|
15950
|
-
access_token: string2(),
|
|
15951
|
-
id_token: string2().optional(),
|
|
15952
|
-
// Optional for OAuth 2.1, but necessary in OpenID Connect
|
|
15953
|
-
token_type: string2(),
|
|
15954
|
-
expires_in: coerce_exports.number().optional(),
|
|
15955
|
-
scope: string2().optional(),
|
|
15956
|
-
refresh_token: string2().optional()
|
|
15957
|
-
}).strip();
|
|
15958
|
-
var OAuthErrorResponseSchema = object2({
|
|
15959
|
-
error: string2(),
|
|
15960
|
-
error_description: string2().optional(),
|
|
15961
|
-
error_uri: string2().optional()
|
|
15962
|
-
});
|
|
15963
|
-
var OptionalSafeUrlSchema = SafeUrlSchema.optional().or(literal("").transform(() => void 0));
|
|
15964
|
-
var OAuthClientMetadataSchema = object2({
|
|
15965
|
-
redirect_uris: array(SafeUrlSchema),
|
|
15966
|
-
token_endpoint_auth_method: string2().optional(),
|
|
15967
|
-
grant_types: array(string2()).optional(),
|
|
15968
|
-
response_types: array(string2()).optional(),
|
|
15969
|
-
client_name: string2().optional(),
|
|
15970
|
-
client_uri: SafeUrlSchema.optional(),
|
|
15971
|
-
logo_uri: OptionalSafeUrlSchema,
|
|
15972
|
-
scope: string2().optional(),
|
|
15973
|
-
contacts: array(string2()).optional(),
|
|
15974
|
-
tos_uri: OptionalSafeUrlSchema,
|
|
15975
|
-
policy_uri: string2().optional(),
|
|
15976
|
-
jwks_uri: SafeUrlSchema.optional(),
|
|
15977
|
-
jwks: any().optional(),
|
|
15978
|
-
software_id: string2().optional(),
|
|
15979
|
-
software_version: string2().optional(),
|
|
15980
|
-
software_statement: string2().optional()
|
|
15981
|
-
}).strip();
|
|
15982
|
-
var OAuthClientInformationSchema = object2({
|
|
15983
|
-
client_id: string2(),
|
|
15984
|
-
client_secret: string2().optional(),
|
|
15985
|
-
client_id_issued_at: number2().optional(),
|
|
15986
|
-
client_secret_expires_at: number2().optional()
|
|
15987
|
-
}).strip();
|
|
15988
|
-
var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
|
|
15989
|
-
var OAuthClientRegistrationErrorSchema = object2({
|
|
15990
|
-
error: string2(),
|
|
15991
|
-
error_description: string2().optional()
|
|
15992
|
-
}).strip();
|
|
15993
|
-
var OAuthTokenRevocationRequestSchema = object2({
|
|
15994
|
-
token: string2(),
|
|
15995
|
-
token_type_hint: string2().optional()
|
|
15996
|
-
}).strip();
|
|
15997
|
-
|
|
15998
|
-
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth-utils.js
|
|
15999
|
-
function resourceUrlFromServerUrl(url2) {
|
|
16000
|
-
const resourceURL = typeof url2 === "string" ? new URL(url2) : new URL(url2.href);
|
|
16001
|
-
resourceURL.hash = "";
|
|
16002
|
-
return resourceURL;
|
|
16003
|
-
}
|
|
16004
|
-
function checkResourceAllowed({ requestedResource, configuredResource }) {
|
|
16005
|
-
const requested = typeof requestedResource === "string" ? new URL(requestedResource) : new URL(requestedResource.href);
|
|
16006
|
-
const configured = typeof configuredResource === "string" ? new URL(configuredResource) : new URL(configuredResource.href);
|
|
16007
|
-
if (requested.origin !== configured.origin) {
|
|
16008
|
-
return false;
|
|
16009
|
-
}
|
|
16010
|
-
if (requested.pathname.length < configured.pathname.length) {
|
|
16011
|
-
return false;
|
|
16012
|
-
}
|
|
16013
|
-
const requestedPath = requested.pathname.endsWith("/") ? requested.pathname : requested.pathname + "/";
|
|
16014
|
-
const configuredPath = configured.pathname.endsWith("/") ? configured.pathname : configured.pathname + "/";
|
|
16015
|
-
return requestedPath.startsWith(configuredPath);
|
|
16016
|
-
}
|
|
16017
|
-
|
|
16018
|
-
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/errors.js
|
|
16019
|
-
var OAuthError = class extends Error {
|
|
16020
|
-
constructor(message, errorUri) {
|
|
16021
|
-
super(message);
|
|
16022
|
-
this.errorUri = errorUri;
|
|
16023
|
-
this.name = this.constructor.name;
|
|
16024
|
-
}
|
|
16025
|
-
/**
|
|
16026
|
-
* Converts the error to a standard OAuth error response object
|
|
16027
|
-
*/
|
|
16028
|
-
toResponseObject() {
|
|
16029
|
-
const response = {
|
|
16030
|
-
error: this.errorCode,
|
|
16031
|
-
error_description: this.message
|
|
16032
|
-
};
|
|
16033
|
-
if (this.errorUri) {
|
|
16034
|
-
response.error_uri = this.errorUri;
|
|
15481
|
+
const index = this._buffer.indexOf("\n");
|
|
15482
|
+
if (index === -1) {
|
|
15483
|
+
return null;
|
|
16035
15484
|
}
|
|
16036
|
-
|
|
16037
|
-
|
|
16038
|
-
|
|
16039
|
-
return this.constructor.errorCode;
|
|
15485
|
+
const line = this._buffer.toString("utf8", 0, index).replace(/\r$/, "");
|
|
15486
|
+
this._buffer = this._buffer.subarray(index + 1);
|
|
15487
|
+
return deserializeMessage(line);
|
|
16040
15488
|
}
|
|
16041
|
-
|
|
16042
|
-
|
|
16043
|
-
};
|
|
16044
|
-
InvalidRequestError.errorCode = "invalid_request";
|
|
16045
|
-
var InvalidClientError = class extends OAuthError {
|
|
16046
|
-
};
|
|
16047
|
-
InvalidClientError.errorCode = "invalid_client";
|
|
16048
|
-
var InvalidGrantError = class extends OAuthError {
|
|
16049
|
-
};
|
|
16050
|
-
InvalidGrantError.errorCode = "invalid_grant";
|
|
16051
|
-
var UnauthorizedClientError = class extends OAuthError {
|
|
16052
|
-
};
|
|
16053
|
-
UnauthorizedClientError.errorCode = "unauthorized_client";
|
|
16054
|
-
var UnsupportedGrantTypeError = class extends OAuthError {
|
|
16055
|
-
};
|
|
16056
|
-
UnsupportedGrantTypeError.errorCode = "unsupported_grant_type";
|
|
16057
|
-
var InvalidScopeError = class extends OAuthError {
|
|
16058
|
-
};
|
|
16059
|
-
InvalidScopeError.errorCode = "invalid_scope";
|
|
16060
|
-
var AccessDeniedError = class extends OAuthError {
|
|
16061
|
-
};
|
|
16062
|
-
AccessDeniedError.errorCode = "access_denied";
|
|
16063
|
-
var ServerError = class extends OAuthError {
|
|
16064
|
-
};
|
|
16065
|
-
ServerError.errorCode = "server_error";
|
|
16066
|
-
var TemporarilyUnavailableError = class extends OAuthError {
|
|
16067
|
-
};
|
|
16068
|
-
TemporarilyUnavailableError.errorCode = "temporarily_unavailable";
|
|
16069
|
-
var UnsupportedResponseTypeError = class extends OAuthError {
|
|
16070
|
-
};
|
|
16071
|
-
UnsupportedResponseTypeError.errorCode = "unsupported_response_type";
|
|
16072
|
-
var UnsupportedTokenTypeError = class extends OAuthError {
|
|
16073
|
-
};
|
|
16074
|
-
UnsupportedTokenTypeError.errorCode = "unsupported_token_type";
|
|
16075
|
-
var InvalidTokenError = class extends OAuthError {
|
|
16076
|
-
};
|
|
16077
|
-
InvalidTokenError.errorCode = "invalid_token";
|
|
16078
|
-
var MethodNotAllowedError = class extends OAuthError {
|
|
16079
|
-
};
|
|
16080
|
-
MethodNotAllowedError.errorCode = "method_not_allowed";
|
|
16081
|
-
var TooManyRequestsError = class extends OAuthError {
|
|
16082
|
-
};
|
|
16083
|
-
TooManyRequestsError.errorCode = "too_many_requests";
|
|
16084
|
-
var InvalidClientMetadataError = class extends OAuthError {
|
|
16085
|
-
};
|
|
16086
|
-
InvalidClientMetadataError.errorCode = "invalid_client_metadata";
|
|
16087
|
-
var InsufficientScopeError = class extends OAuthError {
|
|
16088
|
-
};
|
|
16089
|
-
InsufficientScopeError.errorCode = "insufficient_scope";
|
|
16090
|
-
var InvalidTargetError = class extends OAuthError {
|
|
16091
|
-
};
|
|
16092
|
-
InvalidTargetError.errorCode = "invalid_target";
|
|
16093
|
-
var OAUTH_ERRORS = {
|
|
16094
|
-
[InvalidRequestError.errorCode]: InvalidRequestError,
|
|
16095
|
-
[InvalidClientError.errorCode]: InvalidClientError,
|
|
16096
|
-
[InvalidGrantError.errorCode]: InvalidGrantError,
|
|
16097
|
-
[UnauthorizedClientError.errorCode]: UnauthorizedClientError,
|
|
16098
|
-
[UnsupportedGrantTypeError.errorCode]: UnsupportedGrantTypeError,
|
|
16099
|
-
[InvalidScopeError.errorCode]: InvalidScopeError,
|
|
16100
|
-
[AccessDeniedError.errorCode]: AccessDeniedError,
|
|
16101
|
-
[ServerError.errorCode]: ServerError,
|
|
16102
|
-
[TemporarilyUnavailableError.errorCode]: TemporarilyUnavailableError,
|
|
16103
|
-
[UnsupportedResponseTypeError.errorCode]: UnsupportedResponseTypeError,
|
|
16104
|
-
[UnsupportedTokenTypeError.errorCode]: UnsupportedTokenTypeError,
|
|
16105
|
-
[InvalidTokenError.errorCode]: InvalidTokenError,
|
|
16106
|
-
[MethodNotAllowedError.errorCode]: MethodNotAllowedError,
|
|
16107
|
-
[TooManyRequestsError.errorCode]: TooManyRequestsError,
|
|
16108
|
-
[InvalidClientMetadataError.errorCode]: InvalidClientMetadataError,
|
|
16109
|
-
[InsufficientScopeError.errorCode]: InsufficientScopeError,
|
|
16110
|
-
[InvalidTargetError.errorCode]: InvalidTargetError
|
|
16111
|
-
};
|
|
16112
|
-
|
|
16113
|
-
// node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js
|
|
16114
|
-
var UnauthorizedError = class extends Error {
|
|
16115
|
-
constructor(message) {
|
|
16116
|
-
super(message ?? "Unauthorized");
|
|
15489
|
+
clear() {
|
|
15490
|
+
this._buffer = void 0;
|
|
16117
15491
|
}
|
|
16118
15492
|
};
|
|
16119
|
-
function
|
|
16120
|
-
return
|
|
16121
|
-
}
|
|
16122
|
-
var AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
|
|
16123
|
-
var AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
|
|
16124
|
-
function selectClientAuthMethod(clientInformation, supportedMethods) {
|
|
16125
|
-
const hasClientSecret = clientInformation.client_secret !== void 0;
|
|
16126
|
-
if ("token_endpoint_auth_method" in clientInformation && clientInformation.token_endpoint_auth_method && isClientAuthMethod(clientInformation.token_endpoint_auth_method) && (supportedMethods.length === 0 || supportedMethods.includes(clientInformation.token_endpoint_auth_method))) {
|
|
16127
|
-
return clientInformation.token_endpoint_auth_method;
|
|
16128
|
-
}
|
|
16129
|
-
if (supportedMethods.length === 0) {
|
|
16130
|
-
return hasClientSecret ? "client_secret_basic" : "none";
|
|
16131
|
-
}
|
|
16132
|
-
if (hasClientSecret && supportedMethods.includes("client_secret_basic")) {
|
|
16133
|
-
return "client_secret_basic";
|
|
16134
|
-
}
|
|
16135
|
-
if (hasClientSecret && supportedMethods.includes("client_secret_post")) {
|
|
16136
|
-
return "client_secret_post";
|
|
16137
|
-
}
|
|
16138
|
-
if (supportedMethods.includes("none")) {
|
|
16139
|
-
return "none";
|
|
16140
|
-
}
|
|
16141
|
-
return hasClientSecret ? "client_secret_post" : "none";
|
|
16142
|
-
}
|
|
16143
|
-
function applyClientAuthentication(method, clientInformation, headers, params) {
|
|
16144
|
-
const { client_id, client_secret } = clientInformation;
|
|
16145
|
-
switch (method) {
|
|
16146
|
-
case "client_secret_basic":
|
|
16147
|
-
applyBasicAuth(client_id, client_secret, headers);
|
|
16148
|
-
return;
|
|
16149
|
-
case "client_secret_post":
|
|
16150
|
-
applyPostAuth(client_id, client_secret, params);
|
|
16151
|
-
return;
|
|
16152
|
-
case "none":
|
|
16153
|
-
applyPublicAuth(client_id, params);
|
|
16154
|
-
return;
|
|
16155
|
-
default:
|
|
16156
|
-
throw new Error(`Unsupported client authentication method: ${method}`);
|
|
16157
|
-
}
|
|
15493
|
+
function deserializeMessage(line) {
|
|
15494
|
+
return JSONRPCMessageSchema.parse(JSON.parse(line));
|
|
16158
15495
|
}
|
|
16159
|
-
function
|
|
16160
|
-
|
|
16161
|
-
throw new Error("client_secret_basic authentication requires a client_secret");
|
|
16162
|
-
}
|
|
16163
|
-
const credentials = btoa(`${clientId}:${clientSecret}`);
|
|
16164
|
-
headers.set("Authorization", `Basic ${credentials}`);
|
|
15496
|
+
function serializeMessage(message) {
|
|
15497
|
+
return JSON.stringify(message) + "\n";
|
|
16165
15498
|
}
|
|
16166
|
-
|
|
16167
|
-
|
|
16168
|
-
|
|
16169
|
-
|
|
15499
|
+
|
|
15500
|
+
// package.json
|
|
15501
|
+
var package_default = {
|
|
15502
|
+
name: "rainskills",
|
|
15503
|
+
version: "0.1.2",
|
|
15504
|
+
description: "Interactive Rainbond skill installer for Codex and Claude Code",
|
|
15505
|
+
license: "Apache-2.0",
|
|
15506
|
+
homepage: "https://github.com/goodrain/rainskills#readme",
|
|
15507
|
+
bugs: {
|
|
15508
|
+
url: "https://github.com/goodrain/rainskills/issues"
|
|
15509
|
+
},
|
|
15510
|
+
repository: {
|
|
15511
|
+
type: "git",
|
|
15512
|
+
url: "git+https://github.com/goodrain/rainskills.git"
|
|
15513
|
+
},
|
|
15514
|
+
keywords: [
|
|
15515
|
+
"rainbond",
|
|
15516
|
+
"codex",
|
|
15517
|
+
"claude-code",
|
|
15518
|
+
"skills",
|
|
15519
|
+
"installer"
|
|
15520
|
+
],
|
|
15521
|
+
bin: {
|
|
15522
|
+
rainskills: "bin/rainskills.js"
|
|
15523
|
+
},
|
|
15524
|
+
files: [
|
|
15525
|
+
"SKILL.md",
|
|
15526
|
+
"agents/",
|
|
15527
|
+
"bin/",
|
|
15528
|
+
"install.sh",
|
|
15529
|
+
"marketplace/",
|
|
15530
|
+
"pi/",
|
|
15531
|
+
"rainbond-app-assistant/",
|
|
15532
|
+
"rainbond-app-version-assistant/",
|
|
15533
|
+
"rainbond-delivery-verifier/",
|
|
15534
|
+
"rainbond-env-sync/",
|
|
15535
|
+
"rainbond-fullstack-bootstrap/",
|
|
15536
|
+
"rainbond-fullstack-troubleshooter/",
|
|
15537
|
+
"rainbond-platform-installer/",
|
|
15538
|
+
"rainbond-platform-query/",
|
|
15539
|
+
"rainbond-project-init/",
|
|
15540
|
+
"rainbond-template-installer/",
|
|
15541
|
+
"!**/__pycache__/",
|
|
15542
|
+
"!**/*.pyc"
|
|
15543
|
+
],
|
|
15544
|
+
engines: {
|
|
15545
|
+
node: ">=18"
|
|
15546
|
+
},
|
|
15547
|
+
os: [
|
|
15548
|
+
"darwin",
|
|
15549
|
+
"linux",
|
|
15550
|
+
"win32"
|
|
15551
|
+
],
|
|
15552
|
+
pi: {
|
|
15553
|
+
skills: [
|
|
15554
|
+
"./marketplace/rainskills/skills"
|
|
15555
|
+
]
|
|
15556
|
+
},
|
|
15557
|
+
scripts: {
|
|
15558
|
+
"build:marketplace": "node scripts/build-marketplace-package.mjs",
|
|
15559
|
+
"build:pi": "node scripts/build-pi-extension.mjs",
|
|
15560
|
+
"check:marketplace": "node scripts/build-marketplace-package.mjs --check",
|
|
15561
|
+
"check:pi": "node scripts/build-pi-extension.mjs --check",
|
|
15562
|
+
test: "npm run test:auto-update && npm run test:launcher && npm run test:api-bridge && npm run test:skill-profile && npm run test:marketplace && npm run test:runtime-routing && npm run test:pi && npm run test:telemetry && npm run test:platform && npm run test:windows && npm run test:package-upload && npm run test:package && npm run test:installer && npm run test:signal && npm run test:npx-pty",
|
|
15563
|
+
"test:auto-update": "node --test tests/auto-update.test.js",
|
|
15564
|
+
"test:launcher": "node --test tests/console-origin.test.js tests/environment-credentials.test.js tests/environment-registry.test.js tests/local-runtime-cli.test.js tests/mcp-router.test.js tests/mcp-server.test.js tests/npx-launcher.test.js tests/runtime-credentials.test.js tests/runtime-intents.test.js tests/runtime-operations.test.js tests/runtime-state.test.js",
|
|
15565
|
+
"test:api-bridge": "node --test tests/api-bridge.test.js",
|
|
15566
|
+
"test:skill-profile": "node --test tests/skill-profile-builder.test.js tests/markdown-link-integrity.test.js",
|
|
15567
|
+
"test:marketplace": "node --test tests/marketplace-entry.test.js",
|
|
15568
|
+
"test:runtime-routing": "node --test tests/runtime-onboarding-routing.test.js && python3 tests/run_skill_routing_evals.py",
|
|
15569
|
+
"test:pi": "npm run check:pi && node --test tests/pi-extension.test.js",
|
|
15570
|
+
"test:telemetry": "node --test tests/telemetry.test.js",
|
|
15571
|
+
"test:platform": "node --test tests/platform-installer.test.js tests/host-cluster-installer.test.js tests/existing-kubernetes-installer.test.js tests/ssh-key-setup.test.js",
|
|
15572
|
+
"test:windows": "node --test tests/windows-onboarding.test.js tests/windows-platform.test.js",
|
|
15573
|
+
"test:package-upload": "python3 tests/package_upload_helper_test.py && python3 tests/package_upload_workflow_contract_test.py && python3 rainbond-fullstack-bootstrap/scripts/run_bootstrap_evals.py",
|
|
15574
|
+
"test:package": "node --test tests/npm-package.test.js",
|
|
15575
|
+
"test:installer": "bash tests/browser_authorization_mode_test.sh && bash tests/device_authorization_flow_test.sh && python3 tests/install_test_suite_tty_test.py",
|
|
15576
|
+
"test:signal": "python3 tests/installer_signal_cleanup_test.py",
|
|
15577
|
+
"test:npx-pty": "python3 tests/npx_pty_test.py"
|
|
15578
|
+
},
|
|
15579
|
+
dependencies: {
|
|
15580
|
+
"@modelcontextprotocol/sdk": "1.30.0",
|
|
15581
|
+
yaml: "2.9.0"
|
|
15582
|
+
},
|
|
15583
|
+
devDependencies: {
|
|
15584
|
+
esbuild: "0.25.8"
|
|
15585
|
+
},
|
|
15586
|
+
publishConfig: {
|
|
15587
|
+
access: "public",
|
|
15588
|
+
registry: "https://registry.npmjs.org/"
|
|
16170
15589
|
}
|
|
15590
|
+
};
|
|
15591
|
+
|
|
15592
|
+
// src/pi/rainskills-mcp.ts
|
|
15593
|
+
function readRainbondConfig(_input = {}) {
|
|
15594
|
+
return {
|
|
15595
|
+
command: "npx",
|
|
15596
|
+
args: [
|
|
15597
|
+
"--yes",
|
|
15598
|
+
`rainskills@${package_default.version}`,
|
|
15599
|
+
"mcp",
|
|
15600
|
+
"serve",
|
|
15601
|
+
"--client",
|
|
15602
|
+
"pi"
|
|
15603
|
+
]
|
|
15604
|
+
};
|
|
16171
15605
|
}
|
|
16172
|
-
function
|
|
16173
|
-
|
|
15606
|
+
function publicConfig(config2) {
|
|
15607
|
+
return { command: config2.command, args: [...config2.args] };
|
|
16174
15608
|
}
|
|
16175
|
-
|
|
16176
|
-
const
|
|
16177
|
-
|
|
16178
|
-
|
|
16179
|
-
const result = OAuthErrorResponseSchema.parse(JSON.parse(body));
|
|
16180
|
-
const { error: error2, error_description, error_uri } = result;
|
|
16181
|
-
const errorClass = OAUTH_ERRORS[error2] || ServerError;
|
|
16182
|
-
return new errorClass(error_description || "", error_uri);
|
|
16183
|
-
} catch (error2) {
|
|
16184
|
-
const errorMessage = `${statusCode ? `HTTP ${statusCode}: ` : ""}Invalid OAuth error response: ${error2}. Raw body: ${body}`;
|
|
16185
|
-
return new ServerError(errorMessage);
|
|
15609
|
+
function toPiContent(result) {
|
|
15610
|
+
const content = Array.isArray(result?.content) ? result.content : [];
|
|
15611
|
+
if (content.length === 0) {
|
|
15612
|
+
return [{ type: "text", text: result?.isError ? "Rainbond MCP call failed." : "Done." }];
|
|
16186
15613
|
}
|
|
16187
|
-
|
|
16188
|
-
|
|
16189
|
-
|
|
16190
|
-
return await authInternal(provider, options);
|
|
16191
|
-
} catch (error2) {
|
|
16192
|
-
if (error2 instanceof InvalidClientError || error2 instanceof UnauthorizedClientError) {
|
|
16193
|
-
await provider.invalidateCredentials?.("all");
|
|
16194
|
-
return await authInternal(provider, options);
|
|
16195
|
-
} else if (error2 instanceof InvalidGrantError) {
|
|
16196
|
-
await provider.invalidateCredentials?.("tokens");
|
|
16197
|
-
return await authInternal(provider, options);
|
|
15614
|
+
return content.map((item) => {
|
|
15615
|
+
if (item?.type === "text" && typeof item.text === "string") {
|
|
15616
|
+
return { type: "text", text: item.text };
|
|
16198
15617
|
}
|
|
16199
|
-
|
|
16200
|
-
}
|
|
15618
|
+
return { type: "text", text: JSON.stringify(item) };
|
|
15619
|
+
});
|
|
16201
15620
|
}
|
|
16202
|
-
|
|
16203
|
-
const
|
|
16204
|
-
|
|
16205
|
-
let
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
|
|
16212
|
-
|
|
16213
|
-
|
|
16214
|
-
|
|
16215
|
-
|
|
16216
|
-
|
|
16217
|
-
|
|
16218
|
-
|
|
16219
|
-
|
|
16220
|
-
}
|
|
16221
|
-
if (metadata !== cachedState.authorizationServerMetadata || resourceMetadata !== cachedState.resourceMetadata) {
|
|
16222
|
-
await provider.saveDiscoveryState?.({
|
|
16223
|
-
authorizationServerUrl: String(authorizationServerUrl),
|
|
16224
|
-
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
16225
|
-
resourceMetadata,
|
|
16226
|
-
authorizationServerMetadata: metadata
|
|
15621
|
+
function createMcpClient(config2) {
|
|
15622
|
+
const client = new Client({ name: "rainskills-pi", version: "0.1.0" });
|
|
15623
|
+
const readBuffer = new ReadBuffer();
|
|
15624
|
+
let child = null;
|
|
15625
|
+
const inherited = {};
|
|
15626
|
+
for (const key of ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER", "APPDATA", "USERPROFILE", "TEMP"]) {
|
|
15627
|
+
if (process.env[key]) inherited[key] = process.env[key];
|
|
15628
|
+
}
|
|
15629
|
+
const transport = {
|
|
15630
|
+
onmessage: void 0,
|
|
15631
|
+
onerror: void 0,
|
|
15632
|
+
onclose: void 0,
|
|
15633
|
+
async start() {
|
|
15634
|
+
child = spawn(config2.command, config2.args, {
|
|
15635
|
+
env: inherited,
|
|
15636
|
+
shell: false,
|
|
15637
|
+
stdio: ["pipe", "pipe", "inherit"],
|
|
15638
|
+
windowsHide: true
|
|
16227
15639
|
});
|
|
16228
|
-
|
|
16229
|
-
|
|
16230
|
-
|
|
16231
|
-
authorizationServerUrl = serverInfo.authorizationServerUrl;
|
|
16232
|
-
metadata = serverInfo.authorizationServerMetadata;
|
|
16233
|
-
resourceMetadata = serverInfo.resourceMetadata;
|
|
16234
|
-
await provider.saveDiscoveryState?.({
|
|
16235
|
-
authorizationServerUrl: String(authorizationServerUrl),
|
|
16236
|
-
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
16237
|
-
resourceMetadata,
|
|
16238
|
-
authorizationServerMetadata: metadata
|
|
16239
|
-
});
|
|
16240
|
-
}
|
|
16241
|
-
const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
16242
|
-
const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
|
|
16243
|
-
let clientInformation = await Promise.resolve(provider.clientInformation());
|
|
16244
|
-
if (!clientInformation) {
|
|
16245
|
-
if (authorizationCode !== void 0) {
|
|
16246
|
-
throw new Error("Existing OAuth client information is required when exchanging an authorization code");
|
|
16247
|
-
}
|
|
16248
|
-
const supportsUrlBasedClientId = metadata?.client_id_metadata_document_supported === true;
|
|
16249
|
-
const clientMetadataUrl = provider.clientMetadataUrl;
|
|
16250
|
-
if (clientMetadataUrl && !isHttpsUrl(clientMetadataUrl)) {
|
|
16251
|
-
throw new InvalidClientMetadataError(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${clientMetadataUrl}`);
|
|
16252
|
-
}
|
|
16253
|
-
const shouldUseUrlBasedClientId = supportsUrlBasedClientId && clientMetadataUrl;
|
|
16254
|
-
if (shouldUseUrlBasedClientId) {
|
|
16255
|
-
clientInformation = {
|
|
16256
|
-
client_id: clientMetadataUrl
|
|
16257
|
-
};
|
|
16258
|
-
await provider.saveClientInformation?.(clientInformation);
|
|
16259
|
-
} else {
|
|
16260
|
-
if (!provider.saveClientInformation) {
|
|
16261
|
-
throw new Error("OAuth client information must be saveable for dynamic registration");
|
|
16262
|
-
}
|
|
16263
|
-
const fullInformation = await registerClient(authorizationServerUrl, {
|
|
16264
|
-
metadata,
|
|
16265
|
-
clientMetadata: provider.clientMetadata,
|
|
16266
|
-
scope: resolvedScope,
|
|
16267
|
-
fetchFn
|
|
15640
|
+
await new Promise((resolve, reject) => {
|
|
15641
|
+
child?.once("spawn", resolve);
|
|
15642
|
+
child?.once("error", reject);
|
|
16268
15643
|
});
|
|
16269
|
-
|
|
16270
|
-
|
|
16271
|
-
|
|
16272
|
-
|
|
16273
|
-
|
|
16274
|
-
|
|
16275
|
-
|
|
16276
|
-
|
|
16277
|
-
|
|
16278
|
-
|
|
16279
|
-
|
|
16280
|
-
});
|
|
16281
|
-
await provider.saveTokens(tokens2);
|
|
16282
|
-
return "AUTHORIZED";
|
|
16283
|
-
}
|
|
16284
|
-
const tokens = await provider.tokens();
|
|
16285
|
-
if (tokens?.refresh_token) {
|
|
16286
|
-
try {
|
|
16287
|
-
const newTokens = await refreshAuthorization(authorizationServerUrl, {
|
|
16288
|
-
metadata,
|
|
16289
|
-
clientInformation,
|
|
16290
|
-
refreshToken: tokens.refresh_token,
|
|
16291
|
-
resource,
|
|
16292
|
-
addClientAuthentication: provider.addClientAuthentication,
|
|
16293
|
-
fetchFn
|
|
15644
|
+
child.stdout?.on("data", (chunk) => {
|
|
15645
|
+
try {
|
|
15646
|
+
readBuffer.append(chunk);
|
|
15647
|
+
for (; ; ) {
|
|
15648
|
+
const message = readBuffer.readMessage();
|
|
15649
|
+
if (message === null) break;
|
|
15650
|
+
transport.onmessage?.(message);
|
|
15651
|
+
}
|
|
15652
|
+
} catch (error2) {
|
|
15653
|
+
transport.onerror?.(error2);
|
|
15654
|
+
}
|
|
16294
15655
|
});
|
|
16295
|
-
|
|
16296
|
-
|
|
16297
|
-
}
|
|
16298
|
-
|
|
16299
|
-
|
|
16300
|
-
|
|
16301
|
-
|
|
15656
|
+
child.once("close", () => transport.onclose?.());
|
|
15657
|
+
child.once("error", (error2) => transport.onerror?.(error2));
|
|
15658
|
+
},
|
|
15659
|
+
async send(message) {
|
|
15660
|
+
if (!child?.stdin?.writable) throw new Error("Rainskills local MCP is not writable.");
|
|
15661
|
+
await new Promise((resolve, reject) => {
|
|
15662
|
+
child?.stdin?.write(serializeMessage(message), (error2) => error2 ? reject(error2) : resolve());
|
|
15663
|
+
});
|
|
15664
|
+
},
|
|
15665
|
+
async close() {
|
|
15666
|
+
const running = child;
|
|
15667
|
+
child = null;
|
|
15668
|
+
if (!running) return;
|
|
15669
|
+
running.stdin?.end();
|
|
15670
|
+
if (running.exitCode === null) running.kill("SIGTERM");
|
|
16302
15671
|
}
|
|
16303
|
-
}
|
|
16304
|
-
const state = provider.state ? await provider.state() : void 0;
|
|
16305
|
-
const { authorizationUrl, codeVerifier } = await startAuthorization(authorizationServerUrl, {
|
|
16306
|
-
metadata,
|
|
16307
|
-
clientInformation,
|
|
16308
|
-
state,
|
|
16309
|
-
redirectUrl: provider.redirectUrl,
|
|
16310
|
-
scope: resolvedScope,
|
|
16311
|
-
resource
|
|
16312
|
-
});
|
|
16313
|
-
await provider.saveCodeVerifier(codeVerifier);
|
|
16314
|
-
await provider.redirectToAuthorization(authorizationUrl);
|
|
16315
|
-
return "REDIRECT";
|
|
16316
|
-
}
|
|
16317
|
-
function isHttpsUrl(value) {
|
|
16318
|
-
if (!value)
|
|
16319
|
-
return false;
|
|
16320
|
-
try {
|
|
16321
|
-
const url2 = new URL(value);
|
|
16322
|
-
return url2.protocol === "https:" && url2.pathname !== "/";
|
|
16323
|
-
} catch {
|
|
16324
|
-
return false;
|
|
16325
|
-
}
|
|
16326
|
-
}
|
|
16327
|
-
async function selectResourceURL(serverUrl, provider, resourceMetadata) {
|
|
16328
|
-
const defaultResource = resourceUrlFromServerUrl(serverUrl);
|
|
16329
|
-
if (provider.validateResourceURL) {
|
|
16330
|
-
return await provider.validateResourceURL(defaultResource, resourceMetadata?.resource);
|
|
16331
|
-
}
|
|
16332
|
-
if (!resourceMetadata) {
|
|
16333
|
-
return void 0;
|
|
16334
|
-
}
|
|
16335
|
-
if (!checkResourceAllowed({ requestedResource: defaultResource, configuredResource: resourceMetadata.resource })) {
|
|
16336
|
-
throw new Error(`Protected resource ${resourceMetadata.resource} does not match expected ${defaultResource} (or origin)`);
|
|
16337
|
-
}
|
|
16338
|
-
return new URL(resourceMetadata.resource);
|
|
16339
|
-
}
|
|
16340
|
-
function extractWWWAuthenticateParams(res) {
|
|
16341
|
-
const authenticateHeader = res.headers.get("WWW-Authenticate");
|
|
16342
|
-
if (!authenticateHeader) {
|
|
16343
|
-
return {};
|
|
16344
|
-
}
|
|
16345
|
-
const [type, scheme] = authenticateHeader.split(" ");
|
|
16346
|
-
if (type.toLowerCase() !== "bearer" || !scheme) {
|
|
16347
|
-
return {};
|
|
16348
|
-
}
|
|
16349
|
-
const resourceMetadataMatch = extractFieldFromWwwAuth(res, "resource_metadata") || void 0;
|
|
16350
|
-
let resourceMetadataUrl;
|
|
16351
|
-
if (resourceMetadataMatch) {
|
|
16352
|
-
try {
|
|
16353
|
-
resourceMetadataUrl = new URL(resourceMetadataMatch);
|
|
16354
|
-
} catch {
|
|
16355
|
-
}
|
|
16356
|
-
}
|
|
16357
|
-
const scope = extractFieldFromWwwAuth(res, "scope") || void 0;
|
|
16358
|
-
const error2 = extractFieldFromWwwAuth(res, "error") || void 0;
|
|
16359
|
-
return {
|
|
16360
|
-
resourceMetadataUrl,
|
|
16361
|
-
scope,
|
|
16362
|
-
error: error2
|
|
16363
|
-
};
|
|
16364
|
-
}
|
|
16365
|
-
function extractFieldFromWwwAuth(response, fieldName) {
|
|
16366
|
-
const wwwAuthHeader = response.headers.get("WWW-Authenticate");
|
|
16367
|
-
if (!wwwAuthHeader) {
|
|
16368
|
-
return null;
|
|
16369
|
-
}
|
|
16370
|
-
const pattern = new RegExp(`${fieldName}=(?:"([^"]+)"|([^\\s,]+))`);
|
|
16371
|
-
const match = wwwAuthHeader.match(pattern);
|
|
16372
|
-
if (match) {
|
|
16373
|
-
return match[1] || match[2];
|
|
16374
|
-
}
|
|
16375
|
-
return null;
|
|
16376
|
-
}
|
|
16377
|
-
async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn = fetch) {
|
|
16378
|
-
const response = await discoverMetadataWithFallback(serverUrl, "oauth-protected-resource", fetchFn, {
|
|
16379
|
-
protocolVersion: opts?.protocolVersion,
|
|
16380
|
-
metadataUrl: opts?.resourceMetadataUrl
|
|
16381
|
-
});
|
|
16382
|
-
if (!response || response.status === 404) {
|
|
16383
|
-
await response?.body?.cancel();
|
|
16384
|
-
throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);
|
|
16385
|
-
}
|
|
16386
|
-
if (!response.ok) {
|
|
16387
|
-
await response.body?.cancel();
|
|
16388
|
-
throw new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);
|
|
16389
|
-
}
|
|
16390
|
-
return OAuthProtectedResourceMetadataSchema.parse(await response.json());
|
|
16391
|
-
}
|
|
16392
|
-
async function fetchWithCorsRetry(url2, headers, fetchFn = fetch) {
|
|
16393
|
-
try {
|
|
16394
|
-
return await fetchFn(url2, { headers });
|
|
16395
|
-
} catch (error2) {
|
|
16396
|
-
if (error2 instanceof TypeError) {
|
|
16397
|
-
if (headers) {
|
|
16398
|
-
return fetchWithCorsRetry(url2, void 0, fetchFn);
|
|
16399
|
-
} else {
|
|
16400
|
-
return void 0;
|
|
16401
|
-
}
|
|
16402
|
-
}
|
|
16403
|
-
throw error2;
|
|
16404
|
-
}
|
|
16405
|
-
}
|
|
16406
|
-
function buildWellKnownPath(wellKnownPrefix, pathname = "", options = {}) {
|
|
16407
|
-
if (pathname.endsWith("/")) {
|
|
16408
|
-
pathname = pathname.slice(0, -1);
|
|
16409
|
-
}
|
|
16410
|
-
return options.prependPathname ? `${pathname}/.well-known/${wellKnownPrefix}` : `/.well-known/${wellKnownPrefix}${pathname}`;
|
|
16411
|
-
}
|
|
16412
|
-
async function tryMetadataDiscovery(url2, protocolVersion, fetchFn = fetch) {
|
|
16413
|
-
const headers = {
|
|
16414
|
-
"MCP-Protocol-Version": protocolVersion
|
|
16415
|
-
};
|
|
16416
|
-
return await fetchWithCorsRetry(url2, headers, fetchFn);
|
|
16417
|
-
}
|
|
16418
|
-
function shouldAttemptFallback(response, pathname) {
|
|
16419
|
-
return !response || response.status >= 400 && response.status < 500 && pathname !== "/";
|
|
16420
|
-
}
|
|
16421
|
-
async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
|
|
16422
|
-
const issuer = new URL(serverUrl);
|
|
16423
|
-
const protocolVersion = opts?.protocolVersion ?? LATEST_PROTOCOL_VERSION;
|
|
16424
|
-
let url2;
|
|
16425
|
-
if (opts?.metadataUrl) {
|
|
16426
|
-
url2 = new URL(opts.metadataUrl);
|
|
16427
|
-
} else {
|
|
16428
|
-
const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);
|
|
16429
|
-
url2 = new URL(wellKnownPath, opts?.metadataServerUrl ?? issuer);
|
|
16430
|
-
url2.search = issuer.search;
|
|
16431
|
-
}
|
|
16432
|
-
let response = await tryMetadataDiscovery(url2, protocolVersion, fetchFn);
|
|
16433
|
-
if (!opts?.metadataUrl && shouldAttemptFallback(response, issuer.pathname)) {
|
|
16434
|
-
const rootUrl = new URL(`/.well-known/${wellKnownType}`, issuer);
|
|
16435
|
-
response = await tryMetadataDiscovery(rootUrl, protocolVersion, fetchFn);
|
|
16436
|
-
}
|
|
16437
|
-
return response;
|
|
16438
|
-
}
|
|
16439
|
-
function buildDiscoveryUrls(authorizationServerUrl) {
|
|
16440
|
-
const url2 = typeof authorizationServerUrl === "string" ? new URL(authorizationServerUrl) : authorizationServerUrl;
|
|
16441
|
-
const hasPath = url2.pathname !== "/";
|
|
16442
|
-
const urlsToTry = [];
|
|
16443
|
-
if (!hasPath) {
|
|
16444
|
-
urlsToTry.push({
|
|
16445
|
-
url: new URL("/.well-known/oauth-authorization-server", url2.origin),
|
|
16446
|
-
type: "oauth"
|
|
16447
|
-
});
|
|
16448
|
-
urlsToTry.push({
|
|
16449
|
-
url: new URL(`/.well-known/openid-configuration`, url2.origin),
|
|
16450
|
-
type: "oidc"
|
|
16451
|
-
});
|
|
16452
|
-
return urlsToTry;
|
|
16453
|
-
}
|
|
16454
|
-
let pathname = url2.pathname;
|
|
16455
|
-
if (pathname.endsWith("/")) {
|
|
16456
|
-
pathname = pathname.slice(0, -1);
|
|
16457
|
-
}
|
|
16458
|
-
urlsToTry.push({
|
|
16459
|
-
url: new URL(`/.well-known/oauth-authorization-server${pathname}`, url2.origin),
|
|
16460
|
-
type: "oauth"
|
|
16461
|
-
});
|
|
16462
|
-
urlsToTry.push({
|
|
16463
|
-
url: new URL(`/.well-known/openid-configuration${pathname}`, url2.origin),
|
|
16464
|
-
type: "oidc"
|
|
16465
|
-
});
|
|
16466
|
-
urlsToTry.push({
|
|
16467
|
-
url: new URL(`${pathname}/.well-known/openid-configuration`, url2.origin),
|
|
16468
|
-
type: "oidc"
|
|
16469
|
-
});
|
|
16470
|
-
return urlsToTry;
|
|
16471
|
-
}
|
|
16472
|
-
async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = LATEST_PROTOCOL_VERSION } = {}) {
|
|
16473
|
-
const headers = {
|
|
16474
|
-
"MCP-Protocol-Version": protocolVersion,
|
|
16475
|
-
Accept: "application/json"
|
|
16476
|
-
};
|
|
16477
|
-
const urlsToTry = buildDiscoveryUrls(authorizationServerUrl);
|
|
16478
|
-
for (const { url: endpointUrl, type } of urlsToTry) {
|
|
16479
|
-
const response = await fetchWithCorsRetry(endpointUrl, headers, fetchFn);
|
|
16480
|
-
if (!response) {
|
|
16481
|
-
continue;
|
|
16482
|
-
}
|
|
16483
|
-
if (!response.ok) {
|
|
16484
|
-
await response.body?.cancel();
|
|
16485
|
-
if (response.status >= 400 && response.status < 500) {
|
|
16486
|
-
continue;
|
|
16487
|
-
}
|
|
16488
|
-
throw new Error(`HTTP ${response.status} trying to load ${type === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${endpointUrl}`);
|
|
16489
|
-
}
|
|
16490
|
-
if (type === "oauth") {
|
|
16491
|
-
return OAuthMetadataSchema.parse(await response.json());
|
|
16492
|
-
} else {
|
|
16493
|
-
return OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());
|
|
16494
|
-
}
|
|
16495
|
-
}
|
|
16496
|
-
return void 0;
|
|
16497
|
-
}
|
|
16498
|
-
async function discoverOAuthServerInfo(serverUrl, opts) {
|
|
16499
|
-
let resourceMetadata;
|
|
16500
|
-
let authorizationServerUrl;
|
|
16501
|
-
try {
|
|
16502
|
-
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: opts?.resourceMetadataUrl }, opts?.fetchFn);
|
|
16503
|
-
if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {
|
|
16504
|
-
authorizationServerUrl = resourceMetadata.authorization_servers[0];
|
|
16505
|
-
}
|
|
16506
|
-
} catch {
|
|
16507
|
-
}
|
|
16508
|
-
if (!authorizationServerUrl) {
|
|
16509
|
-
authorizationServerUrl = String(new URL("/", serverUrl));
|
|
16510
|
-
}
|
|
16511
|
-
const authorizationServerMetadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn: opts?.fetchFn });
|
|
16512
|
-
return {
|
|
16513
|
-
authorizationServerUrl,
|
|
16514
|
-
authorizationServerMetadata,
|
|
16515
|
-
resourceMetadata
|
|
16516
|
-
};
|
|
16517
|
-
}
|
|
16518
|
-
async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
|
|
16519
|
-
let authorizationUrl;
|
|
16520
|
-
if (metadata) {
|
|
16521
|
-
authorizationUrl = new URL(metadata.authorization_endpoint);
|
|
16522
|
-
if (!metadata.response_types_supported.includes(AUTHORIZATION_CODE_RESPONSE_TYPE)) {
|
|
16523
|
-
throw new Error(`Incompatible auth server: does not support response type ${AUTHORIZATION_CODE_RESPONSE_TYPE}`);
|
|
16524
|
-
}
|
|
16525
|
-
if (metadata.code_challenge_methods_supported && !metadata.code_challenge_methods_supported.includes(AUTHORIZATION_CODE_CHALLENGE_METHOD)) {
|
|
16526
|
-
throw new Error(`Incompatible auth server: does not support code challenge method ${AUTHORIZATION_CODE_CHALLENGE_METHOD}`);
|
|
16527
|
-
}
|
|
16528
|
-
} else {
|
|
16529
|
-
authorizationUrl = new URL("/authorize", authorizationServerUrl);
|
|
16530
|
-
}
|
|
16531
|
-
const challenge = await pkceChallenge();
|
|
16532
|
-
const codeVerifier = challenge.code_verifier;
|
|
16533
|
-
const codeChallenge = challenge.code_challenge;
|
|
16534
|
-
authorizationUrl.searchParams.set("response_type", AUTHORIZATION_CODE_RESPONSE_TYPE);
|
|
16535
|
-
authorizationUrl.searchParams.set("client_id", clientInformation.client_id);
|
|
16536
|
-
authorizationUrl.searchParams.set("code_challenge", codeChallenge);
|
|
16537
|
-
authorizationUrl.searchParams.set("code_challenge_method", AUTHORIZATION_CODE_CHALLENGE_METHOD);
|
|
16538
|
-
authorizationUrl.searchParams.set("redirect_uri", String(redirectUrl));
|
|
16539
|
-
if (state) {
|
|
16540
|
-
authorizationUrl.searchParams.set("state", state);
|
|
16541
|
-
}
|
|
16542
|
-
if (scope) {
|
|
16543
|
-
authorizationUrl.searchParams.set("scope", scope);
|
|
16544
|
-
}
|
|
16545
|
-
if (scope?.includes("offline_access")) {
|
|
16546
|
-
authorizationUrl.searchParams.append("prompt", "consent");
|
|
16547
|
-
}
|
|
16548
|
-
if (resource) {
|
|
16549
|
-
authorizationUrl.searchParams.set("resource", resource.href);
|
|
16550
|
-
}
|
|
16551
|
-
return { authorizationUrl, codeVerifier };
|
|
16552
|
-
}
|
|
16553
|
-
function prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redirectUri) {
|
|
16554
|
-
return new URLSearchParams({
|
|
16555
|
-
grant_type: "authorization_code",
|
|
16556
|
-
code: authorizationCode,
|
|
16557
|
-
code_verifier: codeVerifier,
|
|
16558
|
-
redirect_uri: String(redirectUri)
|
|
16559
|
-
});
|
|
16560
|
-
}
|
|
16561
|
-
async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequestParams, clientInformation, addClientAuthentication, resource, fetchFn }) {
|
|
16562
|
-
const tokenUrl = metadata?.token_endpoint ? new URL(metadata.token_endpoint) : new URL("/token", authorizationServerUrl);
|
|
16563
|
-
const headers = new Headers({
|
|
16564
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
16565
|
-
Accept: "application/json"
|
|
16566
|
-
});
|
|
16567
|
-
if (resource) {
|
|
16568
|
-
tokenRequestParams.set("resource", resource.href);
|
|
16569
|
-
}
|
|
16570
|
-
if (addClientAuthentication) {
|
|
16571
|
-
await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata);
|
|
16572
|
-
} else if (clientInformation) {
|
|
16573
|
-
const supportedMethods = metadata?.token_endpoint_auth_methods_supported ?? [];
|
|
16574
|
-
const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
|
|
16575
|
-
applyClientAuthentication(authMethod, clientInformation, headers, tokenRequestParams);
|
|
16576
|
-
}
|
|
16577
|
-
const response = await (fetchFn ?? fetch)(tokenUrl, {
|
|
16578
|
-
method: "POST",
|
|
16579
|
-
headers,
|
|
16580
|
-
body: tokenRequestParams
|
|
16581
|
-
});
|
|
16582
|
-
if (!response.ok) {
|
|
16583
|
-
throw await parseErrorResponse(response);
|
|
16584
|
-
}
|
|
16585
|
-
return OAuthTokensSchema.parse(await response.json());
|
|
16586
|
-
}
|
|
16587
|
-
async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }) {
|
|
16588
|
-
const tokenRequestParams = new URLSearchParams({
|
|
16589
|
-
grant_type: "refresh_token",
|
|
16590
|
-
refresh_token: refreshToken
|
|
16591
|
-
});
|
|
16592
|
-
const tokens = await executeTokenRequest(authorizationServerUrl, {
|
|
16593
|
-
metadata,
|
|
16594
|
-
tokenRequestParams,
|
|
16595
|
-
clientInformation,
|
|
16596
|
-
addClientAuthentication,
|
|
16597
|
-
resource,
|
|
16598
|
-
fetchFn
|
|
16599
|
-
});
|
|
16600
|
-
return { refresh_token: refreshToken, ...tokens };
|
|
16601
|
-
}
|
|
16602
|
-
async function fetchToken(provider, authorizationServerUrl, { metadata, resource, authorizationCode, fetchFn } = {}) {
|
|
16603
|
-
const scope = provider.clientMetadata.scope;
|
|
16604
|
-
let tokenRequestParams;
|
|
16605
|
-
if (provider.prepareTokenRequest) {
|
|
16606
|
-
tokenRequestParams = await provider.prepareTokenRequest(scope);
|
|
16607
|
-
}
|
|
16608
|
-
if (!tokenRequestParams) {
|
|
16609
|
-
if (!authorizationCode) {
|
|
16610
|
-
throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");
|
|
16611
|
-
}
|
|
16612
|
-
if (!provider.redirectUrl) {
|
|
16613
|
-
throw new Error("redirectUrl is required for authorization_code flow");
|
|
16614
|
-
}
|
|
16615
|
-
const codeVerifier = await provider.codeVerifier();
|
|
16616
|
-
tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, provider.redirectUrl);
|
|
16617
|
-
}
|
|
16618
|
-
const clientInformation = await provider.clientInformation();
|
|
16619
|
-
return executeTokenRequest(authorizationServerUrl, {
|
|
16620
|
-
metadata,
|
|
16621
|
-
tokenRequestParams,
|
|
16622
|
-
clientInformation: clientInformation ?? void 0,
|
|
16623
|
-
addClientAuthentication: provider.addClientAuthentication,
|
|
16624
|
-
resource,
|
|
16625
|
-
fetchFn
|
|
16626
|
-
});
|
|
16627
|
-
}
|
|
16628
|
-
async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
|
|
16629
|
-
let registrationUrl;
|
|
16630
|
-
if (metadata) {
|
|
16631
|
-
if (!metadata.registration_endpoint) {
|
|
16632
|
-
throw new Error("Incompatible auth server: does not support dynamic client registration");
|
|
16633
|
-
}
|
|
16634
|
-
registrationUrl = new URL(metadata.registration_endpoint);
|
|
16635
|
-
} else {
|
|
16636
|
-
registrationUrl = new URL("/register", authorizationServerUrl);
|
|
16637
|
-
}
|
|
16638
|
-
const response = await (fetchFn ?? fetch)(registrationUrl, {
|
|
16639
|
-
method: "POST",
|
|
16640
|
-
headers: {
|
|
16641
|
-
"Content-Type": "application/json"
|
|
16642
|
-
},
|
|
16643
|
-
body: JSON.stringify({
|
|
16644
|
-
...clientMetadata,
|
|
16645
|
-
...scope !== void 0 ? { scope } : {}
|
|
16646
|
-
})
|
|
16647
|
-
});
|
|
16648
|
-
if (!response.ok) {
|
|
16649
|
-
throw await parseErrorResponse(response);
|
|
16650
|
-
}
|
|
16651
|
-
return OAuthClientInformationFullSchema.parse(await response.json());
|
|
16652
|
-
}
|
|
16653
|
-
|
|
16654
|
-
// node_modules/eventsource-parser/dist/index.js
|
|
16655
|
-
var ParseError = class extends Error {
|
|
16656
|
-
constructor(message, options) {
|
|
16657
|
-
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
16658
|
-
}
|
|
16659
|
-
};
|
|
16660
|
-
var LF = 10;
|
|
16661
|
-
var CR = 13;
|
|
16662
|
-
var SPACE = 32;
|
|
16663
|
-
function noop(_arg) {
|
|
16664
|
-
}
|
|
16665
|
-
function createParser(config2) {
|
|
16666
|
-
if (typeof config2 == "function")
|
|
16667
|
-
throw new TypeError(
|
|
16668
|
-
"`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
|
|
16669
|
-
);
|
|
16670
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
|
|
16671
|
-
let pendingFragmentsLength = 0, isFirstChunk = true, id, data = "", dataLines = 0, eventType, terminated = false;
|
|
16672
|
-
function feed(chunk) {
|
|
16673
|
-
if (terminated)
|
|
16674
|
-
throw new Error(
|
|
16675
|
-
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
16676
|
-
);
|
|
16677
|
-
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
16678
|
-
const trailing2 = processLines(chunk);
|
|
16679
|
-
trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
|
|
16680
|
-
return;
|
|
16681
|
-
}
|
|
16682
|
-
if (chunk.indexOf(`
|
|
16683
|
-
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
16684
|
-
pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
|
|
16685
|
-
return;
|
|
16686
|
-
}
|
|
16687
|
-
pendingFragments.push(chunk);
|
|
16688
|
-
const input = pendingFragments.join("");
|
|
16689
|
-
pendingFragments.length = 0, pendingFragmentsLength = 0;
|
|
16690
|
-
const trailing = processLines(input);
|
|
16691
|
-
trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
|
|
16692
|
-
}
|
|
16693
|
-
function checkBufferSize() {
|
|
16694
|
-
maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(
|
|
16695
|
-
new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
16696
|
-
type: "max-buffer-size-exceeded"
|
|
16697
|
-
})
|
|
16698
|
-
)));
|
|
16699
|
-
}
|
|
16700
|
-
function processLines(chunk) {
|
|
16701
|
-
let searchIndex = 0;
|
|
16702
|
-
if (chunk.indexOf("\r") === -1) {
|
|
16703
|
-
let lfIndex = chunk.indexOf(`
|
|
16704
|
-
`, searchIndex);
|
|
16705
|
-
for (; lfIndex !== -1; ) {
|
|
16706
|
-
if (searchIndex === lfIndex) {
|
|
16707
|
-
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
16708
|
-
`, searchIndex);
|
|
16709
|
-
continue;
|
|
16710
|
-
}
|
|
16711
|
-
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
16712
|
-
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
16713
|
-
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
16714
|
-
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
16715
|
-
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
16716
|
-
`, searchIndex);
|
|
16717
|
-
continue;
|
|
16718
|
-
}
|
|
16719
|
-
data = dataLines === 0 ? value : `${data}
|
|
16720
|
-
${value}`, dataLines++;
|
|
16721
|
-
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
16722
|
-
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
16723
|
-
lfIndex
|
|
16724
|
-
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
16725
|
-
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
16726
|
-
`, searchIndex);
|
|
16727
|
-
}
|
|
16728
|
-
return chunk.slice(searchIndex);
|
|
16729
|
-
}
|
|
16730
|
-
for (; searchIndex < chunk.length; ) {
|
|
16731
|
-
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
16732
|
-
`, searchIndex);
|
|
16733
|
-
let lineEnd = -1;
|
|
16734
|
-
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
|
|
16735
|
-
break;
|
|
16736
|
-
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
16737
|
-
}
|
|
16738
|
-
return chunk.slice(searchIndex);
|
|
16739
|
-
}
|
|
16740
|
-
function parseLine(chunk, start, end) {
|
|
16741
|
-
if (start === end) {
|
|
16742
|
-
dispatchEvent();
|
|
16743
|
-
return;
|
|
16744
|
-
}
|
|
16745
|
-
const firstCharCode = chunk.charCodeAt(start);
|
|
16746
|
-
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
16747
|
-
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
16748
|
-
data = dataLines === 0 ? value2 : `${data}
|
|
16749
|
-
${value2}`, dataLines++;
|
|
16750
|
-
return;
|
|
16751
|
-
}
|
|
16752
|
-
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
16753
|
-
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
16754
|
-
return;
|
|
16755
|
-
}
|
|
16756
|
-
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
16757
|
-
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
16758
|
-
id = value2.includes("\0") ? void 0 : value2;
|
|
16759
|
-
return;
|
|
16760
|
-
}
|
|
16761
|
-
if (firstCharCode === 58) {
|
|
16762
|
-
if (onComment) {
|
|
16763
|
-
const line2 = chunk.slice(start, end);
|
|
16764
|
-
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
16765
|
-
}
|
|
16766
|
-
return;
|
|
16767
|
-
}
|
|
16768
|
-
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
16769
|
-
if (fieldSeparatorIndex === -1) {
|
|
16770
|
-
processField(line, "", line);
|
|
16771
|
-
return;
|
|
16772
|
-
}
|
|
16773
|
-
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
16774
|
-
processField(field, value, line);
|
|
16775
|
-
}
|
|
16776
|
-
function processField(field, value, line) {
|
|
16777
|
-
switch (field) {
|
|
16778
|
-
case "event":
|
|
16779
|
-
eventType = value || void 0;
|
|
16780
|
-
break;
|
|
16781
|
-
case "data":
|
|
16782
|
-
data = dataLines === 0 ? value : `${data}
|
|
16783
|
-
${value}`, dataLines++;
|
|
16784
|
-
break;
|
|
16785
|
-
case "id":
|
|
16786
|
-
id = value.includes("\0") ? void 0 : value;
|
|
16787
|
-
break;
|
|
16788
|
-
case "retry":
|
|
16789
|
-
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
|
|
16790
|
-
new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
16791
|
-
type: "invalid-retry",
|
|
16792
|
-
value,
|
|
16793
|
-
line
|
|
16794
|
-
})
|
|
16795
|
-
);
|
|
16796
|
-
break;
|
|
16797
|
-
default:
|
|
16798
|
-
onError(
|
|
16799
|
-
new ParseError(
|
|
16800
|
-
`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
|
|
16801
|
-
{ type: "unknown-field", field, value, line }
|
|
16802
|
-
)
|
|
16803
|
-
);
|
|
16804
|
-
break;
|
|
16805
|
-
}
|
|
16806
|
-
}
|
|
16807
|
-
function dispatchEvent() {
|
|
16808
|
-
dataLines > 0 && onEvent({
|
|
16809
|
-
id,
|
|
16810
|
-
event: eventType,
|
|
16811
|
-
data
|
|
16812
|
-
}), id = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
16813
|
-
}
|
|
16814
|
-
function reset(options = {}) {
|
|
16815
|
-
if (options.consume && pendingFragments.length > 0) {
|
|
16816
|
-
const incompleteLine = pendingFragments.join("");
|
|
16817
|
-
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
16818
|
-
}
|
|
16819
|
-
isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
|
|
16820
|
-
}
|
|
16821
|
-
return { feed, reset };
|
|
16822
|
-
}
|
|
16823
|
-
function isDataPrefix(chunk, i, firstCharCode) {
|
|
16824
|
-
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
16825
|
-
}
|
|
16826
|
-
function isEventPrefix(chunk, i, firstCharCode) {
|
|
16827
|
-
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
16828
|
-
}
|
|
16829
|
-
|
|
16830
|
-
// node_modules/eventsource-parser/dist/stream.js
|
|
16831
|
-
var EventSourceParserStream = class extends TransformStream {
|
|
16832
|
-
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
16833
|
-
let parser;
|
|
16834
|
-
super({
|
|
16835
|
-
start(controller) {
|
|
16836
|
-
parser = createParser({
|
|
16837
|
-
onEvent: (event) => {
|
|
16838
|
-
controller.enqueue(event);
|
|
16839
|
-
},
|
|
16840
|
-
onError(error2) {
|
|
16841
|
-
typeof onError == "function" && onError(error2), (onError === "terminate" || error2.type === "max-buffer-size-exceeded") && controller.error(error2);
|
|
16842
|
-
},
|
|
16843
|
-
onRetry,
|
|
16844
|
-
onComment,
|
|
16845
|
-
maxBufferSize
|
|
16846
|
-
});
|
|
16847
|
-
},
|
|
16848
|
-
transform(chunk) {
|
|
16849
|
-
parser.feed(chunk);
|
|
16850
|
-
}
|
|
16851
|
-
});
|
|
16852
|
-
}
|
|
16853
|
-
};
|
|
16854
|
-
|
|
16855
|
-
// node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js
|
|
16856
|
-
var DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS = {
|
|
16857
|
-
initialReconnectionDelay: 1e3,
|
|
16858
|
-
maxReconnectionDelay: 3e4,
|
|
16859
|
-
reconnectionDelayGrowFactor: 1.5,
|
|
16860
|
-
maxRetries: 2
|
|
16861
|
-
};
|
|
16862
|
-
var StreamableHTTPError = class extends Error {
|
|
16863
|
-
constructor(code, message) {
|
|
16864
|
-
super(`Streamable HTTP error: ${message}`);
|
|
16865
|
-
this.code = code;
|
|
16866
|
-
}
|
|
16867
|
-
};
|
|
16868
|
-
var StreamableHTTPClientTransport = class {
|
|
16869
|
-
constructor(url2, opts) {
|
|
16870
|
-
this._hasCompletedAuthFlow = false;
|
|
16871
|
-
this._url = url2;
|
|
16872
|
-
this._resourceMetadataUrl = void 0;
|
|
16873
|
-
this._scope = void 0;
|
|
16874
|
-
this._requestInit = opts?.requestInit;
|
|
16875
|
-
this._authProvider = opts?.authProvider;
|
|
16876
|
-
this._fetch = opts?.fetch;
|
|
16877
|
-
this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
16878
|
-
this._sessionId = opts?.sessionId;
|
|
16879
|
-
this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
|
|
16880
|
-
}
|
|
16881
|
-
async _authThenStart() {
|
|
16882
|
-
if (!this._authProvider) {
|
|
16883
|
-
throw new UnauthorizedError("No auth provider");
|
|
16884
|
-
}
|
|
16885
|
-
let result;
|
|
16886
|
-
try {
|
|
16887
|
-
result = await auth(this._authProvider, {
|
|
16888
|
-
serverUrl: this._url,
|
|
16889
|
-
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
16890
|
-
scope: this._scope,
|
|
16891
|
-
fetchFn: this._fetchWithInit
|
|
16892
|
-
});
|
|
16893
|
-
} catch (error2) {
|
|
16894
|
-
this.onerror?.(error2);
|
|
16895
|
-
throw error2;
|
|
16896
|
-
}
|
|
16897
|
-
if (result !== "AUTHORIZED") {
|
|
16898
|
-
throw new UnauthorizedError();
|
|
16899
|
-
}
|
|
16900
|
-
return await this._startOrAuthSse({ resumptionToken: void 0 });
|
|
16901
|
-
}
|
|
16902
|
-
async _commonHeaders() {
|
|
16903
|
-
const headers = {};
|
|
16904
|
-
if (this._authProvider) {
|
|
16905
|
-
const tokens = await this._authProvider.tokens();
|
|
16906
|
-
if (tokens) {
|
|
16907
|
-
headers["Authorization"] = `Bearer ${tokens.access_token}`;
|
|
16908
|
-
}
|
|
16909
|
-
}
|
|
16910
|
-
if (this._sessionId) {
|
|
16911
|
-
headers["mcp-session-id"] = this._sessionId;
|
|
16912
|
-
}
|
|
16913
|
-
if (this._protocolVersion) {
|
|
16914
|
-
headers["mcp-protocol-version"] = this._protocolVersion;
|
|
16915
|
-
}
|
|
16916
|
-
const extraHeaders = normalizeHeaders(this._requestInit?.headers);
|
|
16917
|
-
return new Headers({
|
|
16918
|
-
...headers,
|
|
16919
|
-
...extraHeaders
|
|
16920
|
-
});
|
|
16921
|
-
}
|
|
16922
|
-
async _startOrAuthSse(options) {
|
|
16923
|
-
const { resumptionToken } = options;
|
|
16924
|
-
try {
|
|
16925
|
-
const headers = await this._commonHeaders();
|
|
16926
|
-
headers.set("Accept", "text/event-stream");
|
|
16927
|
-
if (resumptionToken) {
|
|
16928
|
-
headers.set("last-event-id", resumptionToken);
|
|
16929
|
-
}
|
|
16930
|
-
const response = await (this._fetch ?? fetch)(this._url, {
|
|
16931
|
-
method: "GET",
|
|
16932
|
-
headers,
|
|
16933
|
-
signal: this._abortController?.signal
|
|
16934
|
-
});
|
|
16935
|
-
if (!response.ok) {
|
|
16936
|
-
await response.body?.cancel();
|
|
16937
|
-
if (response.status === 401 && this._authProvider) {
|
|
16938
|
-
return await this._authThenStart();
|
|
16939
|
-
}
|
|
16940
|
-
if (response.status === 405) {
|
|
16941
|
-
return;
|
|
16942
|
-
}
|
|
16943
|
-
throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${response.statusText}`);
|
|
16944
|
-
}
|
|
16945
|
-
this._handleSseStream(response.body, options, true);
|
|
16946
|
-
} catch (error2) {
|
|
16947
|
-
this.onerror?.(error2);
|
|
16948
|
-
throw error2;
|
|
16949
|
-
}
|
|
16950
|
-
}
|
|
16951
|
-
/**
|
|
16952
|
-
* Calculates the next reconnection delay using backoff algorithm
|
|
16953
|
-
*
|
|
16954
|
-
* @param attempt Current reconnection attempt count for the specific stream
|
|
16955
|
-
* @returns Time to wait in milliseconds before next reconnection attempt
|
|
16956
|
-
*/
|
|
16957
|
-
_getNextReconnectionDelay(attempt) {
|
|
16958
|
-
if (this._serverRetryMs !== void 0) {
|
|
16959
|
-
return this._serverRetryMs;
|
|
16960
|
-
}
|
|
16961
|
-
const initialDelay = this._reconnectionOptions.initialReconnectionDelay;
|
|
16962
|
-
const growFactor = this._reconnectionOptions.reconnectionDelayGrowFactor;
|
|
16963
|
-
const maxDelay = this._reconnectionOptions.maxReconnectionDelay;
|
|
16964
|
-
return Math.min(initialDelay * Math.pow(growFactor, attempt), maxDelay);
|
|
16965
|
-
}
|
|
16966
|
-
/**
|
|
16967
|
-
* Schedule a reconnection attempt using server-provided retry interval or backoff
|
|
16968
|
-
*
|
|
16969
|
-
* @param lastEventId The ID of the last received event for resumability
|
|
16970
|
-
* @param attemptCount Current reconnection attempt count for this specific stream
|
|
16971
|
-
*/
|
|
16972
|
-
_scheduleReconnection(options, attemptCount = 0) {
|
|
16973
|
-
const maxRetries = this._reconnectionOptions.maxRetries;
|
|
16974
|
-
if (attemptCount >= maxRetries) {
|
|
16975
|
-
this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
|
|
16976
|
-
return;
|
|
16977
|
-
}
|
|
16978
|
-
const delay = this._getNextReconnectionDelay(attemptCount);
|
|
16979
|
-
this._reconnectionTimeout = setTimeout(() => {
|
|
16980
|
-
this._startOrAuthSse(options).catch((error2) => {
|
|
16981
|
-
this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error2 instanceof Error ? error2.message : String(error2)}`));
|
|
16982
|
-
this._scheduleReconnection(options, attemptCount + 1);
|
|
16983
|
-
});
|
|
16984
|
-
}, delay);
|
|
16985
|
-
}
|
|
16986
|
-
_handleSseStream(stream, options, isReconnectable) {
|
|
16987
|
-
if (!stream) {
|
|
16988
|
-
return;
|
|
16989
|
-
}
|
|
16990
|
-
const { onresumptiontoken, replayMessageId } = options;
|
|
16991
|
-
let lastEventId;
|
|
16992
|
-
let hasPrimingEvent = false;
|
|
16993
|
-
let receivedResponse = false;
|
|
16994
|
-
const processStream = async () => {
|
|
16995
|
-
try {
|
|
16996
|
-
const reader = stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream({
|
|
16997
|
-
onRetry: (retryMs) => {
|
|
16998
|
-
this._serverRetryMs = retryMs;
|
|
16999
|
-
}
|
|
17000
|
-
})).getReader();
|
|
17001
|
-
while (true) {
|
|
17002
|
-
const { value: event, done } = await reader.read();
|
|
17003
|
-
if (done) {
|
|
17004
|
-
break;
|
|
17005
|
-
}
|
|
17006
|
-
if (event.id) {
|
|
17007
|
-
lastEventId = event.id;
|
|
17008
|
-
hasPrimingEvent = true;
|
|
17009
|
-
onresumptiontoken?.(event.id);
|
|
17010
|
-
}
|
|
17011
|
-
if (!event.data) {
|
|
17012
|
-
continue;
|
|
17013
|
-
}
|
|
17014
|
-
if (!event.event || event.event === "message") {
|
|
17015
|
-
try {
|
|
17016
|
-
const message = JSONRPCMessageSchema.parse(JSON.parse(event.data));
|
|
17017
|
-
if (isJSONRPCResultResponse(message)) {
|
|
17018
|
-
receivedResponse = true;
|
|
17019
|
-
if (replayMessageId !== void 0) {
|
|
17020
|
-
message.id = replayMessageId;
|
|
17021
|
-
}
|
|
17022
|
-
}
|
|
17023
|
-
this.onmessage?.(message);
|
|
17024
|
-
} catch (error2) {
|
|
17025
|
-
this.onerror?.(error2);
|
|
17026
|
-
}
|
|
17027
|
-
}
|
|
17028
|
-
}
|
|
17029
|
-
const canResume = isReconnectable || hasPrimingEvent;
|
|
17030
|
-
const needsReconnect = canResume && !receivedResponse;
|
|
17031
|
-
if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
|
|
17032
|
-
this._scheduleReconnection({
|
|
17033
|
-
resumptionToken: lastEventId,
|
|
17034
|
-
onresumptiontoken,
|
|
17035
|
-
replayMessageId
|
|
17036
|
-
}, 0);
|
|
17037
|
-
}
|
|
17038
|
-
} catch (error2) {
|
|
17039
|
-
this.onerror?.(new Error(`SSE stream disconnected: ${error2}`));
|
|
17040
|
-
const canResume = isReconnectable || hasPrimingEvent;
|
|
17041
|
-
const needsReconnect = canResume && !receivedResponse;
|
|
17042
|
-
if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
|
|
17043
|
-
try {
|
|
17044
|
-
this._scheduleReconnection({
|
|
17045
|
-
resumptionToken: lastEventId,
|
|
17046
|
-
onresumptiontoken,
|
|
17047
|
-
replayMessageId
|
|
17048
|
-
}, 0);
|
|
17049
|
-
} catch (error3) {
|
|
17050
|
-
this.onerror?.(new Error(`Failed to reconnect: ${error3 instanceof Error ? error3.message : String(error3)}`));
|
|
17051
|
-
}
|
|
17052
|
-
}
|
|
17053
|
-
}
|
|
17054
|
-
};
|
|
17055
|
-
processStream();
|
|
17056
|
-
}
|
|
17057
|
-
async start() {
|
|
17058
|
-
if (this._abortController) {
|
|
17059
|
-
throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
17060
|
-
}
|
|
17061
|
-
this._abortController = new AbortController();
|
|
17062
|
-
}
|
|
17063
|
-
/**
|
|
17064
|
-
* Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
|
|
17065
|
-
*/
|
|
17066
|
-
async finishAuth(authorizationCode) {
|
|
17067
|
-
if (!this._authProvider) {
|
|
17068
|
-
throw new UnauthorizedError("No auth provider");
|
|
17069
|
-
}
|
|
17070
|
-
const result = await auth(this._authProvider, {
|
|
17071
|
-
serverUrl: this._url,
|
|
17072
|
-
authorizationCode,
|
|
17073
|
-
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
17074
|
-
scope: this._scope,
|
|
17075
|
-
fetchFn: this._fetchWithInit
|
|
17076
|
-
});
|
|
17077
|
-
if (result !== "AUTHORIZED") {
|
|
17078
|
-
throw new UnauthorizedError("Failed to authorize");
|
|
17079
|
-
}
|
|
17080
|
-
}
|
|
17081
|
-
async close() {
|
|
17082
|
-
if (this._reconnectionTimeout) {
|
|
17083
|
-
clearTimeout(this._reconnectionTimeout);
|
|
17084
|
-
this._reconnectionTimeout = void 0;
|
|
17085
|
-
}
|
|
17086
|
-
this._abortController?.abort();
|
|
17087
|
-
this.onclose?.();
|
|
17088
|
-
}
|
|
17089
|
-
async send(message, options) {
|
|
17090
|
-
try {
|
|
17091
|
-
const { resumptionToken, onresumptiontoken } = options || {};
|
|
17092
|
-
if (resumptionToken) {
|
|
17093
|
-
this._startOrAuthSse({ resumptionToken, replayMessageId: isJSONRPCRequest(message) ? message.id : void 0 }).catch((err) => this.onerror?.(err));
|
|
17094
|
-
return;
|
|
17095
|
-
}
|
|
17096
|
-
const headers = await this._commonHeaders();
|
|
17097
|
-
headers.set("content-type", "application/json");
|
|
17098
|
-
headers.set("accept", "application/json, text/event-stream");
|
|
17099
|
-
const init = {
|
|
17100
|
-
...this._requestInit,
|
|
17101
|
-
method: "POST",
|
|
17102
|
-
headers,
|
|
17103
|
-
body: JSON.stringify(message),
|
|
17104
|
-
signal: this._abortController?.signal
|
|
17105
|
-
};
|
|
17106
|
-
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
17107
|
-
const sessionId = response.headers.get("mcp-session-id");
|
|
17108
|
-
if (sessionId) {
|
|
17109
|
-
this._sessionId = sessionId;
|
|
17110
|
-
}
|
|
17111
|
-
if (!response.ok) {
|
|
17112
|
-
const text = await response.text().catch(() => null);
|
|
17113
|
-
if (response.status === 401 && this._authProvider) {
|
|
17114
|
-
if (this._hasCompletedAuthFlow) {
|
|
17115
|
-
throw new StreamableHTTPError(401, "Server returned 401 after successful authentication");
|
|
17116
|
-
}
|
|
17117
|
-
const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
|
|
17118
|
-
this._resourceMetadataUrl = resourceMetadataUrl;
|
|
17119
|
-
this._scope = scope;
|
|
17120
|
-
const result = await auth(this._authProvider, {
|
|
17121
|
-
serverUrl: this._url,
|
|
17122
|
-
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
17123
|
-
scope: this._scope,
|
|
17124
|
-
fetchFn: this._fetchWithInit
|
|
17125
|
-
});
|
|
17126
|
-
if (result !== "AUTHORIZED") {
|
|
17127
|
-
throw new UnauthorizedError();
|
|
17128
|
-
}
|
|
17129
|
-
this._hasCompletedAuthFlow = true;
|
|
17130
|
-
return this.send(message);
|
|
17131
|
-
}
|
|
17132
|
-
if (response.status === 403 && this._authProvider) {
|
|
17133
|
-
const { resourceMetadataUrl, scope, error: error2 } = extractWWWAuthenticateParams(response);
|
|
17134
|
-
if (error2 === "insufficient_scope") {
|
|
17135
|
-
const wwwAuthHeader = response.headers.get("WWW-Authenticate");
|
|
17136
|
-
if (this._lastUpscopingHeader === wwwAuthHeader) {
|
|
17137
|
-
throw new StreamableHTTPError(403, "Server returned 403 after trying upscoping");
|
|
17138
|
-
}
|
|
17139
|
-
if (scope) {
|
|
17140
|
-
this._scope = scope;
|
|
17141
|
-
}
|
|
17142
|
-
if (resourceMetadataUrl) {
|
|
17143
|
-
this._resourceMetadataUrl = resourceMetadataUrl;
|
|
17144
|
-
}
|
|
17145
|
-
this._lastUpscopingHeader = wwwAuthHeader ?? void 0;
|
|
17146
|
-
const result = await auth(this._authProvider, {
|
|
17147
|
-
serverUrl: this._url,
|
|
17148
|
-
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
17149
|
-
scope: this._scope,
|
|
17150
|
-
fetchFn: this._fetch
|
|
17151
|
-
});
|
|
17152
|
-
if (result !== "AUTHORIZED") {
|
|
17153
|
-
throw new UnauthorizedError();
|
|
17154
|
-
}
|
|
17155
|
-
return this.send(message);
|
|
17156
|
-
}
|
|
17157
|
-
}
|
|
17158
|
-
throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
|
|
17159
|
-
}
|
|
17160
|
-
this._hasCompletedAuthFlow = false;
|
|
17161
|
-
this._lastUpscopingHeader = void 0;
|
|
17162
|
-
if (response.status === 202) {
|
|
17163
|
-
await response.body?.cancel();
|
|
17164
|
-
if (isInitializedNotification(message)) {
|
|
17165
|
-
this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) => this.onerror?.(err));
|
|
17166
|
-
}
|
|
17167
|
-
return;
|
|
17168
|
-
}
|
|
17169
|
-
const messages = Array.isArray(message) ? message : [message];
|
|
17170
|
-
const hasRequests = messages.filter((msg) => "method" in msg && "id" in msg && msg.id !== void 0).length > 0;
|
|
17171
|
-
const contentType2 = response.headers.get("content-type");
|
|
17172
|
-
const responseMediaType = mediaTypeEssence(contentType2);
|
|
17173
|
-
if (hasRequests) {
|
|
17174
|
-
if (responseMediaType === "text/event-stream") {
|
|
17175
|
-
this._handleSseStream(response.body, { onresumptiontoken }, false);
|
|
17176
|
-
} else if (responseMediaType === "application/json") {
|
|
17177
|
-
const data = await response.json();
|
|
17178
|
-
const responseMessages = Array.isArray(data) ? data.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data)];
|
|
17179
|
-
for (const msg of responseMessages) {
|
|
17180
|
-
this.onmessage?.(msg);
|
|
17181
|
-
}
|
|
17182
|
-
} else {
|
|
17183
|
-
await response.body?.cancel();
|
|
17184
|
-
throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType2}`);
|
|
17185
|
-
}
|
|
17186
|
-
} else {
|
|
17187
|
-
await response.body?.cancel();
|
|
17188
|
-
}
|
|
17189
|
-
} catch (error2) {
|
|
17190
|
-
this.onerror?.(error2);
|
|
17191
|
-
throw error2;
|
|
17192
|
-
}
|
|
17193
|
-
}
|
|
17194
|
-
get sessionId() {
|
|
17195
|
-
return this._sessionId;
|
|
17196
|
-
}
|
|
17197
|
-
/**
|
|
17198
|
-
* Terminates the current session by sending a DELETE request to the server.
|
|
17199
|
-
*
|
|
17200
|
-
* Clients that no longer need a particular session
|
|
17201
|
-
* (e.g., because the user is leaving the client application) SHOULD send an
|
|
17202
|
-
* HTTP DELETE to the MCP endpoint with the Mcp-Session-Id header to explicitly
|
|
17203
|
-
* terminate the session.
|
|
17204
|
-
*
|
|
17205
|
-
* The server MAY respond with HTTP 405 Method Not Allowed, indicating that
|
|
17206
|
-
* the server does not allow clients to terminate sessions.
|
|
17207
|
-
*/
|
|
17208
|
-
async terminateSession() {
|
|
17209
|
-
if (!this._sessionId) {
|
|
17210
|
-
return;
|
|
17211
|
-
}
|
|
17212
|
-
try {
|
|
17213
|
-
const headers = await this._commonHeaders();
|
|
17214
|
-
const init = {
|
|
17215
|
-
...this._requestInit,
|
|
17216
|
-
method: "DELETE",
|
|
17217
|
-
headers,
|
|
17218
|
-
signal: this._abortController?.signal
|
|
17219
|
-
};
|
|
17220
|
-
const response = await (this._fetch ?? fetch)(this._url, init);
|
|
17221
|
-
await response.body?.cancel();
|
|
17222
|
-
if (!response.ok && response.status !== 405) {
|
|
17223
|
-
throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
|
|
17224
|
-
}
|
|
17225
|
-
this._sessionId = void 0;
|
|
17226
|
-
} catch (error2) {
|
|
17227
|
-
this.onerror?.(error2);
|
|
17228
|
-
throw error2;
|
|
17229
|
-
}
|
|
17230
|
-
}
|
|
17231
|
-
setProtocolVersion(version2) {
|
|
17232
|
-
this._protocolVersion = version2;
|
|
17233
|
-
}
|
|
17234
|
-
get protocolVersion() {
|
|
17235
|
-
return this._protocolVersion;
|
|
17236
|
-
}
|
|
17237
|
-
/**
|
|
17238
|
-
* Resume an SSE stream from a previous event ID.
|
|
17239
|
-
* Opens a GET SSE connection with Last-Event-ID header to replay missed events.
|
|
17240
|
-
*
|
|
17241
|
-
* @param lastEventId The event ID to resume from
|
|
17242
|
-
* @param options Optional callback to receive new resumption tokens
|
|
17243
|
-
*/
|
|
17244
|
-
async resumeStream(lastEventId, options) {
|
|
17245
|
-
await this._startOrAuthSse({
|
|
17246
|
-
resumptionToken: lastEventId,
|
|
17247
|
-
onresumptiontoken: options?.onresumptiontoken
|
|
17248
|
-
});
|
|
17249
|
-
}
|
|
17250
|
-
};
|
|
17251
|
-
|
|
17252
|
-
// src/pi/rainskills-mcp.ts
|
|
17253
|
-
function decodeEnvValue(raw) {
|
|
17254
|
-
const value = raw.trim();
|
|
17255
|
-
if (value.length >= 2 && value[0] === "'" && value.at(-1) === "'") {
|
|
17256
|
-
return value.slice(1, -1).replace(/'"'"'/g, "'");
|
|
17257
|
-
}
|
|
17258
|
-
if (value.length >= 2 && value[0] === '"' && value.at(-1) === '"') {
|
|
17259
|
-
return value.slice(1, -1).replace(/\\([\\"$`])/g, "$1");
|
|
17260
|
-
}
|
|
17261
|
-
return value;
|
|
17262
|
-
}
|
|
17263
|
-
function readManagedEnv(filePath) {
|
|
17264
|
-
if (!fs.existsSync(filePath)) return {};
|
|
17265
|
-
const values = {};
|
|
17266
|
-
for (const line of fs.readFileSync(filePath, "utf8").split(/\r?\n/)) {
|
|
17267
|
-
const match = line.match(/^\s*(?:export\s+)?(RAINBOND_JWT|RAINBOND_URL)=(.*)$/);
|
|
17268
|
-
if (match) values[match[1]] = decodeEnvValue(match[2]);
|
|
17269
|
-
}
|
|
17270
|
-
return values;
|
|
17271
|
-
}
|
|
17272
|
-
function readRainbondConfig(input = {}) {
|
|
17273
|
-
const env = input.env ?? process.env;
|
|
17274
|
-
const home = input.home ?? os.homedir();
|
|
17275
|
-
const stored = readManagedEnv(path.join(home, ".rainbond", "mcp.env"));
|
|
17276
|
-
const token = env.RAINBOND_JWT || stored.RAINBOND_JWT;
|
|
17277
|
-
const baseUrl = (env.RAINBOND_URL || stored.RAINBOND_URL || "").replace(/\/+$/, "");
|
|
17278
|
-
if (!token || !baseUrl || !/^https?:\/\//.test(baseUrl)) return null;
|
|
17279
|
-
return {
|
|
17280
|
-
token,
|
|
17281
|
-
url: `${baseUrl}/console/mcp/rainskills/pi/query`
|
|
17282
15672
|
};
|
|
17283
|
-
}
|
|
17284
|
-
function publicConfig(config2) {
|
|
17285
|
-
const parsed = new URL(config2.url);
|
|
17286
|
-
return { origin: parsed.origin, endpoint: parsed.pathname };
|
|
17287
|
-
}
|
|
17288
|
-
function toPiContent(result) {
|
|
17289
|
-
const content = Array.isArray(result?.content) ? result.content : [];
|
|
17290
|
-
if (content.length === 0) {
|
|
17291
|
-
return [{ type: "text", text: result?.isError ? "Rainbond MCP call failed." : "Done." }];
|
|
17292
|
-
}
|
|
17293
|
-
return content.map((item) => {
|
|
17294
|
-
if (item?.type === "text" && typeof item.text === "string") {
|
|
17295
|
-
return { type: "text", text: item.text };
|
|
17296
|
-
}
|
|
17297
|
-
return { type: "text", text: JSON.stringify(item) };
|
|
17298
|
-
});
|
|
17299
|
-
}
|
|
17300
|
-
function createMcpClient(config2) {
|
|
17301
|
-
const client = new Client({ name: "rainskills-pi", version: "0.1.0" });
|
|
17302
|
-
const transport = new StreamableHTTPClientTransport(new URL(config2.url), {
|
|
17303
|
-
requestInit: {
|
|
17304
|
-
headers: {
|
|
17305
|
-
Authorization: `GRJWT ${config2.token}`
|
|
17306
|
-
}
|
|
17307
|
-
}
|
|
17308
|
-
});
|
|
17309
15673
|
return {
|
|
17310
15674
|
connect: () => client.connect(transport),
|
|
17311
15675
|
listTools: (params) => client.listTools(params),
|
|
@@ -17359,7 +15723,7 @@ function registerRainbondExtension(pi, dependencies = {}) {
|
|
|
17359
15723
|
await client?.close().catch(() => void 0);
|
|
17360
15724
|
client = null;
|
|
17361
15725
|
ctx?.ui?.notify?.(
|
|
17362
|
-
"
|
|
15726
|
+
"Rainskills \u672C\u5730\u8FD0\u884C\u73AF\u5883\u8DEF\u7531\u8FDE\u63A5\u5931\u8D25\u3002",
|
|
17363
15727
|
"warning"
|
|
17364
15728
|
);
|
|
17365
15729
|
}
|