@kentico/management-api-mcp 30.12.2-preview → 31.0.0-preview
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 +57 -7
- package/dist/index.js +1692 -382
- package/package.json +53 -28
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -469,9 +469,9 @@ var require_codegen = __commonJS({
|
|
|
469
469
|
}
|
|
470
470
|
};
|
|
471
471
|
var Throw = class extends Node {
|
|
472
|
-
constructor(
|
|
472
|
+
constructor(error2) {
|
|
473
473
|
super();
|
|
474
|
-
this.error =
|
|
474
|
+
this.error = error2;
|
|
475
475
|
}
|
|
476
476
|
render({ _n }) {
|
|
477
477
|
return `throw ${this.error};` + _n;
|
|
@@ -708,9 +708,9 @@ var require_codegen = __commonJS({
|
|
|
708
708
|
}
|
|
709
709
|
};
|
|
710
710
|
var Catch = class extends BlockNode {
|
|
711
|
-
constructor(
|
|
711
|
+
constructor(error2) {
|
|
712
712
|
super();
|
|
713
|
-
this.error =
|
|
713
|
+
this.error = error2;
|
|
714
714
|
}
|
|
715
715
|
render(opts) {
|
|
716
716
|
return `catch(${this.error})` + super.render(opts);
|
|
@@ -901,9 +901,9 @@ var require_codegen = __commonJS({
|
|
|
901
901
|
this._blockNode(node);
|
|
902
902
|
this.code(tryBody);
|
|
903
903
|
if (catchCode) {
|
|
904
|
-
const
|
|
905
|
-
this._currNode = node.catch = new Catch(
|
|
906
|
-
catchCode(
|
|
904
|
+
const error2 = this.name("e");
|
|
905
|
+
this._currNode = node.catch = new Catch(error2);
|
|
906
|
+
catchCode(error2);
|
|
907
907
|
}
|
|
908
908
|
if (finallyCode) {
|
|
909
909
|
this._currNode = node.finally = new Finally();
|
|
@@ -912,8 +912,8 @@ var require_codegen = __commonJS({
|
|
|
912
912
|
return this._endBlockNode(Catch, Finally);
|
|
913
913
|
}
|
|
914
914
|
// `throw` statement
|
|
915
|
-
throw(
|
|
916
|
-
return this._leafNode(new Throw(
|
|
915
|
+
throw(error2) {
|
|
916
|
+
return this._leafNode(new Throw(error2));
|
|
917
917
|
}
|
|
918
918
|
// start self-balancing block
|
|
919
919
|
block(body, nodeCount) {
|
|
@@ -1269,10 +1269,10 @@ var require_errors = __commonJS({
|
|
|
1269
1269
|
exports.keyword$DataError = {
|
|
1270
1270
|
message: ({ keyword, schemaType }) => schemaType ? (0, codegen_1.str)`"${keyword}" keyword must be ${schemaType} ($data)` : (0, codegen_1.str)`"${keyword}" keyword is invalid ($data)`
|
|
1271
1271
|
};
|
|
1272
|
-
function reportError(cxt,
|
|
1272
|
+
function reportError(cxt, error2 = exports.keywordError, errorPaths, overrideAllErrors) {
|
|
1273
1273
|
const { it } = cxt;
|
|
1274
1274
|
const { gen, compositeRule, allErrors } = it;
|
|
1275
|
-
const errObj = errorObjectCode(cxt,
|
|
1275
|
+
const errObj = errorObjectCode(cxt, error2, errorPaths);
|
|
1276
1276
|
if (overrideAllErrors !== null && overrideAllErrors !== void 0 ? overrideAllErrors : compositeRule || allErrors) {
|
|
1277
1277
|
addError(gen, errObj);
|
|
1278
1278
|
} else {
|
|
@@ -1280,10 +1280,10 @@ var require_errors = __commonJS({
|
|
|
1280
1280
|
}
|
|
1281
1281
|
}
|
|
1282
1282
|
exports.reportError = reportError;
|
|
1283
|
-
function reportExtraError(cxt,
|
|
1283
|
+
function reportExtraError(cxt, error2 = exports.keywordError, errorPaths) {
|
|
1284
1284
|
const { it } = cxt;
|
|
1285
1285
|
const { gen, compositeRule, allErrors } = it;
|
|
1286
|
-
const errObj = errorObjectCode(cxt,
|
|
1286
|
+
const errObj = errorObjectCode(cxt, error2, errorPaths);
|
|
1287
1287
|
addError(gen, errObj);
|
|
1288
1288
|
if (!(compositeRule || allErrors)) {
|
|
1289
1289
|
returnErrors(it, names_1.default.vErrors);
|
|
@@ -1334,19 +1334,19 @@ var require_errors = __commonJS({
|
|
|
1334
1334
|
schema: new codegen_1.Name("schema"),
|
|
1335
1335
|
parentSchema: new codegen_1.Name("parentSchema")
|
|
1336
1336
|
};
|
|
1337
|
-
function errorObjectCode(cxt,
|
|
1337
|
+
function errorObjectCode(cxt, error2, errorPaths) {
|
|
1338
1338
|
const { createErrors } = cxt.it;
|
|
1339
1339
|
if (createErrors === false)
|
|
1340
1340
|
return (0, codegen_1._)`{}`;
|
|
1341
|
-
return errorObject(cxt,
|
|
1341
|
+
return errorObject(cxt, error2, errorPaths);
|
|
1342
1342
|
}
|
|
1343
|
-
function errorObject(cxt,
|
|
1343
|
+
function errorObject(cxt, error2, errorPaths = {}) {
|
|
1344
1344
|
const { gen, it } = cxt;
|
|
1345
1345
|
const keyValues = [
|
|
1346
1346
|
errorInstancePath(it, errorPaths),
|
|
1347
1347
|
errorSchemaPath(cxt, errorPaths)
|
|
1348
1348
|
];
|
|
1349
|
-
extraErrorProps(cxt,
|
|
1349
|
+
extraErrorProps(cxt, error2, keyValues);
|
|
1350
1350
|
return gen.object(...keyValues);
|
|
1351
1351
|
}
|
|
1352
1352
|
function errorInstancePath({ errorPath }, { instancePath }) {
|
|
@@ -4614,7 +4614,7 @@ var require_limitNumber = __commonJS({
|
|
|
4614
4614
|
exclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE },
|
|
4615
4615
|
exclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE }
|
|
4616
4616
|
};
|
|
4617
|
-
var
|
|
4617
|
+
var error2 = {
|
|
4618
4618
|
message: ({ keyword, schemaCode }) => (0, codegen_1.str)`must be ${KWDs[keyword].okStr} ${schemaCode}`,
|
|
4619
4619
|
params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
|
|
4620
4620
|
};
|
|
@@ -4623,7 +4623,7 @@ var require_limitNumber = __commonJS({
|
|
|
4623
4623
|
type: "number",
|
|
4624
4624
|
schemaType: "number",
|
|
4625
4625
|
$data: true,
|
|
4626
|
-
error,
|
|
4626
|
+
error: error2,
|
|
4627
4627
|
code(cxt) {
|
|
4628
4628
|
const { keyword, data, schemaCode } = cxt;
|
|
4629
4629
|
cxt.fail$data((0, codegen_1._)`${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`);
|
|
@@ -4639,7 +4639,7 @@ var require_multipleOf = __commonJS({
|
|
|
4639
4639
|
"use strict";
|
|
4640
4640
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4641
4641
|
var codegen_1 = require_codegen();
|
|
4642
|
-
var
|
|
4642
|
+
var error2 = {
|
|
4643
4643
|
message: ({ schemaCode }) => (0, codegen_1.str)`must be multiple of ${schemaCode}`,
|
|
4644
4644
|
params: ({ schemaCode }) => (0, codegen_1._)`{multipleOf: ${schemaCode}}`
|
|
4645
4645
|
};
|
|
@@ -4648,7 +4648,7 @@ var require_multipleOf = __commonJS({
|
|
|
4648
4648
|
type: "number",
|
|
4649
4649
|
schemaType: "number",
|
|
4650
4650
|
$data: true,
|
|
4651
|
-
error,
|
|
4651
|
+
error: error2,
|
|
4652
4652
|
code(cxt) {
|
|
4653
4653
|
const { gen, data, schemaCode, it } = cxt;
|
|
4654
4654
|
const prec = it.opts.multipleOfPrecision;
|
|
@@ -4695,7 +4695,7 @@ var require_limitLength = __commonJS({
|
|
|
4695
4695
|
var codegen_1 = require_codegen();
|
|
4696
4696
|
var util_1 = require_util();
|
|
4697
4697
|
var ucs2length_1 = require_ucs2length();
|
|
4698
|
-
var
|
|
4698
|
+
var error2 = {
|
|
4699
4699
|
message({ keyword, schemaCode }) {
|
|
4700
4700
|
const comp = keyword === "maxLength" ? "more" : "fewer";
|
|
4701
4701
|
return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} characters`;
|
|
@@ -4707,7 +4707,7 @@ var require_limitLength = __commonJS({
|
|
|
4707
4707
|
type: "string",
|
|
4708
4708
|
schemaType: "number",
|
|
4709
4709
|
$data: true,
|
|
4710
|
-
error,
|
|
4710
|
+
error: error2,
|
|
4711
4711
|
code(cxt) {
|
|
4712
4712
|
const { keyword, data, schemaCode, it } = cxt;
|
|
4713
4713
|
const op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
|
@@ -4726,7 +4726,7 @@ var require_pattern = __commonJS({
|
|
|
4726
4726
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4727
4727
|
var code_1 = require_code2();
|
|
4728
4728
|
var codegen_1 = require_codegen();
|
|
4729
|
-
var
|
|
4729
|
+
var error2 = {
|
|
4730
4730
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
|
|
4731
4731
|
params: ({ schemaCode }) => (0, codegen_1._)`{pattern: ${schemaCode}}`
|
|
4732
4732
|
};
|
|
@@ -4735,7 +4735,7 @@ var require_pattern = __commonJS({
|
|
|
4735
4735
|
type: "string",
|
|
4736
4736
|
schemaType: "string",
|
|
4737
4737
|
$data: true,
|
|
4738
|
-
error,
|
|
4738
|
+
error: error2,
|
|
4739
4739
|
code(cxt) {
|
|
4740
4740
|
const { data, $data, schema, schemaCode, it } = cxt;
|
|
4741
4741
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
@@ -4753,7 +4753,7 @@ var require_limitProperties = __commonJS({
|
|
|
4753
4753
|
"use strict";
|
|
4754
4754
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4755
4755
|
var codegen_1 = require_codegen();
|
|
4756
|
-
var
|
|
4756
|
+
var error2 = {
|
|
4757
4757
|
message({ keyword, schemaCode }) {
|
|
4758
4758
|
const comp = keyword === "maxProperties" ? "more" : "fewer";
|
|
4759
4759
|
return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} properties`;
|
|
@@ -4765,7 +4765,7 @@ var require_limitProperties = __commonJS({
|
|
|
4765
4765
|
type: "object",
|
|
4766
4766
|
schemaType: "number",
|
|
4767
4767
|
$data: true,
|
|
4768
|
-
error,
|
|
4768
|
+
error: error2,
|
|
4769
4769
|
code(cxt) {
|
|
4770
4770
|
const { keyword, data, schemaCode } = cxt;
|
|
4771
4771
|
const op = keyword === "maxProperties" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
|
@@ -4784,7 +4784,7 @@ var require_required = __commonJS({
|
|
|
4784
4784
|
var code_1 = require_code2();
|
|
4785
4785
|
var codegen_1 = require_codegen();
|
|
4786
4786
|
var util_1 = require_util();
|
|
4787
|
-
var
|
|
4787
|
+
var error2 = {
|
|
4788
4788
|
message: ({ params: { missingProperty } }) => (0, codegen_1.str)`must have required property '${missingProperty}'`,
|
|
4789
4789
|
params: ({ params: { missingProperty } }) => (0, codegen_1._)`{missingProperty: ${missingProperty}}`
|
|
4790
4790
|
};
|
|
@@ -4793,7 +4793,7 @@ var require_required = __commonJS({
|
|
|
4793
4793
|
type: "object",
|
|
4794
4794
|
schemaType: "array",
|
|
4795
4795
|
$data: true,
|
|
4796
|
-
error,
|
|
4796
|
+
error: error2,
|
|
4797
4797
|
code(cxt) {
|
|
4798
4798
|
const { gen, schema, schemaCode, data, $data, it } = cxt;
|
|
4799
4799
|
const { opts } = it;
|
|
@@ -4864,7 +4864,7 @@ var require_limitItems = __commonJS({
|
|
|
4864
4864
|
"use strict";
|
|
4865
4865
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4866
4866
|
var codegen_1 = require_codegen();
|
|
4867
|
-
var
|
|
4867
|
+
var error2 = {
|
|
4868
4868
|
message({ keyword, schemaCode }) {
|
|
4869
4869
|
const comp = keyword === "maxItems" ? "more" : "fewer";
|
|
4870
4870
|
return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} items`;
|
|
@@ -4876,7 +4876,7 @@ var require_limitItems = __commonJS({
|
|
|
4876
4876
|
type: "array",
|
|
4877
4877
|
schemaType: "number",
|
|
4878
4878
|
$data: true,
|
|
4879
|
-
error,
|
|
4879
|
+
error: error2,
|
|
4880
4880
|
code(cxt) {
|
|
4881
4881
|
const { keyword, data, schemaCode } = cxt;
|
|
4882
4882
|
const op = keyword === "maxItems" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
|
@@ -4907,7 +4907,7 @@ var require_uniqueItems = __commonJS({
|
|
|
4907
4907
|
var codegen_1 = require_codegen();
|
|
4908
4908
|
var util_1 = require_util();
|
|
4909
4909
|
var equal_1 = require_equal();
|
|
4910
|
-
var
|
|
4910
|
+
var error2 = {
|
|
4911
4911
|
message: ({ params: { i, j } }) => (0, codegen_1.str)`must NOT have duplicate items (items ## ${j} and ${i} are identical)`,
|
|
4912
4912
|
params: ({ params: { i, j } }) => (0, codegen_1._)`{i: ${i}, j: ${j}}`
|
|
4913
4913
|
};
|
|
@@ -4916,7 +4916,7 @@ var require_uniqueItems = __commonJS({
|
|
|
4916
4916
|
type: "array",
|
|
4917
4917
|
schemaType: "boolean",
|
|
4918
4918
|
$data: true,
|
|
4919
|
-
error,
|
|
4919
|
+
error: error2,
|
|
4920
4920
|
code(cxt) {
|
|
4921
4921
|
const { gen, data, $data, schema, parentSchema, schemaCode, it } = cxt;
|
|
4922
4922
|
if (!$data && !schema)
|
|
@@ -4973,14 +4973,14 @@ var require_const = __commonJS({
|
|
|
4973
4973
|
var codegen_1 = require_codegen();
|
|
4974
4974
|
var util_1 = require_util();
|
|
4975
4975
|
var equal_1 = require_equal();
|
|
4976
|
-
var
|
|
4976
|
+
var error2 = {
|
|
4977
4977
|
message: "must be equal to constant",
|
|
4978
4978
|
params: ({ schemaCode }) => (0, codegen_1._)`{allowedValue: ${schemaCode}}`
|
|
4979
4979
|
};
|
|
4980
4980
|
var def = {
|
|
4981
4981
|
keyword: "const",
|
|
4982
4982
|
$data: true,
|
|
4983
|
-
error,
|
|
4983
|
+
error: error2,
|
|
4984
4984
|
code(cxt) {
|
|
4985
4985
|
const { gen, data, $data, schemaCode, schema } = cxt;
|
|
4986
4986
|
if ($data || schema && typeof schema == "object") {
|
|
@@ -5002,7 +5002,7 @@ var require_enum = __commonJS({
|
|
|
5002
5002
|
var codegen_1 = require_codegen();
|
|
5003
5003
|
var util_1 = require_util();
|
|
5004
5004
|
var equal_1 = require_equal();
|
|
5005
|
-
var
|
|
5005
|
+
var error2 = {
|
|
5006
5006
|
message: "must be equal to one of the allowed values",
|
|
5007
5007
|
params: ({ schemaCode }) => (0, codegen_1._)`{allowedValues: ${schemaCode}}`
|
|
5008
5008
|
};
|
|
@@ -5010,7 +5010,7 @@ var require_enum = __commonJS({
|
|
|
5010
5010
|
keyword: "enum",
|
|
5011
5011
|
schemaType: "array",
|
|
5012
5012
|
$data: true,
|
|
5013
|
-
error,
|
|
5013
|
+
error: error2,
|
|
5014
5014
|
code(cxt) {
|
|
5015
5015
|
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
5016
5016
|
if (!$data && schema.length === 0)
|
|
@@ -5089,7 +5089,7 @@ var require_additionalItems = __commonJS({
|
|
|
5089
5089
|
exports.validateAdditionalItems = void 0;
|
|
5090
5090
|
var codegen_1 = require_codegen();
|
|
5091
5091
|
var util_1 = require_util();
|
|
5092
|
-
var
|
|
5092
|
+
var error2 = {
|
|
5093
5093
|
message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
|
|
5094
5094
|
params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
|
|
5095
5095
|
};
|
|
@@ -5098,7 +5098,7 @@ var require_additionalItems = __commonJS({
|
|
|
5098
5098
|
type: "array",
|
|
5099
5099
|
schemaType: ["boolean", "object"],
|
|
5100
5100
|
before: "uniqueItems",
|
|
5101
|
-
error,
|
|
5101
|
+
error: error2,
|
|
5102
5102
|
code(cxt) {
|
|
5103
5103
|
const { parentSchema, it } = cxt;
|
|
5104
5104
|
const { items } = parentSchema;
|
|
@@ -5217,7 +5217,7 @@ var require_items2020 = __commonJS({
|
|
|
5217
5217
|
var util_1 = require_util();
|
|
5218
5218
|
var code_1 = require_code2();
|
|
5219
5219
|
var additionalItems_1 = require_additionalItems();
|
|
5220
|
-
var
|
|
5220
|
+
var error2 = {
|
|
5221
5221
|
message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
|
|
5222
5222
|
params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
|
|
5223
5223
|
};
|
|
@@ -5226,7 +5226,7 @@ var require_items2020 = __commonJS({
|
|
|
5226
5226
|
type: "array",
|
|
5227
5227
|
schemaType: ["object", "boolean"],
|
|
5228
5228
|
before: "uniqueItems",
|
|
5229
|
-
error,
|
|
5229
|
+
error: error2,
|
|
5230
5230
|
code(cxt) {
|
|
5231
5231
|
const { schema, parentSchema, it } = cxt;
|
|
5232
5232
|
const { prefixItems } = parentSchema;
|
|
@@ -5250,7 +5250,7 @@ var require_contains = __commonJS({
|
|
|
5250
5250
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5251
5251
|
var codegen_1 = require_codegen();
|
|
5252
5252
|
var util_1 = require_util();
|
|
5253
|
-
var
|
|
5253
|
+
var error2 = {
|
|
5254
5254
|
message: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1.str)`must contain at least ${min} valid item(s)` : (0, codegen_1.str)`must contain at least ${min} and no more than ${max} valid item(s)`,
|
|
5255
5255
|
params: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1._)`{minContains: ${min}}` : (0, codegen_1._)`{minContains: ${min}, maxContains: ${max}}`
|
|
5256
5256
|
};
|
|
@@ -5260,7 +5260,7 @@ var require_contains = __commonJS({
|
|
|
5260
5260
|
schemaType: ["object", "boolean"],
|
|
5261
5261
|
before: "uniqueItems",
|
|
5262
5262
|
trackErrors: true,
|
|
5263
|
-
error,
|
|
5263
|
+
error: error2,
|
|
5264
5264
|
code(cxt) {
|
|
5265
5265
|
const { gen, schema, parentSchema, data, it } = cxt;
|
|
5266
5266
|
let min;
|
|
@@ -5438,7 +5438,7 @@ var require_propertyNames = __commonJS({
|
|
|
5438
5438
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5439
5439
|
var codegen_1 = require_codegen();
|
|
5440
5440
|
var util_1 = require_util();
|
|
5441
|
-
var
|
|
5441
|
+
var error2 = {
|
|
5442
5442
|
message: "property name must be valid",
|
|
5443
5443
|
params: ({ params }) => (0, codegen_1._)`{propertyName: ${params.propertyName}}`
|
|
5444
5444
|
};
|
|
@@ -5446,7 +5446,7 @@ var require_propertyNames = __commonJS({
|
|
|
5446
5446
|
keyword: "propertyNames",
|
|
5447
5447
|
type: "object",
|
|
5448
5448
|
schemaType: ["object", "boolean"],
|
|
5449
|
-
error,
|
|
5449
|
+
error: error2,
|
|
5450
5450
|
code(cxt) {
|
|
5451
5451
|
const { gen, schema, data, it } = cxt;
|
|
5452
5452
|
if ((0, util_1.alwaysValidSchema)(it, schema))
|
|
@@ -5483,7 +5483,7 @@ var require_additionalProperties = __commonJS({
|
|
|
5483
5483
|
var codegen_1 = require_codegen();
|
|
5484
5484
|
var names_1 = require_names();
|
|
5485
5485
|
var util_1 = require_util();
|
|
5486
|
-
var
|
|
5486
|
+
var error2 = {
|
|
5487
5487
|
message: "must NOT have additional properties",
|
|
5488
5488
|
params: ({ params }) => (0, codegen_1._)`{additionalProperty: ${params.additionalProperty}}`
|
|
5489
5489
|
};
|
|
@@ -5493,7 +5493,7 @@ var require_additionalProperties = __commonJS({
|
|
|
5493
5493
|
schemaType: ["boolean", "object"],
|
|
5494
5494
|
allowUndefined: true,
|
|
5495
5495
|
trackErrors: true,
|
|
5496
|
-
error,
|
|
5496
|
+
error: error2,
|
|
5497
5497
|
code(cxt) {
|
|
5498
5498
|
const { gen, schema, parentSchema, data, errsCount, it } = cxt;
|
|
5499
5499
|
if (!errsCount)
|
|
@@ -5767,7 +5767,7 @@ var require_oneOf = __commonJS({
|
|
|
5767
5767
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5768
5768
|
var codegen_1 = require_codegen();
|
|
5769
5769
|
var util_1 = require_util();
|
|
5770
|
-
var
|
|
5770
|
+
var error2 = {
|
|
5771
5771
|
message: "must match exactly one schema in oneOf",
|
|
5772
5772
|
params: ({ params }) => (0, codegen_1._)`{passingSchemas: ${params.passing}}`
|
|
5773
5773
|
};
|
|
@@ -5775,7 +5775,7 @@ var require_oneOf = __commonJS({
|
|
|
5775
5775
|
keyword: "oneOf",
|
|
5776
5776
|
schemaType: "array",
|
|
5777
5777
|
trackErrors: true,
|
|
5778
|
-
error,
|
|
5778
|
+
error: error2,
|
|
5779
5779
|
code(cxt) {
|
|
5780
5780
|
const { gen, schema, parentSchema, it } = cxt;
|
|
5781
5781
|
if (!Array.isArray(schema))
|
|
@@ -5852,7 +5852,7 @@ var require_if = __commonJS({
|
|
|
5852
5852
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5853
5853
|
var codegen_1 = require_codegen();
|
|
5854
5854
|
var util_1 = require_util();
|
|
5855
|
-
var
|
|
5855
|
+
var error2 = {
|
|
5856
5856
|
message: ({ params }) => (0, codegen_1.str)`must match "${params.ifClause}" schema`,
|
|
5857
5857
|
params: ({ params }) => (0, codegen_1._)`{failingKeyword: ${params.ifClause}}`
|
|
5858
5858
|
};
|
|
@@ -5860,7 +5860,7 @@ var require_if = __commonJS({
|
|
|
5860
5860
|
keyword: "if",
|
|
5861
5861
|
schemaType: ["object", "boolean"],
|
|
5862
5862
|
trackErrors: true,
|
|
5863
|
-
error,
|
|
5863
|
+
error: error2,
|
|
5864
5864
|
code(cxt) {
|
|
5865
5865
|
const { gen, parentSchema, it } = cxt;
|
|
5866
5866
|
if (parentSchema.then === void 0 && parentSchema.else === void 0) {
|
|
@@ -5986,7 +5986,7 @@ var require_format = __commonJS({
|
|
|
5986
5986
|
"use strict";
|
|
5987
5987
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5988
5988
|
var codegen_1 = require_codegen();
|
|
5989
|
-
var
|
|
5989
|
+
var error2 = {
|
|
5990
5990
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match format "${schemaCode}"`,
|
|
5991
5991
|
params: ({ schemaCode }) => (0, codegen_1._)`{format: ${schemaCode}}`
|
|
5992
5992
|
};
|
|
@@ -5995,7 +5995,7 @@ var require_format = __commonJS({
|
|
|
5995
5995
|
type: ["number", "string"],
|
|
5996
5996
|
schemaType: "string",
|
|
5997
5997
|
$data: true,
|
|
5998
|
-
error,
|
|
5998
|
+
error: error2,
|
|
5999
5999
|
code(cxt, ruleType) {
|
|
6000
6000
|
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
6001
6001
|
const { opts, errSchemaPath, schemaEnv, self } = it;
|
|
@@ -6150,7 +6150,7 @@ var require_discriminator = __commonJS({
|
|
|
6150
6150
|
var compile_1 = require_compile();
|
|
6151
6151
|
var ref_error_1 = require_ref_error();
|
|
6152
6152
|
var util_1 = require_util();
|
|
6153
|
-
var
|
|
6153
|
+
var error2 = {
|
|
6154
6154
|
message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag ? `tag "${tagName}" must be string` : `value of tag "${tagName}" must be in oneOf`,
|
|
6155
6155
|
params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._)`{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`
|
|
6156
6156
|
};
|
|
@@ -6158,7 +6158,7 @@ var require_discriminator = __commonJS({
|
|
|
6158
6158
|
keyword: "discriminator",
|
|
6159
6159
|
type: "object",
|
|
6160
6160
|
schemaType: "object",
|
|
6161
|
-
error,
|
|
6161
|
+
error: error2,
|
|
6162
6162
|
code(cxt) {
|
|
6163
6163
|
const { gen, data, schema, parentSchema, it } = cxt;
|
|
6164
6164
|
const { oneOf } = parentSchema;
|
|
@@ -7115,9 +7115,9 @@ var require_codegen2 = __commonJS({
|
|
|
7115
7115
|
}
|
|
7116
7116
|
};
|
|
7117
7117
|
var Throw = class extends Node {
|
|
7118
|
-
constructor(
|
|
7118
|
+
constructor(error2) {
|
|
7119
7119
|
super();
|
|
7120
|
-
this.error =
|
|
7120
|
+
this.error = error2;
|
|
7121
7121
|
}
|
|
7122
7122
|
render({ _n }) {
|
|
7123
7123
|
return `throw ${this.error};` + _n;
|
|
@@ -7354,9 +7354,9 @@ var require_codegen2 = __commonJS({
|
|
|
7354
7354
|
}
|
|
7355
7355
|
};
|
|
7356
7356
|
var Catch = class extends BlockNode {
|
|
7357
|
-
constructor(
|
|
7357
|
+
constructor(error2) {
|
|
7358
7358
|
super();
|
|
7359
|
-
this.error =
|
|
7359
|
+
this.error = error2;
|
|
7360
7360
|
}
|
|
7361
7361
|
render(opts) {
|
|
7362
7362
|
return `catch(${this.error})` + super.render(opts);
|
|
@@ -7547,9 +7547,9 @@ var require_codegen2 = __commonJS({
|
|
|
7547
7547
|
this._blockNode(node);
|
|
7548
7548
|
this.code(tryBody);
|
|
7549
7549
|
if (catchCode) {
|
|
7550
|
-
const
|
|
7551
|
-
this._currNode = node.catch = new Catch(
|
|
7552
|
-
catchCode(
|
|
7550
|
+
const error2 = this.name("e");
|
|
7551
|
+
this._currNode = node.catch = new Catch(error2);
|
|
7552
|
+
catchCode(error2);
|
|
7553
7553
|
}
|
|
7554
7554
|
if (finallyCode) {
|
|
7555
7555
|
this._currNode = node.finally = new Finally();
|
|
@@ -7558,8 +7558,8 @@ var require_codegen2 = __commonJS({
|
|
|
7558
7558
|
return this._endBlockNode(Catch, Finally);
|
|
7559
7559
|
}
|
|
7560
7560
|
// `throw` statement
|
|
7561
|
-
throw(
|
|
7562
|
-
return this._leafNode(new Throw(
|
|
7561
|
+
throw(error2) {
|
|
7562
|
+
return this._leafNode(new Throw(error2));
|
|
7563
7563
|
}
|
|
7564
7564
|
// start self-balancing block
|
|
7565
7565
|
block(body, nodeCount) {
|
|
@@ -7915,10 +7915,10 @@ var require_errors2 = __commonJS({
|
|
|
7915
7915
|
exports.keyword$DataError = {
|
|
7916
7916
|
message: ({ keyword, schemaType }) => schemaType ? (0, codegen_1.str)`"${keyword}" keyword must be ${schemaType} ($data)` : (0, codegen_1.str)`"${keyword}" keyword is invalid ($data)`
|
|
7917
7917
|
};
|
|
7918
|
-
function reportError(cxt,
|
|
7918
|
+
function reportError(cxt, error2 = exports.keywordError, errorPaths, overrideAllErrors) {
|
|
7919
7919
|
const { it } = cxt;
|
|
7920
7920
|
const { gen, compositeRule, allErrors } = it;
|
|
7921
|
-
const errObj = errorObjectCode(cxt,
|
|
7921
|
+
const errObj = errorObjectCode(cxt, error2, errorPaths);
|
|
7922
7922
|
if (overrideAllErrors !== null && overrideAllErrors !== void 0 ? overrideAllErrors : compositeRule || allErrors) {
|
|
7923
7923
|
addError(gen, errObj);
|
|
7924
7924
|
} else {
|
|
@@ -7926,10 +7926,10 @@ var require_errors2 = __commonJS({
|
|
|
7926
7926
|
}
|
|
7927
7927
|
}
|
|
7928
7928
|
exports.reportError = reportError;
|
|
7929
|
-
function reportExtraError(cxt,
|
|
7929
|
+
function reportExtraError(cxt, error2 = exports.keywordError, errorPaths) {
|
|
7930
7930
|
const { it } = cxt;
|
|
7931
7931
|
const { gen, compositeRule, allErrors } = it;
|
|
7932
|
-
const errObj = errorObjectCode(cxt,
|
|
7932
|
+
const errObj = errorObjectCode(cxt, error2, errorPaths);
|
|
7933
7933
|
addError(gen, errObj);
|
|
7934
7934
|
if (!(compositeRule || allErrors)) {
|
|
7935
7935
|
returnErrors(it, names_1.default.vErrors);
|
|
@@ -7980,19 +7980,19 @@ var require_errors2 = __commonJS({
|
|
|
7980
7980
|
schema: new codegen_1.Name("schema"),
|
|
7981
7981
|
parentSchema: new codegen_1.Name("parentSchema")
|
|
7982
7982
|
};
|
|
7983
|
-
function errorObjectCode(cxt,
|
|
7983
|
+
function errorObjectCode(cxt, error2, errorPaths) {
|
|
7984
7984
|
const { createErrors } = cxt.it;
|
|
7985
7985
|
if (createErrors === false)
|
|
7986
7986
|
return (0, codegen_1._)`{}`;
|
|
7987
|
-
return errorObject(cxt,
|
|
7987
|
+
return errorObject(cxt, error2, errorPaths);
|
|
7988
7988
|
}
|
|
7989
|
-
function errorObject(cxt,
|
|
7989
|
+
function errorObject(cxt, error2, errorPaths = {}) {
|
|
7990
7990
|
const { gen, it } = cxt;
|
|
7991
7991
|
const keyValues = [
|
|
7992
7992
|
errorInstancePath(it, errorPaths),
|
|
7993
7993
|
errorSchemaPath(cxt, errorPaths)
|
|
7994
7994
|
];
|
|
7995
|
-
extraErrorProps(cxt,
|
|
7995
|
+
extraErrorProps(cxt, error2, keyValues);
|
|
7996
7996
|
return gen.object(...keyValues);
|
|
7997
7997
|
}
|
|
7998
7998
|
function errorInstancePath({ errorPath }, { instancePath }) {
|
|
@@ -10503,7 +10503,7 @@ var require_limitNumber2 = __commonJS({
|
|
|
10503
10503
|
exclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE },
|
|
10504
10504
|
exclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE }
|
|
10505
10505
|
};
|
|
10506
|
-
var
|
|
10506
|
+
var error2 = {
|
|
10507
10507
|
message: ({ keyword, schemaCode }) => (0, codegen_1.str)`must be ${KWDs[keyword].okStr} ${schemaCode}`,
|
|
10508
10508
|
params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
|
|
10509
10509
|
};
|
|
@@ -10512,7 +10512,7 @@ var require_limitNumber2 = __commonJS({
|
|
|
10512
10512
|
type: "number",
|
|
10513
10513
|
schemaType: "number",
|
|
10514
10514
|
$data: true,
|
|
10515
|
-
error,
|
|
10515
|
+
error: error2,
|
|
10516
10516
|
code(cxt) {
|
|
10517
10517
|
const { keyword, data, schemaCode } = cxt;
|
|
10518
10518
|
cxt.fail$data((0, codegen_1._)`${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`);
|
|
@@ -10528,7 +10528,7 @@ var require_multipleOf2 = __commonJS({
|
|
|
10528
10528
|
"use strict";
|
|
10529
10529
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10530
10530
|
var codegen_1 = require_codegen2();
|
|
10531
|
-
var
|
|
10531
|
+
var error2 = {
|
|
10532
10532
|
message: ({ schemaCode }) => (0, codegen_1.str)`must be multiple of ${schemaCode}`,
|
|
10533
10533
|
params: ({ schemaCode }) => (0, codegen_1._)`{multipleOf: ${schemaCode}}`
|
|
10534
10534
|
};
|
|
@@ -10537,7 +10537,7 @@ var require_multipleOf2 = __commonJS({
|
|
|
10537
10537
|
type: "number",
|
|
10538
10538
|
schemaType: "number",
|
|
10539
10539
|
$data: true,
|
|
10540
|
-
error,
|
|
10540
|
+
error: error2,
|
|
10541
10541
|
code(cxt) {
|
|
10542
10542
|
const { gen, data, schemaCode, it } = cxt;
|
|
10543
10543
|
const prec = it.opts.multipleOfPrecision;
|
|
@@ -10584,7 +10584,7 @@ var require_limitLength2 = __commonJS({
|
|
|
10584
10584
|
var codegen_1 = require_codegen2();
|
|
10585
10585
|
var util_1 = require_util2();
|
|
10586
10586
|
var ucs2length_1 = require_ucs2length2();
|
|
10587
|
-
var
|
|
10587
|
+
var error2 = {
|
|
10588
10588
|
message({ keyword, schemaCode }) {
|
|
10589
10589
|
const comp = keyword === "maxLength" ? "more" : "fewer";
|
|
10590
10590
|
return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} characters`;
|
|
@@ -10596,7 +10596,7 @@ var require_limitLength2 = __commonJS({
|
|
|
10596
10596
|
type: "string",
|
|
10597
10597
|
schemaType: "number",
|
|
10598
10598
|
$data: true,
|
|
10599
|
-
error,
|
|
10599
|
+
error: error2,
|
|
10600
10600
|
code(cxt) {
|
|
10601
10601
|
const { keyword, data, schemaCode, it } = cxt;
|
|
10602
10602
|
const op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
|
@@ -10615,7 +10615,7 @@ var require_pattern2 = __commonJS({
|
|
|
10615
10615
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10616
10616
|
var code_1 = require_code4();
|
|
10617
10617
|
var codegen_1 = require_codegen2();
|
|
10618
|
-
var
|
|
10618
|
+
var error2 = {
|
|
10619
10619
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
|
|
10620
10620
|
params: ({ schemaCode }) => (0, codegen_1._)`{pattern: ${schemaCode}}`
|
|
10621
10621
|
};
|
|
@@ -10624,7 +10624,7 @@ var require_pattern2 = __commonJS({
|
|
|
10624
10624
|
type: "string",
|
|
10625
10625
|
schemaType: "string",
|
|
10626
10626
|
$data: true,
|
|
10627
|
-
error,
|
|
10627
|
+
error: error2,
|
|
10628
10628
|
code(cxt) {
|
|
10629
10629
|
const { data, $data, schema, schemaCode, it } = cxt;
|
|
10630
10630
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
@@ -10642,7 +10642,7 @@ var require_limitProperties2 = __commonJS({
|
|
|
10642
10642
|
"use strict";
|
|
10643
10643
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10644
10644
|
var codegen_1 = require_codegen2();
|
|
10645
|
-
var
|
|
10645
|
+
var error2 = {
|
|
10646
10646
|
message({ keyword, schemaCode }) {
|
|
10647
10647
|
const comp = keyword === "maxProperties" ? "more" : "fewer";
|
|
10648
10648
|
return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} properties`;
|
|
@@ -10654,7 +10654,7 @@ var require_limitProperties2 = __commonJS({
|
|
|
10654
10654
|
type: "object",
|
|
10655
10655
|
schemaType: "number",
|
|
10656
10656
|
$data: true,
|
|
10657
|
-
error,
|
|
10657
|
+
error: error2,
|
|
10658
10658
|
code(cxt) {
|
|
10659
10659
|
const { keyword, data, schemaCode } = cxt;
|
|
10660
10660
|
const op = keyword === "maxProperties" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
|
@@ -10673,7 +10673,7 @@ var require_required2 = __commonJS({
|
|
|
10673
10673
|
var code_1 = require_code4();
|
|
10674
10674
|
var codegen_1 = require_codegen2();
|
|
10675
10675
|
var util_1 = require_util2();
|
|
10676
|
-
var
|
|
10676
|
+
var error2 = {
|
|
10677
10677
|
message: ({ params: { missingProperty } }) => (0, codegen_1.str)`must have required property '${missingProperty}'`,
|
|
10678
10678
|
params: ({ params: { missingProperty } }) => (0, codegen_1._)`{missingProperty: ${missingProperty}}`
|
|
10679
10679
|
};
|
|
@@ -10682,7 +10682,7 @@ var require_required2 = __commonJS({
|
|
|
10682
10682
|
type: "object",
|
|
10683
10683
|
schemaType: "array",
|
|
10684
10684
|
$data: true,
|
|
10685
|
-
error,
|
|
10685
|
+
error: error2,
|
|
10686
10686
|
code(cxt) {
|
|
10687
10687
|
const { gen, schema, schemaCode, data, $data, it } = cxt;
|
|
10688
10688
|
const { opts } = it;
|
|
@@ -10753,7 +10753,7 @@ var require_limitItems2 = __commonJS({
|
|
|
10753
10753
|
"use strict";
|
|
10754
10754
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10755
10755
|
var codegen_1 = require_codegen2();
|
|
10756
|
-
var
|
|
10756
|
+
var error2 = {
|
|
10757
10757
|
message({ keyword, schemaCode }) {
|
|
10758
10758
|
const comp = keyword === "maxItems" ? "more" : "fewer";
|
|
10759
10759
|
return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} items`;
|
|
@@ -10765,7 +10765,7 @@ var require_limitItems2 = __commonJS({
|
|
|
10765
10765
|
type: "array",
|
|
10766
10766
|
schemaType: "number",
|
|
10767
10767
|
$data: true,
|
|
10768
|
-
error,
|
|
10768
|
+
error: error2,
|
|
10769
10769
|
code(cxt) {
|
|
10770
10770
|
const { keyword, data, schemaCode } = cxt;
|
|
10771
10771
|
const op = keyword === "maxItems" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
|
@@ -10796,7 +10796,7 @@ var require_uniqueItems2 = __commonJS({
|
|
|
10796
10796
|
var codegen_1 = require_codegen2();
|
|
10797
10797
|
var util_1 = require_util2();
|
|
10798
10798
|
var equal_1 = require_equal2();
|
|
10799
|
-
var
|
|
10799
|
+
var error2 = {
|
|
10800
10800
|
message: ({ params: { i, j } }) => (0, codegen_1.str)`must NOT have duplicate items (items ## ${j} and ${i} are identical)`,
|
|
10801
10801
|
params: ({ params: { i, j } }) => (0, codegen_1._)`{i: ${i}, j: ${j}}`
|
|
10802
10802
|
};
|
|
@@ -10805,7 +10805,7 @@ var require_uniqueItems2 = __commonJS({
|
|
|
10805
10805
|
type: "array",
|
|
10806
10806
|
schemaType: "boolean",
|
|
10807
10807
|
$data: true,
|
|
10808
|
-
error,
|
|
10808
|
+
error: error2,
|
|
10809
10809
|
code(cxt) {
|
|
10810
10810
|
const { gen, data, $data, schema, parentSchema, schemaCode, it } = cxt;
|
|
10811
10811
|
if (!$data && !schema)
|
|
@@ -10862,14 +10862,14 @@ var require_const2 = __commonJS({
|
|
|
10862
10862
|
var codegen_1 = require_codegen2();
|
|
10863
10863
|
var util_1 = require_util2();
|
|
10864
10864
|
var equal_1 = require_equal2();
|
|
10865
|
-
var
|
|
10865
|
+
var error2 = {
|
|
10866
10866
|
message: "must be equal to constant",
|
|
10867
10867
|
params: ({ schemaCode }) => (0, codegen_1._)`{allowedValue: ${schemaCode}}`
|
|
10868
10868
|
};
|
|
10869
10869
|
var def = {
|
|
10870
10870
|
keyword: "const",
|
|
10871
10871
|
$data: true,
|
|
10872
|
-
error,
|
|
10872
|
+
error: error2,
|
|
10873
10873
|
code(cxt) {
|
|
10874
10874
|
const { gen, data, $data, schemaCode, schema } = cxt;
|
|
10875
10875
|
if ($data || schema && typeof schema == "object") {
|
|
@@ -10891,7 +10891,7 @@ var require_enum2 = __commonJS({
|
|
|
10891
10891
|
var codegen_1 = require_codegen2();
|
|
10892
10892
|
var util_1 = require_util2();
|
|
10893
10893
|
var equal_1 = require_equal2();
|
|
10894
|
-
var
|
|
10894
|
+
var error2 = {
|
|
10895
10895
|
message: "must be equal to one of the allowed values",
|
|
10896
10896
|
params: ({ schemaCode }) => (0, codegen_1._)`{allowedValues: ${schemaCode}}`
|
|
10897
10897
|
};
|
|
@@ -10899,7 +10899,7 @@ var require_enum2 = __commonJS({
|
|
|
10899
10899
|
keyword: "enum",
|
|
10900
10900
|
schemaType: "array",
|
|
10901
10901
|
$data: true,
|
|
10902
|
-
error,
|
|
10902
|
+
error: error2,
|
|
10903
10903
|
code(cxt) {
|
|
10904
10904
|
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
10905
10905
|
if (!$data && schema.length === 0)
|
|
@@ -10978,7 +10978,7 @@ var require_additionalItems2 = __commonJS({
|
|
|
10978
10978
|
exports.validateAdditionalItems = void 0;
|
|
10979
10979
|
var codegen_1 = require_codegen2();
|
|
10980
10980
|
var util_1 = require_util2();
|
|
10981
|
-
var
|
|
10981
|
+
var error2 = {
|
|
10982
10982
|
message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
|
|
10983
10983
|
params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
|
|
10984
10984
|
};
|
|
@@ -10987,7 +10987,7 @@ var require_additionalItems2 = __commonJS({
|
|
|
10987
10987
|
type: "array",
|
|
10988
10988
|
schemaType: ["boolean", "object"],
|
|
10989
10989
|
before: "uniqueItems",
|
|
10990
|
-
error,
|
|
10990
|
+
error: error2,
|
|
10991
10991
|
code(cxt) {
|
|
10992
10992
|
const { parentSchema, it } = cxt;
|
|
10993
10993
|
const { items } = parentSchema;
|
|
@@ -11106,7 +11106,7 @@ var require_items20202 = __commonJS({
|
|
|
11106
11106
|
var util_1 = require_util2();
|
|
11107
11107
|
var code_1 = require_code4();
|
|
11108
11108
|
var additionalItems_1 = require_additionalItems2();
|
|
11109
|
-
var
|
|
11109
|
+
var error2 = {
|
|
11110
11110
|
message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
|
|
11111
11111
|
params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
|
|
11112
11112
|
};
|
|
@@ -11115,7 +11115,7 @@ var require_items20202 = __commonJS({
|
|
|
11115
11115
|
type: "array",
|
|
11116
11116
|
schemaType: ["object", "boolean"],
|
|
11117
11117
|
before: "uniqueItems",
|
|
11118
|
-
error,
|
|
11118
|
+
error: error2,
|
|
11119
11119
|
code(cxt) {
|
|
11120
11120
|
const { schema, parentSchema, it } = cxt;
|
|
11121
11121
|
const { prefixItems } = parentSchema;
|
|
@@ -11139,7 +11139,7 @@ var require_contains2 = __commonJS({
|
|
|
11139
11139
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11140
11140
|
var codegen_1 = require_codegen2();
|
|
11141
11141
|
var util_1 = require_util2();
|
|
11142
|
-
var
|
|
11142
|
+
var error2 = {
|
|
11143
11143
|
message: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1.str)`must contain at least ${min} valid item(s)` : (0, codegen_1.str)`must contain at least ${min} and no more than ${max} valid item(s)`,
|
|
11144
11144
|
params: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1._)`{minContains: ${min}}` : (0, codegen_1._)`{minContains: ${min}, maxContains: ${max}}`
|
|
11145
11145
|
};
|
|
@@ -11149,7 +11149,7 @@ var require_contains2 = __commonJS({
|
|
|
11149
11149
|
schemaType: ["object", "boolean"],
|
|
11150
11150
|
before: "uniqueItems",
|
|
11151
11151
|
trackErrors: true,
|
|
11152
|
-
error,
|
|
11152
|
+
error: error2,
|
|
11153
11153
|
code(cxt) {
|
|
11154
11154
|
const { gen, schema, parentSchema, data, it } = cxt;
|
|
11155
11155
|
let min;
|
|
@@ -11327,7 +11327,7 @@ var require_propertyNames2 = __commonJS({
|
|
|
11327
11327
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11328
11328
|
var codegen_1 = require_codegen2();
|
|
11329
11329
|
var util_1 = require_util2();
|
|
11330
|
-
var
|
|
11330
|
+
var error2 = {
|
|
11331
11331
|
message: "property name must be valid",
|
|
11332
11332
|
params: ({ params }) => (0, codegen_1._)`{propertyName: ${params.propertyName}}`
|
|
11333
11333
|
};
|
|
@@ -11335,7 +11335,7 @@ var require_propertyNames2 = __commonJS({
|
|
|
11335
11335
|
keyword: "propertyNames",
|
|
11336
11336
|
type: "object",
|
|
11337
11337
|
schemaType: ["object", "boolean"],
|
|
11338
|
-
error,
|
|
11338
|
+
error: error2,
|
|
11339
11339
|
code(cxt) {
|
|
11340
11340
|
const { gen, schema, data, it } = cxt;
|
|
11341
11341
|
if ((0, util_1.alwaysValidSchema)(it, schema))
|
|
@@ -11372,7 +11372,7 @@ var require_additionalProperties2 = __commonJS({
|
|
|
11372
11372
|
var codegen_1 = require_codegen2();
|
|
11373
11373
|
var names_1 = require_names2();
|
|
11374
11374
|
var util_1 = require_util2();
|
|
11375
|
-
var
|
|
11375
|
+
var error2 = {
|
|
11376
11376
|
message: "must NOT have additional properties",
|
|
11377
11377
|
params: ({ params }) => (0, codegen_1._)`{additionalProperty: ${params.additionalProperty}}`
|
|
11378
11378
|
};
|
|
@@ -11382,7 +11382,7 @@ var require_additionalProperties2 = __commonJS({
|
|
|
11382
11382
|
schemaType: ["boolean", "object"],
|
|
11383
11383
|
allowUndefined: true,
|
|
11384
11384
|
trackErrors: true,
|
|
11385
|
-
error,
|
|
11385
|
+
error: error2,
|
|
11386
11386
|
code(cxt) {
|
|
11387
11387
|
const { gen, schema, parentSchema, data, errsCount, it } = cxt;
|
|
11388
11388
|
if (!errsCount)
|
|
@@ -11656,7 +11656,7 @@ var require_oneOf2 = __commonJS({
|
|
|
11656
11656
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11657
11657
|
var codegen_1 = require_codegen2();
|
|
11658
11658
|
var util_1 = require_util2();
|
|
11659
|
-
var
|
|
11659
|
+
var error2 = {
|
|
11660
11660
|
message: "must match exactly one schema in oneOf",
|
|
11661
11661
|
params: ({ params }) => (0, codegen_1._)`{passingSchemas: ${params.passing}}`
|
|
11662
11662
|
};
|
|
@@ -11664,7 +11664,7 @@ var require_oneOf2 = __commonJS({
|
|
|
11664
11664
|
keyword: "oneOf",
|
|
11665
11665
|
schemaType: "array",
|
|
11666
11666
|
trackErrors: true,
|
|
11667
|
-
error,
|
|
11667
|
+
error: error2,
|
|
11668
11668
|
code(cxt) {
|
|
11669
11669
|
const { gen, schema, parentSchema, it } = cxt;
|
|
11670
11670
|
if (!Array.isArray(schema))
|
|
@@ -11741,7 +11741,7 @@ var require_if2 = __commonJS({
|
|
|
11741
11741
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11742
11742
|
var codegen_1 = require_codegen2();
|
|
11743
11743
|
var util_1 = require_util2();
|
|
11744
|
-
var
|
|
11744
|
+
var error2 = {
|
|
11745
11745
|
message: ({ params }) => (0, codegen_1.str)`must match "${params.ifClause}" schema`,
|
|
11746
11746
|
params: ({ params }) => (0, codegen_1._)`{failingKeyword: ${params.ifClause}}`
|
|
11747
11747
|
};
|
|
@@ -11749,7 +11749,7 @@ var require_if2 = __commonJS({
|
|
|
11749
11749
|
keyword: "if",
|
|
11750
11750
|
schemaType: ["object", "boolean"],
|
|
11751
11751
|
trackErrors: true,
|
|
11752
|
-
error,
|
|
11752
|
+
error: error2,
|
|
11753
11753
|
code(cxt) {
|
|
11754
11754
|
const { gen, parentSchema, it } = cxt;
|
|
11755
11755
|
if (parentSchema.then === void 0 && parentSchema.else === void 0) {
|
|
@@ -11875,7 +11875,7 @@ var require_format3 = __commonJS({
|
|
|
11875
11875
|
"use strict";
|
|
11876
11876
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11877
11877
|
var codegen_1 = require_codegen2();
|
|
11878
|
-
var
|
|
11878
|
+
var error2 = {
|
|
11879
11879
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match format "${schemaCode}"`,
|
|
11880
11880
|
params: ({ schemaCode }) => (0, codegen_1._)`{format: ${schemaCode}}`
|
|
11881
11881
|
};
|
|
@@ -11884,7 +11884,7 @@ var require_format3 = __commonJS({
|
|
|
11884
11884
|
type: ["number", "string"],
|
|
11885
11885
|
schemaType: "string",
|
|
11886
11886
|
$data: true,
|
|
11887
|
-
error,
|
|
11887
|
+
error: error2,
|
|
11888
11888
|
code(cxt, ruleType) {
|
|
11889
11889
|
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
11890
11890
|
const { opts, errSchemaPath, schemaEnv, self } = it;
|
|
@@ -12039,7 +12039,7 @@ var require_discriminator2 = __commonJS({
|
|
|
12039
12039
|
var compile_1 = require_compile2();
|
|
12040
12040
|
var ref_error_1 = require_ref_error2();
|
|
12041
12041
|
var util_1 = require_util2();
|
|
12042
|
-
var
|
|
12042
|
+
var error2 = {
|
|
12043
12043
|
message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag ? `tag "${tagName}" must be string` : `value of tag "${tagName}" must be in oneOf`,
|
|
12044
12044
|
params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._)`{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`
|
|
12045
12045
|
};
|
|
@@ -12047,7 +12047,7 @@ var require_discriminator2 = __commonJS({
|
|
|
12047
12047
|
keyword: "discriminator",
|
|
12048
12048
|
type: "object",
|
|
12049
12049
|
schemaType: "object",
|
|
12050
|
-
error,
|
|
12050
|
+
error: error2,
|
|
12051
12051
|
code(cxt) {
|
|
12052
12052
|
const { gen, data, schema, parentSchema, it } = cxt;
|
|
12053
12053
|
const { oneOf } = parentSchema;
|
|
@@ -12376,7 +12376,7 @@ var require_limit = __commonJS({
|
|
|
12376
12376
|
formatExclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE },
|
|
12377
12377
|
formatExclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE }
|
|
12378
12378
|
};
|
|
12379
|
-
var
|
|
12379
|
+
var error2 = {
|
|
12380
12380
|
message: ({ keyword, schemaCode }) => (0, codegen_1.str)`should be ${KWDs[keyword].okStr} ${schemaCode}`,
|
|
12381
12381
|
params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
|
|
12382
12382
|
};
|
|
@@ -12385,7 +12385,7 @@ var require_limit = __commonJS({
|
|
|
12385
12385
|
type: "string",
|
|
12386
12386
|
schemaType: "string",
|
|
12387
12387
|
$data: true,
|
|
12388
|
-
error,
|
|
12388
|
+
error: error2,
|
|
12389
12389
|
code(cxt) {
|
|
12390
12390
|
const { gen, data, schemaCode, keyword, it } = cxt;
|
|
12391
12391
|
const { opts, self } = it;
|
|
@@ -12525,7 +12525,6 @@ function $constructor(name, initializer3, params) {
|
|
|
12525
12525
|
Object.defineProperty(_, "name", { value: name });
|
|
12526
12526
|
return _;
|
|
12527
12527
|
}
|
|
12528
|
-
var $brand = Symbol("zod_brand");
|
|
12529
12528
|
var $ZodAsyncError = class extends Error {
|
|
12530
12529
|
constructor() {
|
|
12531
12530
|
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
@@ -13084,10 +13083,10 @@ var initializer = (inst, def) => {
|
|
|
13084
13083
|
};
|
|
13085
13084
|
var $ZodError = $constructor("$ZodError", initializer);
|
|
13086
13085
|
var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
|
|
13087
|
-
function flattenError(
|
|
13086
|
+
function flattenError(error2, mapper = (issue2) => issue2.message) {
|
|
13088
13087
|
const fieldErrors = {};
|
|
13089
13088
|
const formErrors = [];
|
|
13090
|
-
for (const sub of
|
|
13089
|
+
for (const sub of error2.issues) {
|
|
13091
13090
|
if (sub.path.length > 0) {
|
|
13092
13091
|
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
13093
13092
|
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
@@ -13097,13 +13096,13 @@ function flattenError(error, mapper = (issue2) => issue2.message) {
|
|
|
13097
13096
|
}
|
|
13098
13097
|
return { formErrors, fieldErrors };
|
|
13099
13098
|
}
|
|
13100
|
-
function formatError(
|
|
13099
|
+
function formatError(error2, _mapper) {
|
|
13101
13100
|
const mapper = _mapper || function(issue2) {
|
|
13102
13101
|
return issue2.message;
|
|
13103
13102
|
};
|
|
13104
13103
|
const fieldErrors = { _errors: [] };
|
|
13105
|
-
const processError = (
|
|
13106
|
-
for (const issue2 of
|
|
13104
|
+
const processError = (error3) => {
|
|
13105
|
+
for (const issue2 of error3.issues) {
|
|
13107
13106
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
13108
13107
|
issue2.errors.map((issues) => processError({ issues }));
|
|
13109
13108
|
} else if (issue2.code === "invalid_key") {
|
|
@@ -13130,7 +13129,7 @@ function formatError(error, _mapper) {
|
|
|
13130
13129
|
}
|
|
13131
13130
|
}
|
|
13132
13131
|
};
|
|
13133
|
-
processError(
|
|
13132
|
+
processError(error2);
|
|
13134
13133
|
return fieldErrors;
|
|
13135
13134
|
}
|
|
13136
13135
|
|
|
@@ -13240,6 +13239,7 @@ var string = (params) => {
|
|
|
13240
13239
|
var integer = /^\d+$/;
|
|
13241
13240
|
var number = /^-?\d+(?:\.\d+)?/i;
|
|
13242
13241
|
var boolean = /true|false/i;
|
|
13242
|
+
var _null = /null/i;
|
|
13243
13243
|
var lowercase = /^[^A-Z]*$/;
|
|
13244
13244
|
var uppercase = /^[^a-z]*$/;
|
|
13245
13245
|
|
|
@@ -14104,6 +14104,23 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
|
14104
14104
|
return payload;
|
|
14105
14105
|
};
|
|
14106
14106
|
});
|
|
14107
|
+
var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
|
|
14108
|
+
$ZodType.init(inst, def);
|
|
14109
|
+
inst._zod.pattern = _null;
|
|
14110
|
+
inst._zod.values = /* @__PURE__ */ new Set([null]);
|
|
14111
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
14112
|
+
const input = payload.value;
|
|
14113
|
+
if (input === null)
|
|
14114
|
+
return payload;
|
|
14115
|
+
payload.issues.push({
|
|
14116
|
+
expected: "null",
|
|
14117
|
+
code: "invalid_type",
|
|
14118
|
+
input,
|
|
14119
|
+
inst
|
|
14120
|
+
});
|
|
14121
|
+
return payload;
|
|
14122
|
+
};
|
|
14123
|
+
});
|
|
14107
14124
|
var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
14108
14125
|
$ZodType.init(inst, def);
|
|
14109
14126
|
inst._zod.parse = (payload) => payload;
|
|
@@ -14892,9 +14909,125 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
14892
14909
|
}
|
|
14893
14910
|
}
|
|
14894
14911
|
|
|
14912
|
+
// node_modules/zod/v4/locales/en.js
|
|
14913
|
+
var parsedType = (data) => {
|
|
14914
|
+
const t = typeof data;
|
|
14915
|
+
switch (t) {
|
|
14916
|
+
case "number": {
|
|
14917
|
+
return Number.isNaN(data) ? "NaN" : "number";
|
|
14918
|
+
}
|
|
14919
|
+
case "object": {
|
|
14920
|
+
if (Array.isArray(data)) {
|
|
14921
|
+
return "array";
|
|
14922
|
+
}
|
|
14923
|
+
if (data === null) {
|
|
14924
|
+
return "null";
|
|
14925
|
+
}
|
|
14926
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
14927
|
+
return data.constructor.name;
|
|
14928
|
+
}
|
|
14929
|
+
}
|
|
14930
|
+
}
|
|
14931
|
+
return t;
|
|
14932
|
+
};
|
|
14933
|
+
var error = () => {
|
|
14934
|
+
const Sizable = {
|
|
14935
|
+
string: { unit: "characters", verb: "to have" },
|
|
14936
|
+
file: { unit: "bytes", verb: "to have" },
|
|
14937
|
+
array: { unit: "items", verb: "to have" },
|
|
14938
|
+
set: { unit: "items", verb: "to have" }
|
|
14939
|
+
};
|
|
14940
|
+
function getSizing(origin) {
|
|
14941
|
+
return Sizable[origin] ?? null;
|
|
14942
|
+
}
|
|
14943
|
+
const Nouns = {
|
|
14944
|
+
regex: "input",
|
|
14945
|
+
email: "email address",
|
|
14946
|
+
url: "URL",
|
|
14947
|
+
emoji: "emoji",
|
|
14948
|
+
uuid: "UUID",
|
|
14949
|
+
uuidv4: "UUIDv4",
|
|
14950
|
+
uuidv6: "UUIDv6",
|
|
14951
|
+
nanoid: "nanoid",
|
|
14952
|
+
guid: "GUID",
|
|
14953
|
+
cuid: "cuid",
|
|
14954
|
+
cuid2: "cuid2",
|
|
14955
|
+
ulid: "ULID",
|
|
14956
|
+
xid: "XID",
|
|
14957
|
+
ksuid: "KSUID",
|
|
14958
|
+
datetime: "ISO datetime",
|
|
14959
|
+
date: "ISO date",
|
|
14960
|
+
time: "ISO time",
|
|
14961
|
+
duration: "ISO duration",
|
|
14962
|
+
ipv4: "IPv4 address",
|
|
14963
|
+
ipv6: "IPv6 address",
|
|
14964
|
+
cidrv4: "IPv4 range",
|
|
14965
|
+
cidrv6: "IPv6 range",
|
|
14966
|
+
base64: "base64-encoded string",
|
|
14967
|
+
base64url: "base64url-encoded string",
|
|
14968
|
+
json_string: "JSON string",
|
|
14969
|
+
e164: "E.164 number",
|
|
14970
|
+
jwt: "JWT",
|
|
14971
|
+
template_literal: "input"
|
|
14972
|
+
};
|
|
14973
|
+
return (issue2) => {
|
|
14974
|
+
switch (issue2.code) {
|
|
14975
|
+
case "invalid_type":
|
|
14976
|
+
return `Invalid input: expected ${issue2.expected}, received ${parsedType(issue2.input)}`;
|
|
14977
|
+
case "invalid_value":
|
|
14978
|
+
if (issue2.values.length === 1)
|
|
14979
|
+
return `Invalid input: expected ${stringifyPrimitive(issue2.values[0])}`;
|
|
14980
|
+
return `Invalid option: expected one of ${joinValues(issue2.values, "|")}`;
|
|
14981
|
+
case "too_big": {
|
|
14982
|
+
const adj = issue2.inclusive ? "<=" : "<";
|
|
14983
|
+
const sizing = getSizing(issue2.origin);
|
|
14984
|
+
if (sizing)
|
|
14985
|
+
return `Too big: expected ${issue2.origin ?? "value"} to have ${adj}${issue2.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
14986
|
+
return `Too big: expected ${issue2.origin ?? "value"} to be ${adj}${issue2.maximum.toString()}`;
|
|
14987
|
+
}
|
|
14988
|
+
case "too_small": {
|
|
14989
|
+
const adj = issue2.inclusive ? ">=" : ">";
|
|
14990
|
+
const sizing = getSizing(issue2.origin);
|
|
14991
|
+
if (sizing) {
|
|
14992
|
+
return `Too small: expected ${issue2.origin} to have ${adj}${issue2.minimum.toString()} ${sizing.unit}`;
|
|
14993
|
+
}
|
|
14994
|
+
return `Too small: expected ${issue2.origin} to be ${adj}${issue2.minimum.toString()}`;
|
|
14995
|
+
}
|
|
14996
|
+
case "invalid_format": {
|
|
14997
|
+
const _issue = issue2;
|
|
14998
|
+
if (_issue.format === "starts_with") {
|
|
14999
|
+
return `Invalid string: must start with "${_issue.prefix}"`;
|
|
15000
|
+
}
|
|
15001
|
+
if (_issue.format === "ends_with")
|
|
15002
|
+
return `Invalid string: must end with "${_issue.suffix}"`;
|
|
15003
|
+
if (_issue.format === "includes")
|
|
15004
|
+
return `Invalid string: must include "${_issue.includes}"`;
|
|
15005
|
+
if (_issue.format === "regex")
|
|
15006
|
+
return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
15007
|
+
return `Invalid ${Nouns[_issue.format] ?? issue2.format}`;
|
|
15008
|
+
}
|
|
15009
|
+
case "not_multiple_of":
|
|
15010
|
+
return `Invalid number: must be a multiple of ${issue2.divisor}`;
|
|
15011
|
+
case "unrecognized_keys":
|
|
15012
|
+
return `Unrecognized key${issue2.keys.length > 1 ? "s" : ""}: ${joinValues(issue2.keys, ", ")}`;
|
|
15013
|
+
case "invalid_key":
|
|
15014
|
+
return `Invalid key in ${issue2.origin}`;
|
|
15015
|
+
case "invalid_union":
|
|
15016
|
+
return "Invalid input";
|
|
15017
|
+
case "invalid_element":
|
|
15018
|
+
return `Invalid value in ${issue2.origin}`;
|
|
15019
|
+
default:
|
|
15020
|
+
return `Invalid input`;
|
|
15021
|
+
}
|
|
15022
|
+
};
|
|
15023
|
+
};
|
|
15024
|
+
function en_default() {
|
|
15025
|
+
return {
|
|
15026
|
+
localeError: error()
|
|
15027
|
+
};
|
|
15028
|
+
}
|
|
15029
|
+
|
|
14895
15030
|
// node_modules/zod/v4/core/registries.js
|
|
14896
|
-
var $output = Symbol("ZodOutput");
|
|
14897
|
-
var $input = Symbol("ZodInput");
|
|
14898
15031
|
var $ZodRegistry = class {
|
|
14899
15032
|
constructor() {
|
|
14900
15033
|
this._map = /* @__PURE__ */ new Map();
|
|
@@ -15208,6 +15341,12 @@ function _boolean(Class2, params) {
|
|
|
15208
15341
|
...normalizeParams(params)
|
|
15209
15342
|
});
|
|
15210
15343
|
}
|
|
15344
|
+
function _null2(Class2, params) {
|
|
15345
|
+
return new Class2({
|
|
15346
|
+
type: "null",
|
|
15347
|
+
...normalizeParams(params)
|
|
15348
|
+
});
|
|
15349
|
+
}
|
|
15211
15350
|
function _unknown(Class2) {
|
|
15212
15351
|
return new Class2({
|
|
15213
15352
|
type: "unknown"
|
|
@@ -16143,6 +16282,17 @@ function isTransforming(_schema, _ctx) {
|
|
|
16143
16282
|
}
|
|
16144
16283
|
|
|
16145
16284
|
// node_modules/zod/v4/classic/iso.js
|
|
16285
|
+
var iso_exports = {};
|
|
16286
|
+
__export(iso_exports, {
|
|
16287
|
+
ZodISODate: () => ZodISODate,
|
|
16288
|
+
ZodISODateTime: () => ZodISODateTime,
|
|
16289
|
+
ZodISODuration: () => ZodISODuration,
|
|
16290
|
+
ZodISOTime: () => ZodISOTime,
|
|
16291
|
+
date: () => date2,
|
|
16292
|
+
datetime: () => datetime2,
|
|
16293
|
+
duration: () => duration2,
|
|
16294
|
+
time: () => time2
|
|
16295
|
+
});
|
|
16146
16296
|
var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
16147
16297
|
$ZodISODateTime.init(inst, def);
|
|
16148
16298
|
ZodStringFormat.init(inst, def);
|
|
@@ -16231,10 +16381,10 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
16231
16381
|
};
|
|
16232
16382
|
inst.clone = (def2, params) => clone(inst, def2, params);
|
|
16233
16383
|
inst.brand = () => inst;
|
|
16234
|
-
inst.register = (reg, meta) => {
|
|
16384
|
+
inst.register = ((reg, meta) => {
|
|
16235
16385
|
reg.add(inst, meta);
|
|
16236
16386
|
return inst;
|
|
16237
|
-
};
|
|
16387
|
+
});
|
|
16238
16388
|
inst.parse = (data, params) => parse2(inst, data, params, { callee: inst.parse });
|
|
16239
16389
|
inst.safeParse = (data, params) => safeParse2(inst, data, params);
|
|
16240
16390
|
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
@@ -16457,6 +16607,13 @@ var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
|
16457
16607
|
function boolean2(params) {
|
|
16458
16608
|
return _boolean(ZodBoolean, params);
|
|
16459
16609
|
}
|
|
16610
|
+
var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
16611
|
+
$ZodNull.init(inst, def);
|
|
16612
|
+
ZodType.init(inst, def);
|
|
16613
|
+
});
|
|
16614
|
+
function _null3(params) {
|
|
16615
|
+
return _null2(ZodNull, params);
|
|
16616
|
+
}
|
|
16460
16617
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
16461
16618
|
$ZodUnknown.init(inst, def);
|
|
16462
16619
|
ZodType.init(inst, def);
|
|
@@ -16816,20 +16973,47 @@ function preprocess(fn, schema) {
|
|
|
16816
16973
|
return pipe(transform(fn), schema);
|
|
16817
16974
|
}
|
|
16818
16975
|
|
|
16976
|
+
// node_modules/zod/v4/classic/external.js
|
|
16977
|
+
config(en_default());
|
|
16978
|
+
|
|
16819
16979
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
16820
|
-
var LATEST_PROTOCOL_VERSION = "2025-
|
|
16821
|
-
var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
16980
|
+
var LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
16981
|
+
var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
16982
|
+
var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
|
|
16822
16983
|
var JSONRPC_VERSION = "2.0";
|
|
16823
16984
|
var AssertObjectSchema = custom((v) => v !== null && (typeof v === "object" || typeof v === "function"));
|
|
16824
16985
|
var ProgressTokenSchema = union([string2(), number2().int()]);
|
|
16825
16986
|
var CursorSchema = string2();
|
|
16987
|
+
var TaskCreationParamsSchema = looseObject({
|
|
16988
|
+
/**
|
|
16989
|
+
* Time in milliseconds to keep task results available after completion.
|
|
16990
|
+
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
16991
|
+
*/
|
|
16992
|
+
ttl: union([number2(), _null3()]).optional(),
|
|
16993
|
+
/**
|
|
16994
|
+
* Time in milliseconds to wait between task status requests.
|
|
16995
|
+
*/
|
|
16996
|
+
pollInterval: number2().optional()
|
|
16997
|
+
});
|
|
16998
|
+
var RelatedTaskMetadataSchema = looseObject({
|
|
16999
|
+
taskId: string2()
|
|
17000
|
+
});
|
|
16826
17001
|
var RequestMetaSchema = looseObject({
|
|
16827
17002
|
/**
|
|
16828
17003
|
* If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
|
|
16829
17004
|
*/
|
|
16830
|
-
progressToken: ProgressTokenSchema.optional()
|
|
17005
|
+
progressToken: ProgressTokenSchema.optional(),
|
|
17006
|
+
/**
|
|
17007
|
+
* If specified, this request is related to the provided task.
|
|
17008
|
+
*/
|
|
17009
|
+
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
16831
17010
|
});
|
|
16832
17011
|
var BaseRequestParamsSchema = looseObject({
|
|
17012
|
+
/**
|
|
17013
|
+
* If specified, the caller is requesting that the receiver create a task to represent the request.
|
|
17014
|
+
* Task creation parameters are now at the top level instead of in _meta.
|
|
17015
|
+
*/
|
|
17016
|
+
task: TaskCreationParamsSchema.optional(),
|
|
16833
17017
|
/**
|
|
16834
17018
|
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
|
|
16835
17019
|
*/
|
|
@@ -16844,7 +17028,12 @@ var NotificationsParamsSchema = looseObject({
|
|
|
16844
17028
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
16845
17029
|
* for notes on _meta usage.
|
|
16846
17030
|
*/
|
|
16847
|
-
_meta:
|
|
17031
|
+
_meta: object({
|
|
17032
|
+
/**
|
|
17033
|
+
* If specified, this notification is related to the provided task.
|
|
17034
|
+
*/
|
|
17035
|
+
[RELATED_TASK_META_KEY]: optional(RelatedTaskMetadataSchema)
|
|
17036
|
+
}).passthrough().optional()
|
|
16848
17037
|
});
|
|
16849
17038
|
var NotificationSchema = object({
|
|
16850
17039
|
method: string2(),
|
|
@@ -16855,7 +17044,12 @@ var ResultSchema = looseObject({
|
|
|
16855
17044
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
16856
17045
|
* for notes on _meta usage.
|
|
16857
17046
|
*/
|
|
16858
|
-
_meta:
|
|
17047
|
+
_meta: looseObject({
|
|
17048
|
+
/**
|
|
17049
|
+
* If specified, this result is related to the provided task.
|
|
17050
|
+
*/
|
|
17051
|
+
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
17052
|
+
}).optional()
|
|
16859
17053
|
});
|
|
16860
17054
|
var RequestIdSchema = union([string2(), number2().int()]);
|
|
16861
17055
|
var JSONRPCRequestSchema = object({
|
|
@@ -16990,6 +17184,54 @@ var ElicitationCapabilitySchema = preprocess((value) => {
|
|
|
16990
17184
|
form: FormElicitationCapabilitySchema.optional(),
|
|
16991
17185
|
url: AssertObjectSchema.optional()
|
|
16992
17186
|
}), record(string2(), unknown()).optional()));
|
|
17187
|
+
var ClientTasksCapabilitySchema = object({
|
|
17188
|
+
/**
|
|
17189
|
+
* Present if the client supports listing tasks.
|
|
17190
|
+
*/
|
|
17191
|
+
list: optional(object({}).passthrough()),
|
|
17192
|
+
/**
|
|
17193
|
+
* Present if the client supports cancelling tasks.
|
|
17194
|
+
*/
|
|
17195
|
+
cancel: optional(object({}).passthrough()),
|
|
17196
|
+
/**
|
|
17197
|
+
* Capabilities for task creation on specific request types.
|
|
17198
|
+
*/
|
|
17199
|
+
requests: optional(object({
|
|
17200
|
+
/**
|
|
17201
|
+
* Task support for sampling requests.
|
|
17202
|
+
*/
|
|
17203
|
+
sampling: optional(object({
|
|
17204
|
+
createMessage: optional(object({}).passthrough())
|
|
17205
|
+
}).passthrough()),
|
|
17206
|
+
/**
|
|
17207
|
+
* Task support for elicitation requests.
|
|
17208
|
+
*/
|
|
17209
|
+
elicitation: optional(object({
|
|
17210
|
+
create: optional(object({}).passthrough())
|
|
17211
|
+
}).passthrough())
|
|
17212
|
+
}).passthrough())
|
|
17213
|
+
}).passthrough();
|
|
17214
|
+
var ServerTasksCapabilitySchema = object({
|
|
17215
|
+
/**
|
|
17216
|
+
* Present if the server supports listing tasks.
|
|
17217
|
+
*/
|
|
17218
|
+
list: optional(object({}).passthrough()),
|
|
17219
|
+
/**
|
|
17220
|
+
* Present if the server supports cancelling tasks.
|
|
17221
|
+
*/
|
|
17222
|
+
cancel: optional(object({}).passthrough()),
|
|
17223
|
+
/**
|
|
17224
|
+
* Capabilities for task creation on specific request types.
|
|
17225
|
+
*/
|
|
17226
|
+
requests: optional(object({
|
|
17227
|
+
/**
|
|
17228
|
+
* Task support for tool requests.
|
|
17229
|
+
*/
|
|
17230
|
+
tools: optional(object({
|
|
17231
|
+
call: optional(object({}).passthrough())
|
|
17232
|
+
}).passthrough())
|
|
17233
|
+
}).passthrough())
|
|
17234
|
+
}).passthrough();
|
|
16993
17235
|
var ClientCapabilitiesSchema = object({
|
|
16994
17236
|
/**
|
|
16995
17237
|
* Experimental, non-standard capabilities that the client supports.
|
|
@@ -17021,7 +17263,11 @@ var ClientCapabilitiesSchema = object({
|
|
|
17021
17263
|
* Whether the client supports issuing notifications for changes to the roots list.
|
|
17022
17264
|
*/
|
|
17023
17265
|
listChanged: boolean2().optional()
|
|
17024
|
-
}).optional()
|
|
17266
|
+
}).optional(),
|
|
17267
|
+
/**
|
|
17268
|
+
* Present if the client supports task creation.
|
|
17269
|
+
*/
|
|
17270
|
+
tasks: optional(ClientTasksCapabilitySchema)
|
|
17025
17271
|
});
|
|
17026
17272
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
17027
17273
|
/**
|
|
@@ -17078,8 +17324,12 @@ var ServerCapabilitiesSchema = object({
|
|
|
17078
17324
|
* Whether this server supports issuing notifications for changes to the tool list.
|
|
17079
17325
|
*/
|
|
17080
17326
|
listChanged: boolean2().optional()
|
|
17081
|
-
}).optional()
|
|
17082
|
-
|
|
17327
|
+
}).optional(),
|
|
17328
|
+
/**
|
|
17329
|
+
* Present if the server supports task creation.
|
|
17330
|
+
*/
|
|
17331
|
+
tasks: optional(ServerTasksCapabilitySchema)
|
|
17332
|
+
}).passthrough();
|
|
17083
17333
|
var InitializeResultSchema = ResultSchema.extend({
|
|
17084
17334
|
/**
|
|
17085
17335
|
* The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect.
|
|
@@ -17143,6 +17393,62 @@ var PaginatedResultSchema = ResultSchema.extend({
|
|
|
17143
17393
|
*/
|
|
17144
17394
|
nextCursor: optional(CursorSchema)
|
|
17145
17395
|
});
|
|
17396
|
+
var TaskSchema = object({
|
|
17397
|
+
taskId: string2(),
|
|
17398
|
+
status: _enum(["working", "input_required", "completed", "failed", "cancelled"]),
|
|
17399
|
+
/**
|
|
17400
|
+
* Time in milliseconds to keep task results available after completion.
|
|
17401
|
+
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
17402
|
+
*/
|
|
17403
|
+
ttl: union([number2(), _null3()]),
|
|
17404
|
+
/**
|
|
17405
|
+
* ISO 8601 timestamp when the task was created.
|
|
17406
|
+
*/
|
|
17407
|
+
createdAt: string2(),
|
|
17408
|
+
/**
|
|
17409
|
+
* ISO 8601 timestamp when the task was last updated.
|
|
17410
|
+
*/
|
|
17411
|
+
lastUpdatedAt: string2(),
|
|
17412
|
+
pollInterval: optional(number2()),
|
|
17413
|
+
/**
|
|
17414
|
+
* Optional diagnostic message for failed tasks or other status information.
|
|
17415
|
+
*/
|
|
17416
|
+
statusMessage: optional(string2())
|
|
17417
|
+
});
|
|
17418
|
+
var CreateTaskResultSchema = ResultSchema.extend({
|
|
17419
|
+
task: TaskSchema
|
|
17420
|
+
});
|
|
17421
|
+
var TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(TaskSchema);
|
|
17422
|
+
var TaskStatusNotificationSchema = NotificationSchema.extend({
|
|
17423
|
+
method: literal("notifications/tasks/status"),
|
|
17424
|
+
params: TaskStatusNotificationParamsSchema
|
|
17425
|
+
});
|
|
17426
|
+
var GetTaskRequestSchema = RequestSchema.extend({
|
|
17427
|
+
method: literal("tasks/get"),
|
|
17428
|
+
params: BaseRequestParamsSchema.extend({
|
|
17429
|
+
taskId: string2()
|
|
17430
|
+
})
|
|
17431
|
+
});
|
|
17432
|
+
var GetTaskResultSchema = ResultSchema.merge(TaskSchema);
|
|
17433
|
+
var GetTaskPayloadRequestSchema = RequestSchema.extend({
|
|
17434
|
+
method: literal("tasks/result"),
|
|
17435
|
+
params: BaseRequestParamsSchema.extend({
|
|
17436
|
+
taskId: string2()
|
|
17437
|
+
})
|
|
17438
|
+
});
|
|
17439
|
+
var ListTasksRequestSchema = PaginatedRequestSchema.extend({
|
|
17440
|
+
method: literal("tasks/list")
|
|
17441
|
+
});
|
|
17442
|
+
var ListTasksResultSchema = PaginatedResultSchema.extend({
|
|
17443
|
+
tasks: array(TaskSchema)
|
|
17444
|
+
});
|
|
17445
|
+
var CancelTaskRequestSchema = RequestSchema.extend({
|
|
17446
|
+
method: literal("tasks/cancel"),
|
|
17447
|
+
params: BaseRequestParamsSchema.extend({
|
|
17448
|
+
taskId: string2()
|
|
17449
|
+
})
|
|
17450
|
+
});
|
|
17451
|
+
var CancelTaskResultSchema = ResultSchema.merge(TaskSchema);
|
|
17146
17452
|
var ResourceContentsSchema = object({
|
|
17147
17453
|
/**
|
|
17148
17454
|
* The URI of this resource.
|
|
@@ -17178,6 +17484,20 @@ var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
|
17178
17484
|
*/
|
|
17179
17485
|
blob: Base64Schema
|
|
17180
17486
|
});
|
|
17487
|
+
var AnnotationsSchema = object({
|
|
17488
|
+
/**
|
|
17489
|
+
* Intended audience(s) for the resource.
|
|
17490
|
+
*/
|
|
17491
|
+
audience: array(_enum(["user", "assistant"])).optional(),
|
|
17492
|
+
/**
|
|
17493
|
+
* Importance hint for the resource, from 0 (least) to 1 (most).
|
|
17494
|
+
*/
|
|
17495
|
+
priority: number2().min(0).max(1).optional(),
|
|
17496
|
+
/**
|
|
17497
|
+
* ISO 8601 timestamp for the most recent modification.
|
|
17498
|
+
*/
|
|
17499
|
+
lastModified: iso_exports.datetime({ offset: true }).optional()
|
|
17500
|
+
});
|
|
17181
17501
|
var ResourceSchema = object({
|
|
17182
17502
|
...BaseMetadataSchema.shape,
|
|
17183
17503
|
...IconsSchema.shape,
|
|
@@ -17195,6 +17515,10 @@ var ResourceSchema = object({
|
|
|
17195
17515
|
* The MIME type of this resource, if known.
|
|
17196
17516
|
*/
|
|
17197
17517
|
mimeType: optional(string2()),
|
|
17518
|
+
/**
|
|
17519
|
+
* Optional annotations for the client.
|
|
17520
|
+
*/
|
|
17521
|
+
annotations: AnnotationsSchema.optional(),
|
|
17198
17522
|
/**
|
|
17199
17523
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
17200
17524
|
* for notes on _meta usage.
|
|
@@ -17218,6 +17542,10 @@ var ResourceTemplateSchema = object({
|
|
|
17218
17542
|
* The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.
|
|
17219
17543
|
*/
|
|
17220
17544
|
mimeType: optional(string2()),
|
|
17545
|
+
/**
|
|
17546
|
+
* Optional annotations for the client.
|
|
17547
|
+
*/
|
|
17548
|
+
annotations: AnnotationsSchema.optional(),
|
|
17221
17549
|
/**
|
|
17222
17550
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
17223
17551
|
* for notes on _meta usage.
|
|
@@ -17332,6 +17660,10 @@ var TextContentSchema = object({
|
|
|
17332
17660
|
* The text content of the message.
|
|
17333
17661
|
*/
|
|
17334
17662
|
text: string2(),
|
|
17663
|
+
/**
|
|
17664
|
+
* Optional annotations for the client.
|
|
17665
|
+
*/
|
|
17666
|
+
annotations: AnnotationsSchema.optional(),
|
|
17335
17667
|
/**
|
|
17336
17668
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
17337
17669
|
* for notes on _meta usage.
|
|
@@ -17348,6 +17680,10 @@ var ImageContentSchema = object({
|
|
|
17348
17680
|
* The MIME type of the image. Different providers may support different image types.
|
|
17349
17681
|
*/
|
|
17350
17682
|
mimeType: string2(),
|
|
17683
|
+
/**
|
|
17684
|
+
* Optional annotations for the client.
|
|
17685
|
+
*/
|
|
17686
|
+
annotations: AnnotationsSchema.optional(),
|
|
17351
17687
|
/**
|
|
17352
17688
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
17353
17689
|
* for notes on _meta usage.
|
|
@@ -17364,6 +17700,10 @@ var AudioContentSchema = object({
|
|
|
17364
17700
|
* The MIME type of the audio. Different providers may support different audio types.
|
|
17365
17701
|
*/
|
|
17366
17702
|
mimeType: string2(),
|
|
17703
|
+
/**
|
|
17704
|
+
* Optional annotations for the client.
|
|
17705
|
+
*/
|
|
17706
|
+
annotations: AnnotationsSchema.optional(),
|
|
17367
17707
|
/**
|
|
17368
17708
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
17369
17709
|
* for notes on _meta usage.
|
|
@@ -17396,6 +17736,10 @@ var ToolUseContentSchema = object({
|
|
|
17396
17736
|
var EmbeddedResourceSchema = object({
|
|
17397
17737
|
type: literal("resource"),
|
|
17398
17738
|
resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
17739
|
+
/**
|
|
17740
|
+
* Optional annotations for the client.
|
|
17741
|
+
*/
|
|
17742
|
+
annotations: AnnotationsSchema.optional(),
|
|
17399
17743
|
/**
|
|
17400
17744
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
17401
17745
|
* for notes on _meta usage.
|
|
@@ -17465,6 +17809,17 @@ var ToolAnnotationsSchema = object({
|
|
|
17465
17809
|
*/
|
|
17466
17810
|
openWorldHint: boolean2().optional()
|
|
17467
17811
|
});
|
|
17812
|
+
var ToolExecutionSchema = object({
|
|
17813
|
+
/**
|
|
17814
|
+
* Indicates the tool's preference for task-augmented execution.
|
|
17815
|
+
* - "required": Clients MUST invoke the tool as a task
|
|
17816
|
+
* - "optional": Clients MAY invoke the tool as a task or normal request
|
|
17817
|
+
* - "forbidden": Clients MUST NOT attempt to invoke the tool as a task
|
|
17818
|
+
*
|
|
17819
|
+
* If not present, defaults to "forbidden".
|
|
17820
|
+
*/
|
|
17821
|
+
taskSupport: _enum(["required", "optional", "forbidden"]).optional()
|
|
17822
|
+
});
|
|
17468
17823
|
var ToolSchema = object({
|
|
17469
17824
|
...BaseMetadataSchema.shape,
|
|
17470
17825
|
...IconsSchema.shape,
|
|
@@ -17495,6 +17850,10 @@ var ToolSchema = object({
|
|
|
17495
17850
|
* Optional additional tool information.
|
|
17496
17851
|
*/
|
|
17497
17852
|
annotations: optional(ToolAnnotationsSchema),
|
|
17853
|
+
/**
|
|
17854
|
+
* Execution-related properties for this tool.
|
|
17855
|
+
*/
|
|
17856
|
+
execution: optional(ToolExecutionSchema),
|
|
17498
17857
|
/**
|
|
17499
17858
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
17500
17859
|
* for notes on _meta usage.
|
|
@@ -17631,6 +17990,7 @@ var ToolResultContentSchema = object({
|
|
|
17631
17990
|
*/
|
|
17632
17991
|
_meta: optional(object({}).passthrough())
|
|
17633
17992
|
}).passthrough();
|
|
17993
|
+
var SamplingContentSchema = discriminatedUnion("type", [TextContentSchema, ImageContentSchema, AudioContentSchema]);
|
|
17634
17994
|
var SamplingMessageContentBlockSchema = discriminatedUnion("type", [
|
|
17635
17995
|
TextContentSchema,
|
|
17636
17996
|
ImageContentSchema,
|
|
@@ -17694,6 +18054,28 @@ var CreateMessageRequestSchema = RequestSchema.extend({
|
|
|
17694
18054
|
params: CreateMessageRequestParamsSchema
|
|
17695
18055
|
});
|
|
17696
18056
|
var CreateMessageResultSchema = ResultSchema.extend({
|
|
18057
|
+
/**
|
|
18058
|
+
* The name of the model that generated the message.
|
|
18059
|
+
*/
|
|
18060
|
+
model: string2(),
|
|
18061
|
+
/**
|
|
18062
|
+
* The reason why sampling stopped, if known.
|
|
18063
|
+
*
|
|
18064
|
+
* Standard values:
|
|
18065
|
+
* - "endTurn": Natural end of the assistant's turn
|
|
18066
|
+
* - "stopSequence": A stop sequence was encountered
|
|
18067
|
+
* - "maxTokens": Maximum token limit was reached
|
|
18068
|
+
*
|
|
18069
|
+
* This field is an open string to allow for provider-specific stop reasons.
|
|
18070
|
+
*/
|
|
18071
|
+
stopReason: optional(_enum(["endTurn", "stopSequence", "maxTokens"]).or(string2())),
|
|
18072
|
+
role: _enum(["user", "assistant"]),
|
|
18073
|
+
/**
|
|
18074
|
+
* Response content. Single content block (text, image, or audio).
|
|
18075
|
+
*/
|
|
18076
|
+
content: SamplingContentSchema
|
|
18077
|
+
});
|
|
18078
|
+
var CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
17697
18079
|
/**
|
|
17698
18080
|
* The name of the model that generated the message.
|
|
17699
18081
|
*/
|
|
@@ -17712,7 +18094,7 @@ var CreateMessageResultSchema = ResultSchema.extend({
|
|
|
17712
18094
|
stopReason: optional(_enum(["endTurn", "stopSequence", "maxTokens", "toolUse"]).or(string2())),
|
|
17713
18095
|
role: _enum(["user", "assistant"]),
|
|
17714
18096
|
/**
|
|
17715
|
-
* Response content. May be ToolUseContent if stopReason is "toolUse".
|
|
18097
|
+
* Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
|
|
17716
18098
|
*/
|
|
17717
18099
|
content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)])
|
|
17718
18100
|
});
|
|
@@ -17860,8 +18242,10 @@ var ElicitResultSchema = ResultSchema.extend({
|
|
|
17860
18242
|
/**
|
|
17861
18243
|
* The submitted form data, only present when action is "accept".
|
|
17862
18244
|
* Contains values matching the requested schema.
|
|
18245
|
+
* Per MCP spec, content is "typically omitted" for decline/cancel actions.
|
|
18246
|
+
* We normalize null to undefined for leniency while maintaining type compatibility.
|
|
17863
18247
|
*/
|
|
17864
|
-
content: record(string2(), union([string2(), number2(), boolean2(), array(string2())])).optional()
|
|
18248
|
+
content: preprocess((val) => val === null ? void 0 : val, record(string2(), union([string2(), number2(), boolean2(), array(string2())])).optional())
|
|
17865
18249
|
});
|
|
17866
18250
|
var ResourceTemplateReferenceSchema = object({
|
|
17867
18251
|
type: literal("ref/resource"),
|
|
@@ -17907,11 +18291,13 @@ function assertCompleteRequestPrompt(request) {
|
|
|
17907
18291
|
if (request.params.ref.type !== "ref/prompt") {
|
|
17908
18292
|
throw new TypeError(`Expected CompleteRequestPrompt, but got ${request.params.ref.type}`);
|
|
17909
18293
|
}
|
|
18294
|
+
void request;
|
|
17910
18295
|
}
|
|
17911
18296
|
function assertCompleteRequestResourceTemplate(request) {
|
|
17912
18297
|
if (request.params.ref.type !== "ref/resource") {
|
|
17913
18298
|
throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${request.params.ref.type}`);
|
|
17914
18299
|
}
|
|
18300
|
+
void request;
|
|
17915
18301
|
}
|
|
17916
18302
|
var CompleteResultSchema = ResultSchema.extend({
|
|
17917
18303
|
completion: looseObject({
|
|
@@ -17966,16 +18352,37 @@ var ClientRequestSchema = union([
|
|
|
17966
18352
|
SubscribeRequestSchema,
|
|
17967
18353
|
UnsubscribeRequestSchema,
|
|
17968
18354
|
CallToolRequestSchema,
|
|
17969
|
-
ListToolsRequestSchema
|
|
18355
|
+
ListToolsRequestSchema,
|
|
18356
|
+
GetTaskRequestSchema,
|
|
18357
|
+
GetTaskPayloadRequestSchema,
|
|
18358
|
+
ListTasksRequestSchema
|
|
17970
18359
|
]);
|
|
17971
18360
|
var ClientNotificationSchema = union([
|
|
17972
18361
|
CancelledNotificationSchema,
|
|
17973
18362
|
ProgressNotificationSchema,
|
|
17974
18363
|
InitializedNotificationSchema,
|
|
17975
|
-
RootsListChangedNotificationSchema
|
|
18364
|
+
RootsListChangedNotificationSchema,
|
|
18365
|
+
TaskStatusNotificationSchema
|
|
18366
|
+
]);
|
|
18367
|
+
var ClientResultSchema = union([
|
|
18368
|
+
EmptyResultSchema,
|
|
18369
|
+
CreateMessageResultSchema,
|
|
18370
|
+
CreateMessageResultWithToolsSchema,
|
|
18371
|
+
ElicitResultSchema,
|
|
18372
|
+
ListRootsResultSchema,
|
|
18373
|
+
GetTaskResultSchema,
|
|
18374
|
+
ListTasksResultSchema,
|
|
18375
|
+
CreateTaskResultSchema
|
|
18376
|
+
]);
|
|
18377
|
+
var ServerRequestSchema = union([
|
|
18378
|
+
PingRequestSchema,
|
|
18379
|
+
CreateMessageRequestSchema,
|
|
18380
|
+
ElicitRequestSchema,
|
|
18381
|
+
ListRootsRequestSchema,
|
|
18382
|
+
GetTaskRequestSchema,
|
|
18383
|
+
GetTaskPayloadRequestSchema,
|
|
18384
|
+
ListTasksRequestSchema
|
|
17976
18385
|
]);
|
|
17977
|
-
var ClientResultSchema = union([EmptyResultSchema, CreateMessageResultSchema, ElicitResultSchema, ListRootsResultSchema]);
|
|
17978
|
-
var ServerRequestSchema = union([PingRequestSchema, CreateMessageRequestSchema, ElicitRequestSchema, ListRootsRequestSchema]);
|
|
17979
18386
|
var ServerNotificationSchema = union([
|
|
17980
18387
|
CancelledNotificationSchema,
|
|
17981
18388
|
ProgressNotificationSchema,
|
|
@@ -17984,6 +18391,7 @@ var ServerNotificationSchema = union([
|
|
|
17984
18391
|
ResourceListChangedNotificationSchema,
|
|
17985
18392
|
ToolListChangedNotificationSchema,
|
|
17986
18393
|
PromptListChangedNotificationSchema,
|
|
18394
|
+
TaskStatusNotificationSchema,
|
|
17987
18395
|
ElicitationCompleteNotificationSchema
|
|
17988
18396
|
]);
|
|
17989
18397
|
var ServerResultSchema = union([
|
|
@@ -17996,7 +18404,10 @@ var ServerResultSchema = union([
|
|
|
17996
18404
|
ListResourceTemplatesResultSchema,
|
|
17997
18405
|
ReadResourceResultSchema,
|
|
17998
18406
|
CallToolResultSchema,
|
|
17999
|
-
ListToolsResultSchema
|
|
18407
|
+
ListToolsResultSchema,
|
|
18408
|
+
GetTaskResultSchema,
|
|
18409
|
+
ListTasksResultSchema,
|
|
18410
|
+
CreateTaskResultSchema
|
|
18000
18411
|
]);
|
|
18001
18412
|
var McpError = class _McpError extends Error {
|
|
18002
18413
|
constructor(code, message, data) {
|
|
@@ -18069,9 +18480,9 @@ var StdioServerTransport = class {
|
|
|
18069
18480
|
this._readBuffer.append(chunk);
|
|
18070
18481
|
this.processReadBuffer();
|
|
18071
18482
|
};
|
|
18072
|
-
this._onerror = (
|
|
18483
|
+
this._onerror = (error2) => {
|
|
18073
18484
|
var _a;
|
|
18074
|
-
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this,
|
|
18485
|
+
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error2);
|
|
18075
18486
|
};
|
|
18076
18487
|
}
|
|
18077
18488
|
/**
|
|
@@ -18094,8 +18505,8 @@ var StdioServerTransport = class {
|
|
|
18094
18505
|
break;
|
|
18095
18506
|
}
|
|
18096
18507
|
(_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, message);
|
|
18097
|
-
} catch (
|
|
18098
|
-
(_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this,
|
|
18508
|
+
} catch (error2) {
|
|
18509
|
+
(_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error2);
|
|
18099
18510
|
}
|
|
18100
18511
|
}
|
|
18101
18512
|
}
|
|
@@ -18155,7 +18566,7 @@ __export(external_exports, {
|
|
|
18155
18566
|
ZodNaN: () => ZodNaN,
|
|
18156
18567
|
ZodNativeEnum: () => ZodNativeEnum,
|
|
18157
18568
|
ZodNever: () => ZodNever2,
|
|
18158
|
-
ZodNull: () =>
|
|
18569
|
+
ZodNull: () => ZodNull2,
|
|
18159
18570
|
ZodNullable: () => ZodNullable2,
|
|
18160
18571
|
ZodNumber: () => ZodNumber2,
|
|
18161
18572
|
ZodObject: () => ZodObject2,
|
|
@@ -18185,7 +18596,7 @@ __export(external_exports, {
|
|
|
18185
18596
|
custom: () => custom2,
|
|
18186
18597
|
date: () => dateType,
|
|
18187
18598
|
datetimeRegex: () => datetimeRegex,
|
|
18188
|
-
defaultErrorMap: () =>
|
|
18599
|
+
defaultErrorMap: () => en_default2,
|
|
18189
18600
|
discriminatedUnion: () => discriminatedUnionType,
|
|
18190
18601
|
effect: () => effectsType,
|
|
18191
18602
|
enum: () => enumType,
|
|
@@ -18418,8 +18829,8 @@ var ZodError2 = class _ZodError extends Error {
|
|
|
18418
18829
|
return issue2.message;
|
|
18419
18830
|
};
|
|
18420
18831
|
const fieldErrors = { _errors: [] };
|
|
18421
|
-
const processError = (
|
|
18422
|
-
for (const issue2 of
|
|
18832
|
+
const processError = (error2) => {
|
|
18833
|
+
for (const issue2 of error2.issues) {
|
|
18423
18834
|
if (issue2.code === "invalid_union") {
|
|
18424
18835
|
issue2.unionErrors.map(processError);
|
|
18425
18836
|
} else if (issue2.code === "invalid_return_type") {
|
|
@@ -18482,8 +18893,8 @@ var ZodError2 = class _ZodError extends Error {
|
|
|
18482
18893
|
}
|
|
18483
18894
|
};
|
|
18484
18895
|
ZodError2.create = (issues) => {
|
|
18485
|
-
const
|
|
18486
|
-
return
|
|
18896
|
+
const error2 = new ZodError2(issues);
|
|
18897
|
+
return error2;
|
|
18487
18898
|
};
|
|
18488
18899
|
|
|
18489
18900
|
// node_modules/zod/v3/locales/en.js
|
|
@@ -18587,10 +18998,10 @@ var errorMap = (issue2, _ctx) => {
|
|
|
18587
18998
|
}
|
|
18588
18999
|
return { message };
|
|
18589
19000
|
};
|
|
18590
|
-
var
|
|
19001
|
+
var en_default2 = errorMap;
|
|
18591
19002
|
|
|
18592
19003
|
// node_modules/zod/v3/errors.js
|
|
18593
|
-
var overrideErrorMap =
|
|
19004
|
+
var overrideErrorMap = en_default2;
|
|
18594
19005
|
function setErrorMap(map) {
|
|
18595
19006
|
overrideErrorMap = map;
|
|
18596
19007
|
}
|
|
@@ -18638,7 +19049,7 @@ function addIssueToContext(ctx, issueData) {
|
|
|
18638
19049
|
// then schema-bound map if available
|
|
18639
19050
|
overrideMap,
|
|
18640
19051
|
// then global override map
|
|
18641
|
-
overrideMap ===
|
|
19052
|
+
overrideMap === en_default2 ? void 0 : en_default2
|
|
18642
19053
|
// then global default map
|
|
18643
19054
|
].filter((x) => !!x)
|
|
18644
19055
|
});
|
|
@@ -18747,8 +19158,8 @@ var handleResult = (ctx, result) => {
|
|
|
18747
19158
|
get error() {
|
|
18748
19159
|
if (this._error)
|
|
18749
19160
|
return this._error;
|
|
18750
|
-
const
|
|
18751
|
-
this._error =
|
|
19161
|
+
const error2 = new ZodError2(ctx.common.issues);
|
|
19162
|
+
this._error = error2;
|
|
18752
19163
|
return this._error;
|
|
18753
19164
|
}
|
|
18754
19165
|
};
|
|
@@ -19145,8 +19556,8 @@ var ZodString2 = class _ZodString2 extends ZodType2 {
|
|
|
19145
19556
|
if (this._def.coerce) {
|
|
19146
19557
|
input.data = String(input.data);
|
|
19147
19558
|
}
|
|
19148
|
-
const
|
|
19149
|
-
if (
|
|
19559
|
+
const parsedType2 = this._getType(input);
|
|
19560
|
+
if (parsedType2 !== ZodParsedType.string) {
|
|
19150
19561
|
const ctx2 = this._getOrReturnCtx(input);
|
|
19151
19562
|
addIssueToContext(ctx2, {
|
|
19152
19563
|
code: ZodIssueCode.invalid_type,
|
|
@@ -19705,8 +20116,8 @@ var ZodNumber2 = class _ZodNumber extends ZodType2 {
|
|
|
19705
20116
|
if (this._def.coerce) {
|
|
19706
20117
|
input.data = Number(input.data);
|
|
19707
20118
|
}
|
|
19708
|
-
const
|
|
19709
|
-
if (
|
|
20119
|
+
const parsedType2 = this._getType(input);
|
|
20120
|
+
if (parsedType2 !== ZodParsedType.number) {
|
|
19710
20121
|
const ctx2 = this._getOrReturnCtx(input);
|
|
19711
20122
|
addIssueToContext(ctx2, {
|
|
19712
20123
|
code: ZodIssueCode.invalid_type,
|
|
@@ -19940,8 +20351,8 @@ var ZodBigInt = class _ZodBigInt extends ZodType2 {
|
|
|
19940
20351
|
return this._getInvalidInput(input);
|
|
19941
20352
|
}
|
|
19942
20353
|
}
|
|
19943
|
-
const
|
|
19944
|
-
if (
|
|
20354
|
+
const parsedType2 = this._getType(input);
|
|
20355
|
+
if (parsedType2 !== ZodParsedType.bigint) {
|
|
19945
20356
|
return this._getInvalidInput(input);
|
|
19946
20357
|
}
|
|
19947
20358
|
let ctx = void 0;
|
|
@@ -20103,8 +20514,8 @@ var ZodBoolean2 = class extends ZodType2 {
|
|
|
20103
20514
|
if (this._def.coerce) {
|
|
20104
20515
|
input.data = Boolean(input.data);
|
|
20105
20516
|
}
|
|
20106
|
-
const
|
|
20107
|
-
if (
|
|
20517
|
+
const parsedType2 = this._getType(input);
|
|
20518
|
+
if (parsedType2 !== ZodParsedType.boolean) {
|
|
20108
20519
|
const ctx = this._getOrReturnCtx(input);
|
|
20109
20520
|
addIssueToContext(ctx, {
|
|
20110
20521
|
code: ZodIssueCode.invalid_type,
|
|
@@ -20128,8 +20539,8 @@ var ZodDate = class _ZodDate extends ZodType2 {
|
|
|
20128
20539
|
if (this._def.coerce) {
|
|
20129
20540
|
input.data = new Date(input.data);
|
|
20130
20541
|
}
|
|
20131
|
-
const
|
|
20132
|
-
if (
|
|
20542
|
+
const parsedType2 = this._getType(input);
|
|
20543
|
+
if (parsedType2 !== ZodParsedType.date) {
|
|
20133
20544
|
const ctx2 = this._getOrReturnCtx(input);
|
|
20134
20545
|
addIssueToContext(ctx2, {
|
|
20135
20546
|
code: ZodIssueCode.invalid_type,
|
|
@@ -20234,8 +20645,8 @@ ZodDate.create = (params) => {
|
|
|
20234
20645
|
};
|
|
20235
20646
|
var ZodSymbol = class extends ZodType2 {
|
|
20236
20647
|
_parse(input) {
|
|
20237
|
-
const
|
|
20238
|
-
if (
|
|
20648
|
+
const parsedType2 = this._getType(input);
|
|
20649
|
+
if (parsedType2 !== ZodParsedType.symbol) {
|
|
20239
20650
|
const ctx = this._getOrReturnCtx(input);
|
|
20240
20651
|
addIssueToContext(ctx, {
|
|
20241
20652
|
code: ZodIssueCode.invalid_type,
|
|
@@ -20255,8 +20666,8 @@ ZodSymbol.create = (params) => {
|
|
|
20255
20666
|
};
|
|
20256
20667
|
var ZodUndefined = class extends ZodType2 {
|
|
20257
20668
|
_parse(input) {
|
|
20258
|
-
const
|
|
20259
|
-
if (
|
|
20669
|
+
const parsedType2 = this._getType(input);
|
|
20670
|
+
if (parsedType2 !== ZodParsedType.undefined) {
|
|
20260
20671
|
const ctx = this._getOrReturnCtx(input);
|
|
20261
20672
|
addIssueToContext(ctx, {
|
|
20262
20673
|
code: ZodIssueCode.invalid_type,
|
|
@@ -20274,10 +20685,10 @@ ZodUndefined.create = (params) => {
|
|
|
20274
20685
|
...processCreateParams(params)
|
|
20275
20686
|
});
|
|
20276
20687
|
};
|
|
20277
|
-
var
|
|
20688
|
+
var ZodNull2 = class extends ZodType2 {
|
|
20278
20689
|
_parse(input) {
|
|
20279
|
-
const
|
|
20280
|
-
if (
|
|
20690
|
+
const parsedType2 = this._getType(input);
|
|
20691
|
+
if (parsedType2 !== ZodParsedType.null) {
|
|
20281
20692
|
const ctx = this._getOrReturnCtx(input);
|
|
20282
20693
|
addIssueToContext(ctx, {
|
|
20283
20694
|
code: ZodIssueCode.invalid_type,
|
|
@@ -20289,8 +20700,8 @@ var ZodNull = class extends ZodType2 {
|
|
|
20289
20700
|
return OK(input.data);
|
|
20290
20701
|
}
|
|
20291
20702
|
};
|
|
20292
|
-
|
|
20293
|
-
return new
|
|
20703
|
+
ZodNull2.create = (params) => {
|
|
20704
|
+
return new ZodNull2({
|
|
20294
20705
|
typeName: ZodFirstPartyTypeKind.ZodNull,
|
|
20295
20706
|
...processCreateParams(params)
|
|
20296
20707
|
});
|
|
@@ -20344,8 +20755,8 @@ ZodNever2.create = (params) => {
|
|
|
20344
20755
|
};
|
|
20345
20756
|
var ZodVoid = class extends ZodType2 {
|
|
20346
20757
|
_parse(input) {
|
|
20347
|
-
const
|
|
20348
|
-
if (
|
|
20758
|
+
const parsedType2 = this._getType(input);
|
|
20759
|
+
if (parsedType2 !== ZodParsedType.undefined) {
|
|
20349
20760
|
const ctx = this._getOrReturnCtx(input);
|
|
20350
20761
|
addIssueToContext(ctx, {
|
|
20351
20762
|
code: ZodIssueCode.invalid_type,
|
|
@@ -20506,8 +20917,8 @@ var ZodObject2 = class _ZodObject extends ZodType2 {
|
|
|
20506
20917
|
return this._cached;
|
|
20507
20918
|
}
|
|
20508
20919
|
_parse(input) {
|
|
20509
|
-
const
|
|
20510
|
-
if (
|
|
20920
|
+
const parsedType2 = this._getType(input);
|
|
20921
|
+
if (parsedType2 !== ZodParsedType.object) {
|
|
20511
20922
|
const ctx2 = this._getOrReturnCtx(input);
|
|
20512
20923
|
addIssueToContext(ctx2, {
|
|
20513
20924
|
code: ZodIssueCode.invalid_type,
|
|
@@ -20934,7 +21345,7 @@ var getDiscriminator = (type) => {
|
|
|
20934
21345
|
return getDiscriminator(type._def.innerType);
|
|
20935
21346
|
} else if (type instanceof ZodUndefined) {
|
|
20936
21347
|
return [void 0];
|
|
20937
|
-
} else if (type instanceof
|
|
21348
|
+
} else if (type instanceof ZodNull2) {
|
|
20938
21349
|
return [null];
|
|
20939
21350
|
} else if (type instanceof ZodOptional2) {
|
|
20940
21351
|
return [void 0, ...getDiscriminator(type.unwrap())];
|
|
@@ -21403,25 +21814,25 @@ var ZodFunction = class _ZodFunction extends ZodType2 {
|
|
|
21403
21814
|
});
|
|
21404
21815
|
return INVALID;
|
|
21405
21816
|
}
|
|
21406
|
-
function makeArgsIssue(args,
|
|
21817
|
+
function makeArgsIssue(args, error2) {
|
|
21407
21818
|
return makeIssue({
|
|
21408
21819
|
data: args,
|
|
21409
21820
|
path: ctx.path,
|
|
21410
|
-
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(),
|
|
21821
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default2].filter((x) => !!x),
|
|
21411
21822
|
issueData: {
|
|
21412
21823
|
code: ZodIssueCode.invalid_arguments,
|
|
21413
|
-
argumentsError:
|
|
21824
|
+
argumentsError: error2
|
|
21414
21825
|
}
|
|
21415
21826
|
});
|
|
21416
21827
|
}
|
|
21417
|
-
function makeReturnsIssue(returns,
|
|
21828
|
+
function makeReturnsIssue(returns, error2) {
|
|
21418
21829
|
return makeIssue({
|
|
21419
21830
|
data: returns,
|
|
21420
21831
|
path: ctx.path,
|
|
21421
|
-
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(),
|
|
21832
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default2].filter((x) => !!x),
|
|
21422
21833
|
issueData: {
|
|
21423
21834
|
code: ZodIssueCode.invalid_return_type,
|
|
21424
|
-
returnTypeError:
|
|
21835
|
+
returnTypeError: error2
|
|
21425
21836
|
}
|
|
21426
21837
|
});
|
|
21427
21838
|
}
|
|
@@ -21430,15 +21841,15 @@ var ZodFunction = class _ZodFunction extends ZodType2 {
|
|
|
21430
21841
|
if (this._def.returns instanceof ZodPromise) {
|
|
21431
21842
|
const me = this;
|
|
21432
21843
|
return OK(async function(...args) {
|
|
21433
|
-
const
|
|
21844
|
+
const error2 = new ZodError2([]);
|
|
21434
21845
|
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
21435
|
-
|
|
21436
|
-
throw
|
|
21846
|
+
error2.addIssue(makeArgsIssue(args, e));
|
|
21847
|
+
throw error2;
|
|
21437
21848
|
});
|
|
21438
21849
|
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
21439
21850
|
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
21440
|
-
|
|
21441
|
-
throw
|
|
21851
|
+
error2.addIssue(makeReturnsIssue(result, e));
|
|
21852
|
+
throw error2;
|
|
21442
21853
|
});
|
|
21443
21854
|
return parsedReturns;
|
|
21444
21855
|
});
|
|
@@ -21815,8 +22226,8 @@ ZodEffects.createWithPreprocess = (preprocess2, schema, params) => {
|
|
|
21815
22226
|
};
|
|
21816
22227
|
var ZodOptional2 = class extends ZodType2 {
|
|
21817
22228
|
_parse(input) {
|
|
21818
|
-
const
|
|
21819
|
-
if (
|
|
22229
|
+
const parsedType2 = this._getType(input);
|
|
22230
|
+
if (parsedType2 === ZodParsedType.undefined) {
|
|
21820
22231
|
return OK(void 0);
|
|
21821
22232
|
}
|
|
21822
22233
|
return this._def.innerType._parse(input);
|
|
@@ -21834,8 +22245,8 @@ ZodOptional2.create = (type, params) => {
|
|
|
21834
22245
|
};
|
|
21835
22246
|
var ZodNullable2 = class extends ZodType2 {
|
|
21836
22247
|
_parse(input) {
|
|
21837
|
-
const
|
|
21838
|
-
if (
|
|
22248
|
+
const parsedType2 = this._getType(input);
|
|
22249
|
+
if (parsedType2 === ZodParsedType.null) {
|
|
21839
22250
|
return OK(null);
|
|
21840
22251
|
}
|
|
21841
22252
|
return this._def.innerType._parse(input);
|
|
@@ -21931,8 +22342,8 @@ ZodCatch2.create = (type, params) => {
|
|
|
21931
22342
|
};
|
|
21932
22343
|
var ZodNaN = class extends ZodType2 {
|
|
21933
22344
|
_parse(input) {
|
|
21934
|
-
const
|
|
21935
|
-
if (
|
|
22345
|
+
const parsedType2 = this._getType(input);
|
|
22346
|
+
if (parsedType2 !== ZodParsedType.nan) {
|
|
21936
22347
|
const ctx = this._getOrReturnCtx(input);
|
|
21937
22348
|
addIssueToContext(ctx, {
|
|
21938
22349
|
code: ZodIssueCode.invalid_type,
|
|
@@ -21950,7 +22361,7 @@ ZodNaN.create = (params) => {
|
|
|
21950
22361
|
...processCreateParams(params)
|
|
21951
22362
|
});
|
|
21952
22363
|
};
|
|
21953
|
-
var BRAND = Symbol("zod_brand");
|
|
22364
|
+
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
|
|
21954
22365
|
var ZodBranded = class extends ZodType2 {
|
|
21955
22366
|
_parse(input) {
|
|
21956
22367
|
const { ctx } = this._processInputParams(input);
|
|
@@ -22122,7 +22533,7 @@ var booleanType = ZodBoolean2.create;
|
|
|
22122
22533
|
var dateType = ZodDate.create;
|
|
22123
22534
|
var symbolType = ZodSymbol.create;
|
|
22124
22535
|
var undefinedType = ZodUndefined.create;
|
|
22125
|
-
var nullType =
|
|
22536
|
+
var nullType = ZodNull2.create;
|
|
22126
22537
|
var anyType = ZodAny.create;
|
|
22127
22538
|
var unknownType = ZodUnknown2.create;
|
|
22128
22539
|
var neverType = ZodNever2.create;
|
|
@@ -22152,14 +22563,14 @@ var ostring = () => stringType().optional();
|
|
|
22152
22563
|
var onumber = () => numberType().optional();
|
|
22153
22564
|
var oboolean = () => booleanType().optional();
|
|
22154
22565
|
var coerce = {
|
|
22155
|
-
string: (arg) => ZodString2.create({ ...arg, coerce: true }),
|
|
22156
|
-
number: (arg) => ZodNumber2.create({ ...arg, coerce: true }),
|
|
22157
|
-
boolean: (arg) => ZodBoolean2.create({
|
|
22566
|
+
string: ((arg) => ZodString2.create({ ...arg, coerce: true })),
|
|
22567
|
+
number: ((arg) => ZodNumber2.create({ ...arg, coerce: true })),
|
|
22568
|
+
boolean: ((arg) => ZodBoolean2.create({
|
|
22158
22569
|
...arg,
|
|
22159
22570
|
coerce: true
|
|
22160
|
-
}),
|
|
22161
|
-
bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
|
|
22162
|
-
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
22571
|
+
})),
|
|
22572
|
+
bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
|
|
22573
|
+
date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
|
|
22163
22574
|
};
|
|
22164
22575
|
var NEVER2 = INVALID;
|
|
22165
22576
|
|
|
@@ -22187,10 +22598,10 @@ var ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
|
|
|
22187
22598
|
};
|
|
22188
22599
|
inst.clone = (_def, params) => clone(inst, _def, params);
|
|
22189
22600
|
inst.brand = () => inst;
|
|
22190
|
-
inst.register = (reg, meta) => {
|
|
22601
|
+
inst.register = ((reg, meta) => {
|
|
22191
22602
|
reg.add(inst, meta);
|
|
22192
22603
|
return inst;
|
|
22193
|
-
};
|
|
22604
|
+
});
|
|
22194
22605
|
});
|
|
22195
22606
|
var ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => {
|
|
22196
22607
|
$ZodObject.init(inst, def);
|
|
@@ -22284,7 +22695,7 @@ function normalizeObjectSchema(schema) {
|
|
|
22284
22695
|
if (isZ4Schema(schema)) {
|
|
22285
22696
|
const v4Schema = schema;
|
|
22286
22697
|
const def = (_a = v4Schema._zod) === null || _a === void 0 ? void 0 : _a.def;
|
|
22287
|
-
if (def && (def.
|
|
22698
|
+
if (def && (def.type === "object" || def.shape !== void 0)) {
|
|
22288
22699
|
return schema;
|
|
22289
22700
|
}
|
|
22290
22701
|
} else {
|
|
@@ -22295,24 +22706,24 @@ function normalizeObjectSchema(schema) {
|
|
|
22295
22706
|
}
|
|
22296
22707
|
return void 0;
|
|
22297
22708
|
}
|
|
22298
|
-
function getParseErrorMessage(
|
|
22299
|
-
if (
|
|
22300
|
-
if ("message" in
|
|
22301
|
-
return
|
|
22709
|
+
function getParseErrorMessage(error2) {
|
|
22710
|
+
if (error2 && typeof error2 === "object") {
|
|
22711
|
+
if ("message" in error2 && typeof error2.message === "string") {
|
|
22712
|
+
return error2.message;
|
|
22302
22713
|
}
|
|
22303
|
-
if ("issues" in
|
|
22304
|
-
const firstIssue =
|
|
22714
|
+
if ("issues" in error2 && Array.isArray(error2.issues) && error2.issues.length > 0) {
|
|
22715
|
+
const firstIssue = error2.issues[0];
|
|
22305
22716
|
if (firstIssue && typeof firstIssue === "object" && "message" in firstIssue) {
|
|
22306
22717
|
return String(firstIssue.message);
|
|
22307
22718
|
}
|
|
22308
22719
|
}
|
|
22309
22720
|
try {
|
|
22310
|
-
return JSON.stringify(
|
|
22721
|
+
return JSON.stringify(error2);
|
|
22311
22722
|
} catch (_a) {
|
|
22312
|
-
return String(
|
|
22723
|
+
return String(error2);
|
|
22313
22724
|
}
|
|
22314
22725
|
}
|
|
22315
|
-
return String(
|
|
22726
|
+
return String(error2);
|
|
22316
22727
|
}
|
|
22317
22728
|
function getSchemaDescription(schema) {
|
|
22318
22729
|
var _a, _b, _c, _d;
|
|
@@ -22327,7 +22738,7 @@ function isSchemaOptional(schema) {
|
|
|
22327
22738
|
var _a, _b, _c;
|
|
22328
22739
|
if (isZ4Schema(schema)) {
|
|
22329
22740
|
const v4Schema = schema;
|
|
22330
|
-
return ((_b = (_a = v4Schema._zod) === null || _a === void 0 ? void 0 : _a.def) === null || _b === void 0 ? void 0 : _b.
|
|
22741
|
+
return ((_b = (_a = v4Schema._zod) === null || _a === void 0 ? void 0 : _a.def) === null || _b === void 0 ? void 0 : _b.type) === "optional";
|
|
22331
22742
|
}
|
|
22332
22743
|
const v3Schema = schema;
|
|
22333
22744
|
if (typeof schema.isOptional === "function") {
|
|
@@ -22363,8 +22774,13 @@ function getLiteralValue(schema) {
|
|
|
22363
22774
|
return void 0;
|
|
22364
22775
|
}
|
|
22365
22776
|
|
|
22777
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
|
|
22778
|
+
function isTerminal(status) {
|
|
22779
|
+
return status === "completed" || status === "failed" || status === "cancelled";
|
|
22780
|
+
}
|
|
22781
|
+
|
|
22366
22782
|
// node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
22367
|
-
var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
22783
|
+
var ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
22368
22784
|
var defaultOptions = {
|
|
22369
22785
|
name: void 0,
|
|
22370
22786
|
$refStrategy: "root",
|
|
@@ -22671,20 +23087,20 @@ function parseIntersectionDef(def, refs) {
|
|
|
22671
23087
|
|
|
22672
23088
|
// node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
22673
23089
|
function parseLiteralDef(def, refs) {
|
|
22674
|
-
const
|
|
22675
|
-
if (
|
|
23090
|
+
const parsedType2 = typeof def.value;
|
|
23091
|
+
if (parsedType2 !== "bigint" && parsedType2 !== "number" && parsedType2 !== "boolean" && parsedType2 !== "string") {
|
|
22676
23092
|
return {
|
|
22677
23093
|
type: Array.isArray(def.value) ? "array" : "object"
|
|
22678
23094
|
};
|
|
22679
23095
|
}
|
|
22680
23096
|
if (refs.target === "openApi3") {
|
|
22681
23097
|
return {
|
|
22682
|
-
type:
|
|
23098
|
+
type: parsedType2 === "bigint" ? "integer" : parsedType2,
|
|
22683
23099
|
enum: [def.value]
|
|
22684
23100
|
};
|
|
22685
23101
|
}
|
|
22686
23102
|
return {
|
|
22687
|
-
type:
|
|
23103
|
+
type: parsedType2 === "bigint" ? "integer" : parsedType2,
|
|
22688
23104
|
const: def.value
|
|
22689
23105
|
};
|
|
22690
23106
|
}
|
|
@@ -23703,9 +24119,10 @@ var Protocol = class {
|
|
|
23703
24119
|
this._progressHandlers = /* @__PURE__ */ new Map();
|
|
23704
24120
|
this._timeoutInfo = /* @__PURE__ */ new Map();
|
|
23705
24121
|
this._pendingDebouncedNotifications = /* @__PURE__ */ new Set();
|
|
24122
|
+
this._taskProgressTokens = /* @__PURE__ */ new Map();
|
|
24123
|
+
this._requestResolvers = /* @__PURE__ */ new Map();
|
|
23706
24124
|
this.setNotificationHandler(CancelledNotificationSchema, (notification) => {
|
|
23707
|
-
|
|
23708
|
-
controller === null || controller === void 0 ? void 0 : controller.abort(notification.params.reason);
|
|
24125
|
+
this._oncancel(notification);
|
|
23709
24126
|
});
|
|
23710
24127
|
this.setNotificationHandler(ProgressNotificationSchema, (notification) => {
|
|
23711
24128
|
this._onprogress(notification);
|
|
@@ -23715,6 +24132,116 @@ var Protocol = class {
|
|
|
23715
24132
|
// Automatic pong by default.
|
|
23716
24133
|
(_request) => ({})
|
|
23717
24134
|
);
|
|
24135
|
+
this._taskStore = _options === null || _options === void 0 ? void 0 : _options.taskStore;
|
|
24136
|
+
this._taskMessageQueue = _options === null || _options === void 0 ? void 0 : _options.taskMessageQueue;
|
|
24137
|
+
if (this._taskStore) {
|
|
24138
|
+
this.setRequestHandler(GetTaskRequestSchema, async (request, extra) => {
|
|
24139
|
+
const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
24140
|
+
if (!task) {
|
|
24141
|
+
throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
|
|
24142
|
+
}
|
|
24143
|
+
return {
|
|
24144
|
+
...task
|
|
24145
|
+
};
|
|
24146
|
+
});
|
|
24147
|
+
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
24148
|
+
const handleTaskResult = async () => {
|
|
24149
|
+
var _a;
|
|
24150
|
+
const taskId = request.params.taskId;
|
|
24151
|
+
if (this._taskMessageQueue) {
|
|
24152
|
+
let queuedMessage;
|
|
24153
|
+
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
24154
|
+
if (queuedMessage.type === "response" || queuedMessage.type === "error") {
|
|
24155
|
+
const message = queuedMessage.message;
|
|
24156
|
+
const requestId = message.id;
|
|
24157
|
+
const resolver = this._requestResolvers.get(requestId);
|
|
24158
|
+
if (resolver) {
|
|
24159
|
+
this._requestResolvers.delete(requestId);
|
|
24160
|
+
if (queuedMessage.type === "response") {
|
|
24161
|
+
resolver(message);
|
|
24162
|
+
} else {
|
|
24163
|
+
const errorMessage = message;
|
|
24164
|
+
const error2 = new McpError(errorMessage.error.code, errorMessage.error.message, errorMessage.error.data);
|
|
24165
|
+
resolver(error2);
|
|
24166
|
+
}
|
|
24167
|
+
} else {
|
|
24168
|
+
const messageType = queuedMessage.type === "response" ? "Response" : "Error";
|
|
24169
|
+
this._onerror(new Error(`${messageType} handler missing for request ${requestId}`));
|
|
24170
|
+
}
|
|
24171
|
+
continue;
|
|
24172
|
+
}
|
|
24173
|
+
await ((_a = this._transport) === null || _a === void 0 ? void 0 : _a.send(queuedMessage.message, { relatedRequestId: extra.requestId }));
|
|
24174
|
+
}
|
|
24175
|
+
}
|
|
24176
|
+
const task = await this._taskStore.getTask(taskId, extra.sessionId);
|
|
24177
|
+
if (!task) {
|
|
24178
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
24179
|
+
}
|
|
24180
|
+
if (!isTerminal(task.status)) {
|
|
24181
|
+
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
24182
|
+
return await handleTaskResult();
|
|
24183
|
+
}
|
|
24184
|
+
if (isTerminal(task.status)) {
|
|
24185
|
+
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
24186
|
+
this._clearTaskQueue(taskId);
|
|
24187
|
+
return {
|
|
24188
|
+
...result,
|
|
24189
|
+
_meta: {
|
|
24190
|
+
...result._meta,
|
|
24191
|
+
[RELATED_TASK_META_KEY]: {
|
|
24192
|
+
taskId
|
|
24193
|
+
}
|
|
24194
|
+
}
|
|
24195
|
+
};
|
|
24196
|
+
}
|
|
24197
|
+
return await handleTaskResult();
|
|
24198
|
+
};
|
|
24199
|
+
return await handleTaskResult();
|
|
24200
|
+
});
|
|
24201
|
+
this.setRequestHandler(ListTasksRequestSchema, async (request, extra) => {
|
|
24202
|
+
var _a;
|
|
24203
|
+
try {
|
|
24204
|
+
const { tasks, nextCursor } = await this._taskStore.listTasks((_a = request.params) === null || _a === void 0 ? void 0 : _a.cursor, extra.sessionId);
|
|
24205
|
+
return {
|
|
24206
|
+
tasks,
|
|
24207
|
+
nextCursor,
|
|
24208
|
+
_meta: {}
|
|
24209
|
+
};
|
|
24210
|
+
} catch (error2) {
|
|
24211
|
+
throw new McpError(ErrorCode.InvalidParams, `Failed to list tasks: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
24212
|
+
}
|
|
24213
|
+
});
|
|
24214
|
+
this.setRequestHandler(CancelTaskRequestSchema, async (request, extra) => {
|
|
24215
|
+
try {
|
|
24216
|
+
const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
24217
|
+
if (!task) {
|
|
24218
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${request.params.taskId}`);
|
|
24219
|
+
}
|
|
24220
|
+
if (isTerminal(task.status)) {
|
|
24221
|
+
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
24222
|
+
}
|
|
24223
|
+
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
24224
|
+
this._clearTaskQueue(request.params.taskId);
|
|
24225
|
+
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
24226
|
+
if (!cancelledTask) {
|
|
24227
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
24228
|
+
}
|
|
24229
|
+
return {
|
|
24230
|
+
_meta: {},
|
|
24231
|
+
...cancelledTask
|
|
24232
|
+
};
|
|
24233
|
+
} catch (error2) {
|
|
24234
|
+
if (error2 instanceof McpError) {
|
|
24235
|
+
throw error2;
|
|
24236
|
+
}
|
|
24237
|
+
throw new McpError(ErrorCode.InvalidRequest, `Failed to cancel task: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
24238
|
+
}
|
|
24239
|
+
});
|
|
24240
|
+
}
|
|
24241
|
+
}
|
|
24242
|
+
async _oncancel(notification) {
|
|
24243
|
+
const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
|
|
24244
|
+
controller === null || controller === void 0 ? void 0 : controller.abort(notification.params.reason);
|
|
23718
24245
|
}
|
|
23719
24246
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
23720
24247
|
this._timeoutInfo.set(messageId, {
|
|
@@ -23763,9 +24290,9 @@ var Protocol = class {
|
|
|
23763
24290
|
this._onclose();
|
|
23764
24291
|
};
|
|
23765
24292
|
const _onerror = (_b = this.transport) === null || _b === void 0 ? void 0 : _b.onerror;
|
|
23766
|
-
this._transport.onerror = (
|
|
23767
|
-
_onerror === null || _onerror === void 0 ? void 0 : _onerror(
|
|
23768
|
-
this._onerror(
|
|
24293
|
+
this._transport.onerror = (error2) => {
|
|
24294
|
+
_onerror === null || _onerror === void 0 ? void 0 : _onerror(error2);
|
|
24295
|
+
this._onerror(error2);
|
|
23769
24296
|
};
|
|
23770
24297
|
const _onmessage = (_c = this._transport) === null || _c === void 0 ? void 0 : _c.onmessage;
|
|
23771
24298
|
this._transport.onmessage = (message, extra) => {
|
|
@@ -23787,17 +24314,18 @@ var Protocol = class {
|
|
|
23787
24314
|
const responseHandlers = this._responseHandlers;
|
|
23788
24315
|
this._responseHandlers = /* @__PURE__ */ new Map();
|
|
23789
24316
|
this._progressHandlers.clear();
|
|
24317
|
+
this._taskProgressTokens.clear();
|
|
23790
24318
|
this._pendingDebouncedNotifications.clear();
|
|
24319
|
+
const error2 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
23791
24320
|
this._transport = void 0;
|
|
23792
24321
|
(_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
23793
|
-
const error = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
23794
24322
|
for (const handler of responseHandlers.values()) {
|
|
23795
|
-
handler(
|
|
24323
|
+
handler(error2);
|
|
23796
24324
|
}
|
|
23797
24325
|
}
|
|
23798
|
-
_onerror(
|
|
24326
|
+
_onerror(error2) {
|
|
23799
24327
|
var _a;
|
|
23800
|
-
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this,
|
|
24328
|
+
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error2);
|
|
23801
24329
|
}
|
|
23802
24330
|
_onnotification(notification) {
|
|
23803
24331
|
var _a;
|
|
@@ -23805,59 +24333,115 @@ var Protocol = class {
|
|
|
23805
24333
|
if (handler === void 0) {
|
|
23806
24334
|
return;
|
|
23807
24335
|
}
|
|
23808
|
-
Promise.resolve().then(() => handler(notification)).catch((
|
|
24336
|
+
Promise.resolve().then(() => handler(notification)).catch((error2) => this._onerror(new Error(`Uncaught error in notification handler: ${error2}`)));
|
|
23809
24337
|
}
|
|
23810
24338
|
_onrequest(request, extra) {
|
|
23811
|
-
var _a, _b;
|
|
24339
|
+
var _a, _b, _c, _d, _e, _f;
|
|
23812
24340
|
const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== void 0 ? _a : this.fallbackRequestHandler;
|
|
23813
24341
|
const capturedTransport = this._transport;
|
|
24342
|
+
const relatedTaskId = (_d = (_c = (_b = request.params) === null || _b === void 0 ? void 0 : _b._meta) === null || _c === void 0 ? void 0 : _c[RELATED_TASK_META_KEY]) === null || _d === void 0 ? void 0 : _d.taskId;
|
|
23814
24343
|
if (handler === void 0) {
|
|
23815
|
-
|
|
24344
|
+
const errorResponse = {
|
|
23816
24345
|
jsonrpc: "2.0",
|
|
23817
24346
|
id: request.id,
|
|
23818
24347
|
error: {
|
|
23819
24348
|
code: ErrorCode.MethodNotFound,
|
|
23820
24349
|
message: "Method not found"
|
|
23821
24350
|
}
|
|
23822
|
-
}
|
|
24351
|
+
};
|
|
24352
|
+
if (relatedTaskId && this._taskMessageQueue) {
|
|
24353
|
+
this._enqueueTaskMessage(relatedTaskId, {
|
|
24354
|
+
type: "error",
|
|
24355
|
+
message: errorResponse,
|
|
24356
|
+
timestamp: Date.now()
|
|
24357
|
+
}, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId).catch((error2) => this._onerror(new Error(`Failed to enqueue error response: ${error2}`)));
|
|
24358
|
+
} else {
|
|
24359
|
+
capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(errorResponse).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
|
|
24360
|
+
}
|
|
23823
24361
|
return;
|
|
23824
24362
|
}
|
|
23825
24363
|
const abortController = new AbortController();
|
|
23826
24364
|
this._requestHandlerAbortControllers.set(request.id, abortController);
|
|
24365
|
+
const taskCreationParams = (_e = request.params) === null || _e === void 0 ? void 0 : _e.task;
|
|
24366
|
+
const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId) : void 0;
|
|
23827
24367
|
const fullExtra = {
|
|
23828
24368
|
signal: abortController.signal,
|
|
23829
24369
|
sessionId: capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId,
|
|
23830
|
-
_meta: (
|
|
23831
|
-
sendNotification: (notification) =>
|
|
23832
|
-
|
|
24370
|
+
_meta: (_f = request.params) === null || _f === void 0 ? void 0 : _f._meta,
|
|
24371
|
+
sendNotification: async (notification) => {
|
|
24372
|
+
const notificationOptions = { relatedRequestId: request.id };
|
|
24373
|
+
if (relatedTaskId) {
|
|
24374
|
+
notificationOptions.relatedTask = { taskId: relatedTaskId };
|
|
24375
|
+
}
|
|
24376
|
+
await this.notification(notification, notificationOptions);
|
|
24377
|
+
},
|
|
24378
|
+
sendRequest: async (r, resultSchema, options) => {
|
|
24379
|
+
var _a2, _b2;
|
|
24380
|
+
const requestOptions = { ...options, relatedRequestId: request.id };
|
|
24381
|
+
if (relatedTaskId && !requestOptions.relatedTask) {
|
|
24382
|
+
requestOptions.relatedTask = { taskId: relatedTaskId };
|
|
24383
|
+
}
|
|
24384
|
+
const effectiveTaskId = (_b2 = (_a2 = requestOptions.relatedTask) === null || _a2 === void 0 ? void 0 : _a2.taskId) !== null && _b2 !== void 0 ? _b2 : relatedTaskId;
|
|
24385
|
+
if (effectiveTaskId && taskStore) {
|
|
24386
|
+
await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
|
|
24387
|
+
}
|
|
24388
|
+
return await this.request(r, resultSchema, requestOptions);
|
|
24389
|
+
},
|
|
23833
24390
|
authInfo: extra === null || extra === void 0 ? void 0 : extra.authInfo,
|
|
23834
24391
|
requestId: request.id,
|
|
23835
|
-
requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo
|
|
23836
|
-
|
|
23837
|
-
|
|
24392
|
+
requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo,
|
|
24393
|
+
taskId: relatedTaskId,
|
|
24394
|
+
taskStore,
|
|
24395
|
+
taskRequestedTtl: taskCreationParams === null || taskCreationParams === void 0 ? void 0 : taskCreationParams.ttl,
|
|
24396
|
+
closeSSEStream: extra === null || extra === void 0 ? void 0 : extra.closeSSEStream,
|
|
24397
|
+
closeStandaloneSSEStream: extra === null || extra === void 0 ? void 0 : extra.closeStandaloneSSEStream
|
|
24398
|
+
};
|
|
24399
|
+
Promise.resolve().then(() => {
|
|
24400
|
+
if (taskCreationParams) {
|
|
24401
|
+
this.assertTaskHandlerCapability(request.method);
|
|
24402
|
+
}
|
|
24403
|
+
}).then(() => handler(request, fullExtra)).then(async (result) => {
|
|
23838
24404
|
if (abortController.signal.aborted) {
|
|
23839
24405
|
return;
|
|
23840
24406
|
}
|
|
23841
|
-
|
|
24407
|
+
const response = {
|
|
23842
24408
|
result,
|
|
23843
24409
|
jsonrpc: "2.0",
|
|
23844
24410
|
id: request.id
|
|
23845
|
-
}
|
|
23846
|
-
|
|
24411
|
+
};
|
|
24412
|
+
if (relatedTaskId && this._taskMessageQueue) {
|
|
24413
|
+
await this._enqueueTaskMessage(relatedTaskId, {
|
|
24414
|
+
type: "response",
|
|
24415
|
+
message: response,
|
|
24416
|
+
timestamp: Date.now()
|
|
24417
|
+
}, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId);
|
|
24418
|
+
} else {
|
|
24419
|
+
await (capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(response));
|
|
24420
|
+
}
|
|
24421
|
+
}, async (error2) => {
|
|
23847
24422
|
var _a2;
|
|
23848
24423
|
if (abortController.signal.aborted) {
|
|
23849
24424
|
return;
|
|
23850
24425
|
}
|
|
23851
|
-
|
|
24426
|
+
const errorResponse = {
|
|
23852
24427
|
jsonrpc: "2.0",
|
|
23853
24428
|
id: request.id,
|
|
23854
24429
|
error: {
|
|
23855
|
-
code: Number.isSafeInteger(
|
|
23856
|
-
message: (_a2 =
|
|
23857
|
-
...
|
|
24430
|
+
code: Number.isSafeInteger(error2["code"]) ? error2["code"] : ErrorCode.InternalError,
|
|
24431
|
+
message: (_a2 = error2.message) !== null && _a2 !== void 0 ? _a2 : "Internal error",
|
|
24432
|
+
...error2["data"] !== void 0 && { data: error2["data"] }
|
|
23858
24433
|
}
|
|
23859
|
-
}
|
|
23860
|
-
|
|
24434
|
+
};
|
|
24435
|
+
if (relatedTaskId && this._taskMessageQueue) {
|
|
24436
|
+
await this._enqueueTaskMessage(relatedTaskId, {
|
|
24437
|
+
type: "error",
|
|
24438
|
+
message: errorResponse,
|
|
24439
|
+
timestamp: Date.now()
|
|
24440
|
+
}, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId);
|
|
24441
|
+
} else {
|
|
24442
|
+
await (capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(errorResponse));
|
|
24443
|
+
}
|
|
24444
|
+
}).catch((error2) => this._onerror(new Error(`Failed to send response: ${error2}`))).finally(() => {
|
|
23861
24445
|
this._requestHandlerAbortControllers.delete(request.id);
|
|
23862
24446
|
});
|
|
23863
24447
|
}
|
|
@@ -23874,8 +24458,11 @@ var Protocol = class {
|
|
|
23874
24458
|
if (timeoutInfo && responseHandler && timeoutInfo.resetTimeoutOnProgress) {
|
|
23875
24459
|
try {
|
|
23876
24460
|
this._resetTimeout(messageId);
|
|
23877
|
-
} catch (
|
|
23878
|
-
|
|
24461
|
+
} catch (error2) {
|
|
24462
|
+
this._responseHandlers.delete(messageId);
|
|
24463
|
+
this._progressHandlers.delete(messageId);
|
|
24464
|
+
this._cleanupTimeout(messageId);
|
|
24465
|
+
responseHandler(error2);
|
|
23879
24466
|
return;
|
|
23880
24467
|
}
|
|
23881
24468
|
}
|
|
@@ -23883,19 +24470,43 @@ var Protocol = class {
|
|
|
23883
24470
|
}
|
|
23884
24471
|
_onresponse(response) {
|
|
23885
24472
|
const messageId = Number(response.id);
|
|
24473
|
+
const resolver = this._requestResolvers.get(messageId);
|
|
24474
|
+
if (resolver) {
|
|
24475
|
+
this._requestResolvers.delete(messageId);
|
|
24476
|
+
if (isJSONRPCResponse(response)) {
|
|
24477
|
+
resolver(response);
|
|
24478
|
+
} else {
|
|
24479
|
+
const error2 = new McpError(response.error.code, response.error.message, response.error.data);
|
|
24480
|
+
resolver(error2);
|
|
24481
|
+
}
|
|
24482
|
+
return;
|
|
24483
|
+
}
|
|
23886
24484
|
const handler = this._responseHandlers.get(messageId);
|
|
23887
24485
|
if (handler === void 0) {
|
|
23888
24486
|
this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(response)}`));
|
|
23889
24487
|
return;
|
|
23890
24488
|
}
|
|
23891
24489
|
this._responseHandlers.delete(messageId);
|
|
23892
|
-
this._progressHandlers.delete(messageId);
|
|
23893
24490
|
this._cleanupTimeout(messageId);
|
|
24491
|
+
let isTaskResponse = false;
|
|
24492
|
+
if (isJSONRPCResponse(response) && response.result && typeof response.result === "object") {
|
|
24493
|
+
const result = response.result;
|
|
24494
|
+
if (result.task && typeof result.task === "object") {
|
|
24495
|
+
const task = result.task;
|
|
24496
|
+
if (typeof task.taskId === "string") {
|
|
24497
|
+
isTaskResponse = true;
|
|
24498
|
+
this._taskProgressTokens.set(task.taskId, messageId);
|
|
24499
|
+
}
|
|
24500
|
+
}
|
|
24501
|
+
}
|
|
24502
|
+
if (!isTaskResponse) {
|
|
24503
|
+
this._progressHandlers.delete(messageId);
|
|
24504
|
+
}
|
|
23894
24505
|
if (isJSONRPCResponse(response)) {
|
|
23895
24506
|
handler(response);
|
|
23896
24507
|
} else {
|
|
23897
|
-
const
|
|
23898
|
-
handler(
|
|
24508
|
+
const error2 = McpError.fromError(response.error.code, response.error.message, response.error.data);
|
|
24509
|
+
handler(error2);
|
|
23899
24510
|
}
|
|
23900
24511
|
}
|
|
23901
24512
|
get transport() {
|
|
@@ -23909,22 +24520,120 @@ var Protocol = class {
|
|
|
23909
24520
|
await ((_a = this._transport) === null || _a === void 0 ? void 0 : _a.close());
|
|
23910
24521
|
}
|
|
23911
24522
|
/**
|
|
23912
|
-
* Sends a request and
|
|
24523
|
+
* Sends a request and returns an AsyncGenerator that yields response messages.
|
|
24524
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
23913
24525
|
*
|
|
23914
|
-
*
|
|
24526
|
+
* @example
|
|
24527
|
+
* ```typescript
|
|
24528
|
+
* const stream = protocol.requestStream(request, resultSchema, options);
|
|
24529
|
+
* for await (const message of stream) {
|
|
24530
|
+
* switch (message.type) {
|
|
24531
|
+
* case 'taskCreated':
|
|
24532
|
+
* console.log('Task created:', message.task.taskId);
|
|
24533
|
+
* break;
|
|
24534
|
+
* case 'taskStatus':
|
|
24535
|
+
* console.log('Task status:', message.task.status);
|
|
24536
|
+
* break;
|
|
24537
|
+
* case 'result':
|
|
24538
|
+
* console.log('Final result:', message.result);
|
|
24539
|
+
* break;
|
|
24540
|
+
* case 'error':
|
|
24541
|
+
* console.error('Error:', message.error);
|
|
24542
|
+
* break;
|
|
24543
|
+
* }
|
|
24544
|
+
* }
|
|
24545
|
+
* ```
|
|
24546
|
+
*
|
|
24547
|
+
* @experimental Use `client.experimental.tasks.requestStream()` to access this method.
|
|
23915
24548
|
*/
|
|
23916
|
-
|
|
23917
|
-
|
|
23918
|
-
|
|
23919
|
-
|
|
23920
|
-
|
|
23921
|
-
|
|
23922
|
-
|
|
24549
|
+
async *requestStream(request, resultSchema, options) {
|
|
24550
|
+
var _a, _b, _c, _d;
|
|
24551
|
+
const { task } = options !== null && options !== void 0 ? options : {};
|
|
24552
|
+
if (!task) {
|
|
24553
|
+
try {
|
|
24554
|
+
const result = await this.request(request, resultSchema, options);
|
|
24555
|
+
yield { type: "result", result };
|
|
24556
|
+
} catch (error2) {
|
|
24557
|
+
yield {
|
|
24558
|
+
type: "error",
|
|
24559
|
+
error: error2 instanceof McpError ? error2 : new McpError(ErrorCode.InternalError, String(error2))
|
|
24560
|
+
};
|
|
23923
24561
|
}
|
|
23924
|
-
|
|
23925
|
-
|
|
24562
|
+
return;
|
|
24563
|
+
}
|
|
24564
|
+
let taskId;
|
|
24565
|
+
try {
|
|
24566
|
+
const createResult = await this.request(request, CreateTaskResultSchema, options);
|
|
24567
|
+
if (createResult.task) {
|
|
24568
|
+
taskId = createResult.task.taskId;
|
|
24569
|
+
yield { type: "taskCreated", task: createResult.task };
|
|
24570
|
+
} else {
|
|
24571
|
+
throw new McpError(ErrorCode.InternalError, "Task creation did not return a task");
|
|
24572
|
+
}
|
|
24573
|
+
while (true) {
|
|
24574
|
+
const task2 = await this.getTask({ taskId }, options);
|
|
24575
|
+
yield { type: "taskStatus", task: task2 };
|
|
24576
|
+
if (isTerminal(task2.status)) {
|
|
24577
|
+
if (task2.status === "completed") {
|
|
24578
|
+
const result = await this.getTaskResult({ taskId }, resultSchema, options);
|
|
24579
|
+
yield { type: "result", result };
|
|
24580
|
+
} else if (task2.status === "failed") {
|
|
24581
|
+
yield {
|
|
24582
|
+
type: "error",
|
|
24583
|
+
error: new McpError(ErrorCode.InternalError, `Task ${taskId} failed`)
|
|
24584
|
+
};
|
|
24585
|
+
} else if (task2.status === "cancelled") {
|
|
24586
|
+
yield {
|
|
24587
|
+
type: "error",
|
|
24588
|
+
error: new McpError(ErrorCode.InternalError, `Task ${taskId} was cancelled`)
|
|
24589
|
+
};
|
|
24590
|
+
}
|
|
24591
|
+
return;
|
|
24592
|
+
}
|
|
24593
|
+
if (task2.status === "input_required") {
|
|
24594
|
+
const result = await this.getTaskResult({ taskId }, resultSchema, options);
|
|
24595
|
+
yield { type: "result", result };
|
|
24596
|
+
return;
|
|
24597
|
+
}
|
|
24598
|
+
const pollInterval = (_c = (_a = task2.pollInterval) !== null && _a !== void 0 ? _a : (_b = this._options) === null || _b === void 0 ? void 0 : _b.defaultTaskPollInterval) !== null && _c !== void 0 ? _c : 1e3;
|
|
24599
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
24600
|
+
(_d = options === null || options === void 0 ? void 0 : options.signal) === null || _d === void 0 ? void 0 : _d.throwIfAborted();
|
|
23926
24601
|
}
|
|
23927
|
-
|
|
24602
|
+
} catch (error2) {
|
|
24603
|
+
yield {
|
|
24604
|
+
type: "error",
|
|
24605
|
+
error: error2 instanceof McpError ? error2 : new McpError(ErrorCode.InternalError, String(error2))
|
|
24606
|
+
};
|
|
24607
|
+
}
|
|
24608
|
+
}
|
|
24609
|
+
/**
|
|
24610
|
+
* Sends a request and waits for a response.
|
|
24611
|
+
*
|
|
24612
|
+
* Do not use this method to emit notifications! Use notification() instead.
|
|
24613
|
+
*/
|
|
24614
|
+
request(request, resultSchema, options) {
|
|
24615
|
+
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options !== null && options !== void 0 ? options : {};
|
|
24616
|
+
return new Promise((resolve, reject) => {
|
|
24617
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
24618
|
+
const earlyReject = (error2) => {
|
|
24619
|
+
reject(error2);
|
|
24620
|
+
};
|
|
24621
|
+
if (!this._transport) {
|
|
24622
|
+
earlyReject(new Error("Not connected"));
|
|
24623
|
+
return;
|
|
24624
|
+
}
|
|
24625
|
+
if (((_a = this._options) === null || _a === void 0 ? void 0 : _a.enforceStrictCapabilities) === true) {
|
|
24626
|
+
try {
|
|
24627
|
+
this.assertCapabilityForMethod(request.method);
|
|
24628
|
+
if (task) {
|
|
24629
|
+
this.assertTaskCapability(request.method);
|
|
24630
|
+
}
|
|
24631
|
+
} catch (e) {
|
|
24632
|
+
earlyReject(e);
|
|
24633
|
+
return;
|
|
24634
|
+
}
|
|
24635
|
+
}
|
|
24636
|
+
(_b = options === null || options === void 0 ? void 0 : options.signal) === null || _b === void 0 ? void 0 : _b.throwIfAborted();
|
|
23928
24637
|
const messageId = this._requestMessageId++;
|
|
23929
24638
|
const jsonrpcRequest = {
|
|
23930
24639
|
...request,
|
|
@@ -23941,6 +24650,21 @@ var Protocol = class {
|
|
|
23941
24650
|
}
|
|
23942
24651
|
};
|
|
23943
24652
|
}
|
|
24653
|
+
if (task) {
|
|
24654
|
+
jsonrpcRequest.params = {
|
|
24655
|
+
...jsonrpcRequest.params,
|
|
24656
|
+
task
|
|
24657
|
+
};
|
|
24658
|
+
}
|
|
24659
|
+
if (relatedTask) {
|
|
24660
|
+
jsonrpcRequest.params = {
|
|
24661
|
+
...jsonrpcRequest.params,
|
|
24662
|
+
_meta: {
|
|
24663
|
+
...((_d = jsonrpcRequest.params) === null || _d === void 0 ? void 0 : _d._meta) || {},
|
|
24664
|
+
[RELATED_TASK_META_KEY]: relatedTask
|
|
24665
|
+
}
|
|
24666
|
+
};
|
|
24667
|
+
}
|
|
23944
24668
|
const cancel = (reason) => {
|
|
23945
24669
|
var _a2;
|
|
23946
24670
|
this._responseHandlers.delete(messageId);
|
|
@@ -23953,8 +24677,9 @@ var Protocol = class {
|
|
|
23953
24677
|
requestId: messageId,
|
|
23954
24678
|
reason: String(reason)
|
|
23955
24679
|
}
|
|
23956
|
-
}, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((
|
|
23957
|
-
|
|
24680
|
+
}, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error3) => this._onerror(new Error(`Failed to send cancellation: ${error3}`)));
|
|
24681
|
+
const error2 = reason instanceof McpError ? reason : new McpError(ErrorCode.RequestTimeout, String(reason));
|
|
24682
|
+
reject(error2);
|
|
23958
24683
|
};
|
|
23959
24684
|
this._responseHandlers.set(messageId, (response) => {
|
|
23960
24685
|
var _a2;
|
|
@@ -23971,57 +24696,154 @@ var Protocol = class {
|
|
|
23971
24696
|
} else {
|
|
23972
24697
|
resolve(parseResult.data);
|
|
23973
24698
|
}
|
|
23974
|
-
} catch (
|
|
23975
|
-
reject(
|
|
24699
|
+
} catch (error2) {
|
|
24700
|
+
reject(error2);
|
|
23976
24701
|
}
|
|
23977
24702
|
});
|
|
23978
|
-
(
|
|
24703
|
+
(_e = options === null || options === void 0 ? void 0 : options.signal) === null || _e === void 0 ? void 0 : _e.addEventListener("abort", () => {
|
|
23979
24704
|
var _a2;
|
|
23980
24705
|
cancel((_a2 = options === null || options === void 0 ? void 0 : options.signal) === null || _a2 === void 0 ? void 0 : _a2.reason);
|
|
23981
24706
|
});
|
|
23982
|
-
const timeout = (
|
|
24707
|
+
const timeout = (_f = options === null || options === void 0 ? void 0 : options.timeout) !== null && _f !== void 0 ? _f : DEFAULT_REQUEST_TIMEOUT_MSEC;
|
|
23983
24708
|
const timeoutHandler = () => cancel(McpError.fromError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
|
|
23984
|
-
this._setupTimeout(messageId, timeout, options === null || options === void 0 ? void 0 : options.maxTotalTimeout, timeoutHandler, (
|
|
23985
|
-
|
|
23986
|
-
|
|
23987
|
-
|
|
23988
|
-
|
|
24709
|
+
this._setupTimeout(messageId, timeout, options === null || options === void 0 ? void 0 : options.maxTotalTimeout, timeoutHandler, (_g = options === null || options === void 0 ? void 0 : options.resetTimeoutOnProgress) !== null && _g !== void 0 ? _g : false);
|
|
24710
|
+
const relatedTaskId = relatedTask === null || relatedTask === void 0 ? void 0 : relatedTask.taskId;
|
|
24711
|
+
if (relatedTaskId) {
|
|
24712
|
+
const responseResolver = (response) => {
|
|
24713
|
+
const handler = this._responseHandlers.get(messageId);
|
|
24714
|
+
if (handler) {
|
|
24715
|
+
handler(response);
|
|
24716
|
+
} else {
|
|
24717
|
+
this._onerror(new Error(`Response handler missing for side-channeled request ${messageId}`));
|
|
24718
|
+
}
|
|
24719
|
+
};
|
|
24720
|
+
this._requestResolvers.set(messageId, responseResolver);
|
|
24721
|
+
this._enqueueTaskMessage(relatedTaskId, {
|
|
24722
|
+
type: "request",
|
|
24723
|
+
message: jsonrpcRequest,
|
|
24724
|
+
timestamp: Date.now()
|
|
24725
|
+
}).catch((error2) => {
|
|
24726
|
+
this._cleanupTimeout(messageId);
|
|
24727
|
+
reject(error2);
|
|
24728
|
+
});
|
|
24729
|
+
} else {
|
|
24730
|
+
this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error2) => {
|
|
24731
|
+
this._cleanupTimeout(messageId);
|
|
24732
|
+
reject(error2);
|
|
24733
|
+
});
|
|
24734
|
+
}
|
|
23989
24735
|
});
|
|
23990
24736
|
}
|
|
24737
|
+
/**
|
|
24738
|
+
* Gets the current status of a task.
|
|
24739
|
+
*
|
|
24740
|
+
* @experimental Use `client.experimental.tasks.getTask()` to access this method.
|
|
24741
|
+
*/
|
|
24742
|
+
async getTask(params, options) {
|
|
24743
|
+
return this.request({ method: "tasks/get", params }, GetTaskResultSchema, options);
|
|
24744
|
+
}
|
|
24745
|
+
/**
|
|
24746
|
+
* Retrieves the result of a completed task.
|
|
24747
|
+
*
|
|
24748
|
+
* @experimental Use `client.experimental.tasks.getTaskResult()` to access this method.
|
|
24749
|
+
*/
|
|
24750
|
+
async getTaskResult(params, resultSchema, options) {
|
|
24751
|
+
return this.request({ method: "tasks/result", params }, resultSchema, options);
|
|
24752
|
+
}
|
|
24753
|
+
/**
|
|
24754
|
+
* Lists tasks, optionally starting from a pagination cursor.
|
|
24755
|
+
*
|
|
24756
|
+
* @experimental Use `client.experimental.tasks.listTasks()` to access this method.
|
|
24757
|
+
*/
|
|
24758
|
+
async listTasks(params, options) {
|
|
24759
|
+
return this.request({ method: "tasks/list", params }, ListTasksResultSchema, options);
|
|
24760
|
+
}
|
|
24761
|
+
/**
|
|
24762
|
+
* Cancels a specific task.
|
|
24763
|
+
*
|
|
24764
|
+
* @experimental Use `client.experimental.tasks.cancelTask()` to access this method.
|
|
24765
|
+
*/
|
|
24766
|
+
async cancelTask(params, options) {
|
|
24767
|
+
return this.request({ method: "tasks/cancel", params }, CancelTaskResultSchema, options);
|
|
24768
|
+
}
|
|
23991
24769
|
/**
|
|
23992
24770
|
* Emits a notification, which is a one-way message that does not expect a response.
|
|
23993
24771
|
*/
|
|
23994
24772
|
async notification(notification, options) {
|
|
23995
|
-
var _a, _b;
|
|
24773
|
+
var _a, _b, _c, _d, _e;
|
|
23996
24774
|
if (!this._transport) {
|
|
23997
24775
|
throw new Error("Not connected");
|
|
23998
24776
|
}
|
|
23999
24777
|
this.assertNotificationCapability(notification.method);
|
|
24000
|
-
const
|
|
24001
|
-
|
|
24778
|
+
const relatedTaskId = (_a = options === null || options === void 0 ? void 0 : options.relatedTask) === null || _a === void 0 ? void 0 : _a.taskId;
|
|
24779
|
+
if (relatedTaskId) {
|
|
24780
|
+
const jsonrpcNotification2 = {
|
|
24781
|
+
...notification,
|
|
24782
|
+
jsonrpc: "2.0",
|
|
24783
|
+
params: {
|
|
24784
|
+
...notification.params,
|
|
24785
|
+
_meta: {
|
|
24786
|
+
...((_b = notification.params) === null || _b === void 0 ? void 0 : _b._meta) || {},
|
|
24787
|
+
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
24788
|
+
}
|
|
24789
|
+
}
|
|
24790
|
+
};
|
|
24791
|
+
await this._enqueueTaskMessage(relatedTaskId, {
|
|
24792
|
+
type: "notification",
|
|
24793
|
+
message: jsonrpcNotification2,
|
|
24794
|
+
timestamp: Date.now()
|
|
24795
|
+
});
|
|
24796
|
+
return;
|
|
24797
|
+
}
|
|
24798
|
+
const debouncedMethods = (_d = (_c = this._options) === null || _c === void 0 ? void 0 : _c.debouncedNotificationMethods) !== null && _d !== void 0 ? _d : [];
|
|
24799
|
+
const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !(options === null || options === void 0 ? void 0 : options.relatedRequestId) && !(options === null || options === void 0 ? void 0 : options.relatedTask);
|
|
24002
24800
|
if (canDebounce) {
|
|
24003
24801
|
if (this._pendingDebouncedNotifications.has(notification.method)) {
|
|
24004
24802
|
return;
|
|
24005
24803
|
}
|
|
24006
24804
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
24007
24805
|
Promise.resolve().then(() => {
|
|
24008
|
-
var _a2;
|
|
24806
|
+
var _a2, _b2;
|
|
24009
24807
|
this._pendingDebouncedNotifications.delete(notification.method);
|
|
24010
24808
|
if (!this._transport) {
|
|
24011
24809
|
return;
|
|
24012
24810
|
}
|
|
24013
|
-
|
|
24811
|
+
let jsonrpcNotification2 = {
|
|
24014
24812
|
...notification,
|
|
24015
24813
|
jsonrpc: "2.0"
|
|
24016
24814
|
};
|
|
24017
|
-
(
|
|
24815
|
+
if (options === null || options === void 0 ? void 0 : options.relatedTask) {
|
|
24816
|
+
jsonrpcNotification2 = {
|
|
24817
|
+
...jsonrpcNotification2,
|
|
24818
|
+
params: {
|
|
24819
|
+
...jsonrpcNotification2.params,
|
|
24820
|
+
_meta: {
|
|
24821
|
+
...((_a2 = jsonrpcNotification2.params) === null || _a2 === void 0 ? void 0 : _a2._meta) || {},
|
|
24822
|
+
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
24823
|
+
}
|
|
24824
|
+
}
|
|
24825
|
+
};
|
|
24826
|
+
}
|
|
24827
|
+
(_b2 = this._transport) === null || _b2 === void 0 ? void 0 : _b2.send(jsonrpcNotification2, options).catch((error2) => this._onerror(error2));
|
|
24018
24828
|
});
|
|
24019
24829
|
return;
|
|
24020
24830
|
}
|
|
24021
|
-
|
|
24831
|
+
let jsonrpcNotification = {
|
|
24022
24832
|
...notification,
|
|
24023
24833
|
jsonrpc: "2.0"
|
|
24024
24834
|
};
|
|
24835
|
+
if (options === null || options === void 0 ? void 0 : options.relatedTask) {
|
|
24836
|
+
jsonrpcNotification = {
|
|
24837
|
+
...jsonrpcNotification,
|
|
24838
|
+
params: {
|
|
24839
|
+
...jsonrpcNotification.params,
|
|
24840
|
+
_meta: {
|
|
24841
|
+
...((_e = jsonrpcNotification.params) === null || _e === void 0 ? void 0 : _e._meta) || {},
|
|
24842
|
+
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
24843
|
+
}
|
|
24844
|
+
}
|
|
24845
|
+
};
|
|
24846
|
+
}
|
|
24025
24847
|
await this._transport.send(jsonrpcNotification, options);
|
|
24026
24848
|
}
|
|
24027
24849
|
/**
|
|
@@ -24069,6 +24891,152 @@ var Protocol = class {
|
|
|
24069
24891
|
removeNotificationHandler(method) {
|
|
24070
24892
|
this._notificationHandlers.delete(method);
|
|
24071
24893
|
}
|
|
24894
|
+
/**
|
|
24895
|
+
* Cleans up the progress handler associated with a task.
|
|
24896
|
+
* This should be called when a task reaches a terminal status.
|
|
24897
|
+
*/
|
|
24898
|
+
_cleanupTaskProgressHandler(taskId) {
|
|
24899
|
+
const progressToken = this._taskProgressTokens.get(taskId);
|
|
24900
|
+
if (progressToken !== void 0) {
|
|
24901
|
+
this._progressHandlers.delete(progressToken);
|
|
24902
|
+
this._taskProgressTokens.delete(taskId);
|
|
24903
|
+
}
|
|
24904
|
+
}
|
|
24905
|
+
/**
|
|
24906
|
+
* Enqueues a task-related message for side-channel delivery via tasks/result.
|
|
24907
|
+
* @param taskId The task ID to associate the message with
|
|
24908
|
+
* @param message The message to enqueue
|
|
24909
|
+
* @param sessionId Optional session ID for binding the operation to a specific session
|
|
24910
|
+
* @throws Error if taskStore is not configured or if enqueue fails (e.g., queue overflow)
|
|
24911
|
+
*
|
|
24912
|
+
* Note: If enqueue fails, it's the TaskMessageQueue implementation's responsibility to handle
|
|
24913
|
+
* the error appropriately (e.g., by failing the task, logging, etc.). The Protocol layer
|
|
24914
|
+
* simply propagates the error.
|
|
24915
|
+
*/
|
|
24916
|
+
async _enqueueTaskMessage(taskId, message, sessionId) {
|
|
24917
|
+
var _a;
|
|
24918
|
+
if (!this._taskStore || !this._taskMessageQueue) {
|
|
24919
|
+
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
24920
|
+
}
|
|
24921
|
+
const maxQueueSize = (_a = this._options) === null || _a === void 0 ? void 0 : _a.maxTaskQueueSize;
|
|
24922
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
24923
|
+
}
|
|
24924
|
+
/**
|
|
24925
|
+
* Clears the message queue for a task and rejects any pending request resolvers.
|
|
24926
|
+
* @param taskId The task ID whose queue should be cleared
|
|
24927
|
+
* @param sessionId Optional session ID for binding the operation to a specific session
|
|
24928
|
+
*/
|
|
24929
|
+
async _clearTaskQueue(taskId, sessionId) {
|
|
24930
|
+
if (this._taskMessageQueue) {
|
|
24931
|
+
const messages = await this._taskMessageQueue.dequeueAll(taskId, sessionId);
|
|
24932
|
+
for (const message of messages) {
|
|
24933
|
+
if (message.type === "request" && isJSONRPCRequest(message.message)) {
|
|
24934
|
+
const requestId = message.message.id;
|
|
24935
|
+
const resolver = this._requestResolvers.get(requestId);
|
|
24936
|
+
if (resolver) {
|
|
24937
|
+
resolver(new McpError(ErrorCode.InternalError, "Task cancelled or completed"));
|
|
24938
|
+
this._requestResolvers.delete(requestId);
|
|
24939
|
+
} else {
|
|
24940
|
+
this._onerror(new Error(`Resolver missing for request ${requestId} during task ${taskId} cleanup`));
|
|
24941
|
+
}
|
|
24942
|
+
}
|
|
24943
|
+
}
|
|
24944
|
+
}
|
|
24945
|
+
}
|
|
24946
|
+
/**
|
|
24947
|
+
* Waits for a task update (new messages or status change) with abort signal support.
|
|
24948
|
+
* Uses polling to check for updates at the task's configured poll interval.
|
|
24949
|
+
* @param taskId The task ID to wait for
|
|
24950
|
+
* @param signal Abort signal to cancel the wait
|
|
24951
|
+
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
24952
|
+
*/
|
|
24953
|
+
async _waitForTaskUpdate(taskId, signal) {
|
|
24954
|
+
var _a, _b, _c;
|
|
24955
|
+
let interval = (_b = (_a = this._options) === null || _a === void 0 ? void 0 : _a.defaultTaskPollInterval) !== null && _b !== void 0 ? _b : 1e3;
|
|
24956
|
+
try {
|
|
24957
|
+
const task = await ((_c = this._taskStore) === null || _c === void 0 ? void 0 : _c.getTask(taskId));
|
|
24958
|
+
if (task === null || task === void 0 ? void 0 : task.pollInterval) {
|
|
24959
|
+
interval = task.pollInterval;
|
|
24960
|
+
}
|
|
24961
|
+
} catch (_d) {
|
|
24962
|
+
}
|
|
24963
|
+
return new Promise((resolve, reject) => {
|
|
24964
|
+
if (signal.aborted) {
|
|
24965
|
+
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
24966
|
+
return;
|
|
24967
|
+
}
|
|
24968
|
+
const timeoutId = setTimeout(resolve, interval);
|
|
24969
|
+
signal.addEventListener("abort", () => {
|
|
24970
|
+
clearTimeout(timeoutId);
|
|
24971
|
+
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
24972
|
+
}, { once: true });
|
|
24973
|
+
});
|
|
24974
|
+
}
|
|
24975
|
+
requestTaskStore(request, sessionId) {
|
|
24976
|
+
const taskStore = this._taskStore;
|
|
24977
|
+
if (!taskStore) {
|
|
24978
|
+
throw new Error("No task store configured");
|
|
24979
|
+
}
|
|
24980
|
+
return {
|
|
24981
|
+
createTask: async (taskParams) => {
|
|
24982
|
+
if (!request) {
|
|
24983
|
+
throw new Error("No request provided");
|
|
24984
|
+
}
|
|
24985
|
+
return await taskStore.createTask(taskParams, request.id, {
|
|
24986
|
+
method: request.method,
|
|
24987
|
+
params: request.params
|
|
24988
|
+
}, sessionId);
|
|
24989
|
+
},
|
|
24990
|
+
getTask: async (taskId) => {
|
|
24991
|
+
const task = await taskStore.getTask(taskId, sessionId);
|
|
24992
|
+
if (!task) {
|
|
24993
|
+
throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
|
|
24994
|
+
}
|
|
24995
|
+
return task;
|
|
24996
|
+
},
|
|
24997
|
+
storeTaskResult: async (taskId, status, result) => {
|
|
24998
|
+
await taskStore.storeTaskResult(taskId, status, result, sessionId);
|
|
24999
|
+
const task = await taskStore.getTask(taskId, sessionId);
|
|
25000
|
+
if (task) {
|
|
25001
|
+
const notification = TaskStatusNotificationSchema.parse({
|
|
25002
|
+
method: "notifications/tasks/status",
|
|
25003
|
+
params: task
|
|
25004
|
+
});
|
|
25005
|
+
await this.notification(notification);
|
|
25006
|
+
if (isTerminal(task.status)) {
|
|
25007
|
+
this._cleanupTaskProgressHandler(taskId);
|
|
25008
|
+
}
|
|
25009
|
+
}
|
|
25010
|
+
},
|
|
25011
|
+
getTaskResult: (taskId) => {
|
|
25012
|
+
return taskStore.getTaskResult(taskId, sessionId);
|
|
25013
|
+
},
|
|
25014
|
+
updateTaskStatus: async (taskId, status, statusMessage) => {
|
|
25015
|
+
const task = await taskStore.getTask(taskId, sessionId);
|
|
25016
|
+
if (!task) {
|
|
25017
|
+
throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" not found - it may have been cleaned up`);
|
|
25018
|
+
}
|
|
25019
|
+
if (isTerminal(task.status)) {
|
|
25020
|
+
throw new McpError(ErrorCode.InvalidParams, `Cannot update task "${taskId}" from terminal status "${task.status}" to "${status}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);
|
|
25021
|
+
}
|
|
25022
|
+
await taskStore.updateTaskStatus(taskId, status, statusMessage, sessionId);
|
|
25023
|
+
const updatedTask = await taskStore.getTask(taskId, sessionId);
|
|
25024
|
+
if (updatedTask) {
|
|
25025
|
+
const notification = TaskStatusNotificationSchema.parse({
|
|
25026
|
+
method: "notifications/tasks/status",
|
|
25027
|
+
params: updatedTask
|
|
25028
|
+
});
|
|
25029
|
+
await this.notification(notification);
|
|
25030
|
+
if (isTerminal(updatedTask.status)) {
|
|
25031
|
+
this._cleanupTaskProgressHandler(taskId);
|
|
25032
|
+
}
|
|
25033
|
+
}
|
|
25034
|
+
},
|
|
25035
|
+
listTasks: (cursor) => {
|
|
25036
|
+
return taskStore.listTasks(cursor, sessionId);
|
|
25037
|
+
}
|
|
25038
|
+
};
|
|
25039
|
+
}
|
|
24072
25040
|
};
|
|
24073
25041
|
function isPlainObject2(value) {
|
|
24074
25042
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -24159,6 +25127,115 @@ var AjvJsonSchemaValidator = class {
|
|
|
24159
25127
|
}
|
|
24160
25128
|
};
|
|
24161
25129
|
|
|
25130
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
|
|
25131
|
+
var ExperimentalServerTasks = class {
|
|
25132
|
+
constructor(_server) {
|
|
25133
|
+
this._server = _server;
|
|
25134
|
+
}
|
|
25135
|
+
/**
|
|
25136
|
+
* Sends a request and returns an AsyncGenerator that yields response messages.
|
|
25137
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
25138
|
+
*
|
|
25139
|
+
* This method provides streaming access to request processing, allowing you to
|
|
25140
|
+
* observe intermediate task status updates for task-augmented requests.
|
|
25141
|
+
*
|
|
25142
|
+
* @param request - The request to send
|
|
25143
|
+
* @param resultSchema - Zod schema for validating the result
|
|
25144
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
25145
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
25146
|
+
*
|
|
25147
|
+
* @experimental
|
|
25148
|
+
*/
|
|
25149
|
+
requestStream(request, resultSchema, options) {
|
|
25150
|
+
return this._server.requestStream(request, resultSchema, options);
|
|
25151
|
+
}
|
|
25152
|
+
/**
|
|
25153
|
+
* Gets the current status of a task.
|
|
25154
|
+
*
|
|
25155
|
+
* @param taskId - The task identifier
|
|
25156
|
+
* @param options - Optional request options
|
|
25157
|
+
* @returns The task status
|
|
25158
|
+
*
|
|
25159
|
+
* @experimental
|
|
25160
|
+
*/
|
|
25161
|
+
async getTask(taskId, options) {
|
|
25162
|
+
return this._server.getTask({ taskId }, options);
|
|
25163
|
+
}
|
|
25164
|
+
/**
|
|
25165
|
+
* Retrieves the result of a completed task.
|
|
25166
|
+
*
|
|
25167
|
+
* @param taskId - The task identifier
|
|
25168
|
+
* @param resultSchema - Zod schema for validating the result
|
|
25169
|
+
* @param options - Optional request options
|
|
25170
|
+
* @returns The task result
|
|
25171
|
+
*
|
|
25172
|
+
* @experimental
|
|
25173
|
+
*/
|
|
25174
|
+
async getTaskResult(taskId, resultSchema, options) {
|
|
25175
|
+
return this._server.getTaskResult({ taskId }, resultSchema, options);
|
|
25176
|
+
}
|
|
25177
|
+
/**
|
|
25178
|
+
* Lists tasks with optional pagination.
|
|
25179
|
+
*
|
|
25180
|
+
* @param cursor - Optional pagination cursor
|
|
25181
|
+
* @param options - Optional request options
|
|
25182
|
+
* @returns List of tasks with optional next cursor
|
|
25183
|
+
*
|
|
25184
|
+
* @experimental
|
|
25185
|
+
*/
|
|
25186
|
+
async listTasks(cursor, options) {
|
|
25187
|
+
return this._server.listTasks(cursor ? { cursor } : void 0, options);
|
|
25188
|
+
}
|
|
25189
|
+
/**
|
|
25190
|
+
* Cancels a running task.
|
|
25191
|
+
*
|
|
25192
|
+
* @param taskId - The task identifier
|
|
25193
|
+
* @param options - Optional request options
|
|
25194
|
+
*
|
|
25195
|
+
* @experimental
|
|
25196
|
+
*/
|
|
25197
|
+
async cancelTask(taskId, options) {
|
|
25198
|
+
return this._server.cancelTask({ taskId }, options);
|
|
25199
|
+
}
|
|
25200
|
+
};
|
|
25201
|
+
|
|
25202
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
25203
|
+
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
25204
|
+
var _a;
|
|
25205
|
+
if (!requests) {
|
|
25206
|
+
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
25207
|
+
}
|
|
25208
|
+
switch (method) {
|
|
25209
|
+
case "tools/call":
|
|
25210
|
+
if (!((_a = requests.tools) === null || _a === void 0 ? void 0 : _a.call)) {
|
|
25211
|
+
throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
|
|
25212
|
+
}
|
|
25213
|
+
break;
|
|
25214
|
+
default:
|
|
25215
|
+
break;
|
|
25216
|
+
}
|
|
25217
|
+
}
|
|
25218
|
+
function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
25219
|
+
var _a, _b;
|
|
25220
|
+
if (!requests) {
|
|
25221
|
+
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
25222
|
+
}
|
|
25223
|
+
switch (method) {
|
|
25224
|
+
case "sampling/createMessage":
|
|
25225
|
+
if (!((_a = requests.sampling) === null || _a === void 0 ? void 0 : _a.createMessage)) {
|
|
25226
|
+
throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
|
|
25227
|
+
}
|
|
25228
|
+
break;
|
|
25229
|
+
case "elicitation/create":
|
|
25230
|
+
if (!((_b = requests.elicitation) === null || _b === void 0 ? void 0 : _b.create)) {
|
|
25231
|
+
throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
|
|
25232
|
+
}
|
|
25233
|
+
break;
|
|
25234
|
+
default:
|
|
25235
|
+
break;
|
|
25236
|
+
}
|
|
25237
|
+
}
|
|
25238
|
+
|
|
24162
25239
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
24163
25240
|
var Server = class extends Protocol {
|
|
24164
25241
|
/**
|
|
@@ -24195,6 +25272,21 @@ var Server = class extends Protocol {
|
|
|
24195
25272
|
});
|
|
24196
25273
|
}
|
|
24197
25274
|
}
|
|
25275
|
+
/**
|
|
25276
|
+
* Access experimental features.
|
|
25277
|
+
*
|
|
25278
|
+
* WARNING: These APIs are experimental and may change without notice.
|
|
25279
|
+
*
|
|
25280
|
+
* @experimental
|
|
25281
|
+
*/
|
|
25282
|
+
get experimental() {
|
|
25283
|
+
if (!this._experimental) {
|
|
25284
|
+
this._experimental = {
|
|
25285
|
+
tasks: new ExperimentalServerTasks(this)
|
|
25286
|
+
};
|
|
25287
|
+
}
|
|
25288
|
+
return this._experimental;
|
|
25289
|
+
}
|
|
24198
25290
|
/**
|
|
24199
25291
|
* Registers new capabilities. This can only be called before connecting to a transport.
|
|
24200
25292
|
*
|
|
@@ -24206,6 +25298,58 @@ var Server = class extends Protocol {
|
|
|
24206
25298
|
}
|
|
24207
25299
|
this._capabilities = mergeCapabilities(this._capabilities, capabilities);
|
|
24208
25300
|
}
|
|
25301
|
+
/**
|
|
25302
|
+
* Override request handler registration to enforce server-side validation for tools/call.
|
|
25303
|
+
*/
|
|
25304
|
+
setRequestHandler(requestSchema, handler) {
|
|
25305
|
+
var _a, _b, _c;
|
|
25306
|
+
const shape = getObjectShape(requestSchema);
|
|
25307
|
+
const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
|
|
25308
|
+
if (!methodSchema) {
|
|
25309
|
+
throw new Error("Schema is missing a method literal");
|
|
25310
|
+
}
|
|
25311
|
+
let methodValue;
|
|
25312
|
+
if (isZ4Schema(methodSchema)) {
|
|
25313
|
+
const v4Schema = methodSchema;
|
|
25314
|
+
const v4Def = (_a = v4Schema._zod) === null || _a === void 0 ? void 0 : _a.def;
|
|
25315
|
+
methodValue = (_b = v4Def === null || v4Def === void 0 ? void 0 : v4Def.value) !== null && _b !== void 0 ? _b : v4Schema.value;
|
|
25316
|
+
} else {
|
|
25317
|
+
const v3Schema = methodSchema;
|
|
25318
|
+
const legacyDef = v3Schema._def;
|
|
25319
|
+
methodValue = (_c = legacyDef === null || legacyDef === void 0 ? void 0 : legacyDef.value) !== null && _c !== void 0 ? _c : v3Schema.value;
|
|
25320
|
+
}
|
|
25321
|
+
if (typeof methodValue !== "string") {
|
|
25322
|
+
throw new Error("Schema method literal must be a string");
|
|
25323
|
+
}
|
|
25324
|
+
const method = methodValue;
|
|
25325
|
+
if (method === "tools/call") {
|
|
25326
|
+
const wrappedHandler = async (request, extra) => {
|
|
25327
|
+
const validatedRequest = safeParse3(CallToolRequestSchema, request);
|
|
25328
|
+
if (!validatedRequest.success) {
|
|
25329
|
+
const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
|
|
25330
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage}`);
|
|
25331
|
+
}
|
|
25332
|
+
const { params } = validatedRequest.data;
|
|
25333
|
+
const result = await Promise.resolve(handler(request, extra));
|
|
25334
|
+
if (params.task) {
|
|
25335
|
+
const taskValidationResult = safeParse3(CreateTaskResultSchema, result);
|
|
25336
|
+
if (!taskValidationResult.success) {
|
|
25337
|
+
const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
|
|
25338
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
|
|
25339
|
+
}
|
|
25340
|
+
return taskValidationResult.data;
|
|
25341
|
+
}
|
|
25342
|
+
const validationResult = safeParse3(CallToolResultSchema, result);
|
|
25343
|
+
if (!validationResult.success) {
|
|
25344
|
+
const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
|
|
25345
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${errorMessage}`);
|
|
25346
|
+
}
|
|
25347
|
+
return validationResult.data;
|
|
25348
|
+
};
|
|
25349
|
+
return super.setRequestHandler(requestSchema, wrappedHandler);
|
|
25350
|
+
}
|
|
25351
|
+
return super.setRequestHandler(requestSchema, handler);
|
|
25352
|
+
}
|
|
24209
25353
|
assertCapabilityForMethod(method) {
|
|
24210
25354
|
var _a, _b, _c;
|
|
24211
25355
|
switch (method) {
|
|
@@ -24264,6 +25408,9 @@ var Server = class extends Protocol {
|
|
|
24264
25408
|
}
|
|
24265
25409
|
}
|
|
24266
25410
|
assertRequestHandlerCapability(method) {
|
|
25411
|
+
if (!this._capabilities) {
|
|
25412
|
+
return;
|
|
25413
|
+
}
|
|
24267
25414
|
switch (method) {
|
|
24268
25415
|
case "completion/complete":
|
|
24269
25416
|
if (!this._capabilities.completions) {
|
|
@@ -24294,11 +25441,30 @@ var Server = class extends Protocol {
|
|
|
24294
25441
|
throw new Error(`Server does not support tools (required for ${method})`);
|
|
24295
25442
|
}
|
|
24296
25443
|
break;
|
|
25444
|
+
case "tasks/get":
|
|
25445
|
+
case "tasks/list":
|
|
25446
|
+
case "tasks/result":
|
|
25447
|
+
case "tasks/cancel":
|
|
25448
|
+
if (!this._capabilities.tasks) {
|
|
25449
|
+
throw new Error(`Server does not support tasks capability (required for ${method})`);
|
|
25450
|
+
}
|
|
25451
|
+
break;
|
|
24297
25452
|
case "ping":
|
|
24298
25453
|
case "initialize":
|
|
24299
25454
|
break;
|
|
24300
25455
|
}
|
|
24301
25456
|
}
|
|
25457
|
+
assertTaskCapability(method) {
|
|
25458
|
+
var _a, _b;
|
|
25459
|
+
assertClientRequestTaskCapability((_b = (_a = this._clientCapabilities) === null || _a === void 0 ? void 0 : _a.tasks) === null || _b === void 0 ? void 0 : _b.requests, method, "Client");
|
|
25460
|
+
}
|
|
25461
|
+
assertTaskHandlerCapability(method) {
|
|
25462
|
+
var _a;
|
|
25463
|
+
if (!this._capabilities) {
|
|
25464
|
+
return;
|
|
25465
|
+
}
|
|
25466
|
+
assertToolsCallTaskCapability((_a = this._capabilities.tasks) === null || _a === void 0 ? void 0 : _a.requests, method, "Server");
|
|
25467
|
+
}
|
|
24302
25468
|
async _oninitialize(request) {
|
|
24303
25469
|
const requestedVersion = request.params.protocolVersion;
|
|
24304
25470
|
this._clientCapabilities = request.params.capabilities;
|
|
@@ -24329,6 +25495,7 @@ var Server = class extends Protocol {
|
|
|
24329
25495
|
async ping() {
|
|
24330
25496
|
return this.request({ method: "ping" }, EmptyResultSchema);
|
|
24331
25497
|
}
|
|
25498
|
+
// Implementation
|
|
24332
25499
|
async createMessage(params, options) {
|
|
24333
25500
|
var _a, _b;
|
|
24334
25501
|
if (params.tools || params.toolChoice) {
|
|
@@ -24359,6 +25526,9 @@ var Server = class extends Protocol {
|
|
|
24359
25526
|
}
|
|
24360
25527
|
}
|
|
24361
25528
|
}
|
|
25529
|
+
if (params.tools) {
|
|
25530
|
+
return this.request({ method: "sampling/createMessage", params }, CreateMessageResultWithToolsSchema, options);
|
|
25531
|
+
}
|
|
24362
25532
|
return this.request({ method: "sampling/createMessage", params }, CreateMessageResultSchema, options);
|
|
24363
25533
|
}
|
|
24364
25534
|
/**
|
|
@@ -24392,11 +25562,11 @@ var Server = class extends Protocol {
|
|
|
24392
25562
|
if (!validationResult.valid) {
|
|
24393
25563
|
throw new McpError(ErrorCode.InvalidParams, `Elicitation response content does not match requested schema: ${validationResult.errorMessage}`);
|
|
24394
25564
|
}
|
|
24395
|
-
} catch (
|
|
24396
|
-
if (
|
|
24397
|
-
throw
|
|
25565
|
+
} catch (error2) {
|
|
25566
|
+
if (error2 instanceof McpError) {
|
|
25567
|
+
throw error2;
|
|
24398
25568
|
}
|
|
24399
|
-
throw new McpError(ErrorCode.InternalError, `Error validating elicitation response: ${
|
|
25569
|
+
throw new McpError(ErrorCode.InternalError, `Error validating elicitation response: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
24400
25570
|
}
|
|
24401
25571
|
}
|
|
24402
25572
|
return result;
|
|
@@ -24460,7 +25630,7 @@ var Server = class extends Protocol {
|
|
|
24460
25630
|
};
|
|
24461
25631
|
|
|
24462
25632
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
|
|
24463
|
-
var COMPLETABLE_SYMBOL = Symbol.for("mcp.completable");
|
|
25633
|
+
var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
|
|
24464
25634
|
function isCompletable(schema) {
|
|
24465
25635
|
return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
|
|
24466
25636
|
}
|
|
@@ -24531,6 +25701,21 @@ function validateAndWarnToolName(name) {
|
|
|
24531
25701
|
return result.isValid;
|
|
24532
25702
|
}
|
|
24533
25703
|
|
|
25704
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
|
|
25705
|
+
var ExperimentalMcpServerTasks = class {
|
|
25706
|
+
constructor(_mcpServer) {
|
|
25707
|
+
this._mcpServer = _mcpServer;
|
|
25708
|
+
}
|
|
25709
|
+
registerToolTask(name, config2, handler) {
|
|
25710
|
+
const execution = { taskSupport: "required", ...config2.execution };
|
|
25711
|
+
if (execution.taskSupport === "forbidden") {
|
|
25712
|
+
throw new Error(`Cannot register task-based tool '${name}' with taskSupport 'forbidden'. Use registerTool() instead.`);
|
|
25713
|
+
}
|
|
25714
|
+
const mcpServerInternal = this._mcpServer;
|
|
25715
|
+
return mcpServerInternal._createRegisteredTool(name, config2.title, config2.description, config2.inputSchema, config2.outputSchema, config2.annotations, execution, config2._meta, handler);
|
|
25716
|
+
}
|
|
25717
|
+
};
|
|
25718
|
+
|
|
24534
25719
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
|
|
24535
25720
|
var McpServer = class {
|
|
24536
25721
|
constructor(serverInfo, options) {
|
|
@@ -24544,6 +25729,21 @@ var McpServer = class {
|
|
|
24544
25729
|
this._promptHandlersInitialized = false;
|
|
24545
25730
|
this.server = new Server(serverInfo, options);
|
|
24546
25731
|
}
|
|
25732
|
+
/**
|
|
25733
|
+
* Access experimental features.
|
|
25734
|
+
*
|
|
25735
|
+
* WARNING: These APIs are experimental and may change without notice.
|
|
25736
|
+
*
|
|
25737
|
+
* @experimental
|
|
25738
|
+
*/
|
|
25739
|
+
get experimental() {
|
|
25740
|
+
if (!this._experimental) {
|
|
25741
|
+
this._experimental = {
|
|
25742
|
+
tasks: new ExperimentalMcpServerTasks(this)
|
|
25743
|
+
};
|
|
25744
|
+
}
|
|
25745
|
+
return this._experimental;
|
|
25746
|
+
}
|
|
24547
25747
|
/**
|
|
24548
25748
|
* Attaches to the given transport, starts it, and starts listening for messages.
|
|
24549
25749
|
*
|
|
@@ -24583,6 +25783,7 @@ var McpServer = class {
|
|
|
24583
25783
|
}) : EMPTY_OBJECT_JSON_SCHEMA;
|
|
24584
25784
|
})(),
|
|
24585
25785
|
annotations: tool.annotations,
|
|
25786
|
+
execution: tool.execution,
|
|
24586
25787
|
_meta: tool._meta
|
|
24587
25788
|
};
|
|
24588
25789
|
if (tool.outputSchema) {
|
|
@@ -24598,48 +25799,42 @@ var McpServer = class {
|
|
|
24598
25799
|
})
|
|
24599
25800
|
}));
|
|
24600
25801
|
this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
24601
|
-
|
|
24602
|
-
let result;
|
|
25802
|
+
var _a;
|
|
24603
25803
|
try {
|
|
25804
|
+
const tool = this._registeredTools[request.params.name];
|
|
24604
25805
|
if (!tool) {
|
|
24605
25806
|
throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} not found`);
|
|
24606
25807
|
}
|
|
24607
25808
|
if (!tool.enabled) {
|
|
24608
25809
|
throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
|
|
24609
25810
|
}
|
|
24610
|
-
|
|
24611
|
-
|
|
24612
|
-
|
|
24613
|
-
|
|
24614
|
-
|
|
24615
|
-
if (!parseResult.success) {
|
|
24616
|
-
throw new McpError(ErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${request.params.name}: ${getParseErrorMessage(parseResult.error)}`);
|
|
24617
|
-
}
|
|
24618
|
-
const args = parseResult.data;
|
|
24619
|
-
result = await Promise.resolve(cb(args, extra));
|
|
24620
|
-
} else {
|
|
24621
|
-
const cb = tool.callback;
|
|
24622
|
-
result = await Promise.resolve(cb(extra));
|
|
25811
|
+
const isTaskRequest = !!request.params.task;
|
|
25812
|
+
const taskSupport = (_a = tool.execution) === null || _a === void 0 ? void 0 : _a.taskSupport;
|
|
25813
|
+
const isTaskHandler = "createTask" in tool.handler;
|
|
25814
|
+
if ((taskSupport === "required" || taskSupport === "optional") && !isTaskHandler) {
|
|
25815
|
+
throw new McpError(ErrorCode.InternalError, `Tool ${request.params.name} has taskSupport '${taskSupport}' but was not registered with registerToolTask`);
|
|
24623
25816
|
}
|
|
24624
|
-
if (
|
|
24625
|
-
|
|
24626
|
-
|
|
24627
|
-
|
|
24628
|
-
|
|
24629
|
-
|
|
24630
|
-
|
|
24631
|
-
|
|
24632
|
-
|
|
25817
|
+
if (taskSupport === "required" && !isTaskRequest) {
|
|
25818
|
+
throw new McpError(ErrorCode.MethodNotFound, `Tool ${request.params.name} requires task augmentation (taskSupport: 'required')`);
|
|
25819
|
+
}
|
|
25820
|
+
if (taskSupport === "optional" && !isTaskRequest && isTaskHandler) {
|
|
25821
|
+
return await this.handleAutomaticTaskPolling(tool, request, extra);
|
|
25822
|
+
}
|
|
25823
|
+
const args = await this.validateToolInput(tool, request.params.arguments, request.params.name);
|
|
25824
|
+
const result = await this.executeToolHandler(tool, args, extra);
|
|
25825
|
+
if (isTaskRequest) {
|
|
25826
|
+
return result;
|
|
24633
25827
|
}
|
|
24634
|
-
|
|
24635
|
-
|
|
24636
|
-
|
|
24637
|
-
|
|
25828
|
+
await this.validateToolOutput(tool, result, request.params.name);
|
|
25829
|
+
return result;
|
|
25830
|
+
} catch (error2) {
|
|
25831
|
+
if (error2 instanceof McpError) {
|
|
25832
|
+
if (error2.code === ErrorCode.UrlElicitationRequired) {
|
|
25833
|
+
throw error2;
|
|
24638
25834
|
}
|
|
24639
25835
|
}
|
|
24640
|
-
return this.createToolError(
|
|
25836
|
+
return this.createToolError(error2 instanceof Error ? error2.message : String(error2));
|
|
24641
25837
|
}
|
|
24642
|
-
return result;
|
|
24643
25838
|
});
|
|
24644
25839
|
this._toolHandlersInitialized = true;
|
|
24645
25840
|
}
|
|
@@ -24660,6 +25855,102 @@ var McpServer = class {
|
|
|
24660
25855
|
isError: true
|
|
24661
25856
|
};
|
|
24662
25857
|
}
|
|
25858
|
+
/**
|
|
25859
|
+
* Validates tool input arguments against the tool's input schema.
|
|
25860
|
+
*/
|
|
25861
|
+
async validateToolInput(tool, args, toolName) {
|
|
25862
|
+
if (!tool.inputSchema) {
|
|
25863
|
+
return void 0;
|
|
25864
|
+
}
|
|
25865
|
+
const inputObj = normalizeObjectSchema(tool.inputSchema);
|
|
25866
|
+
const schemaToParse = inputObj !== null && inputObj !== void 0 ? inputObj : tool.inputSchema;
|
|
25867
|
+
const parseResult = await safeParseAsync3(schemaToParse, args);
|
|
25868
|
+
if (!parseResult.success) {
|
|
25869
|
+
const error2 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
25870
|
+
const errorMessage = getParseErrorMessage(error2);
|
|
25871
|
+
throw new McpError(ErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${toolName}: ${errorMessage}`);
|
|
25872
|
+
}
|
|
25873
|
+
return parseResult.data;
|
|
25874
|
+
}
|
|
25875
|
+
/**
|
|
25876
|
+
* Validates tool output against the tool's output schema.
|
|
25877
|
+
*/
|
|
25878
|
+
async validateToolOutput(tool, result, toolName) {
|
|
25879
|
+
if (!tool.outputSchema) {
|
|
25880
|
+
return;
|
|
25881
|
+
}
|
|
25882
|
+
if (!("content" in result)) {
|
|
25883
|
+
return;
|
|
25884
|
+
}
|
|
25885
|
+
if (result.isError) {
|
|
25886
|
+
return;
|
|
25887
|
+
}
|
|
25888
|
+
if (!result.structuredContent) {
|
|
25889
|
+
throw new McpError(ErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`);
|
|
25890
|
+
}
|
|
25891
|
+
const outputObj = normalizeObjectSchema(tool.outputSchema);
|
|
25892
|
+
const parseResult = await safeParseAsync3(outputObj, result.structuredContent);
|
|
25893
|
+
if (!parseResult.success) {
|
|
25894
|
+
const error2 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
25895
|
+
const errorMessage = getParseErrorMessage(error2);
|
|
25896
|
+
throw new McpError(ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${errorMessage}`);
|
|
25897
|
+
}
|
|
25898
|
+
}
|
|
25899
|
+
/**
|
|
25900
|
+
* Executes a tool handler (either regular or task-based).
|
|
25901
|
+
*/
|
|
25902
|
+
async executeToolHandler(tool, args, extra) {
|
|
25903
|
+
const handler = tool.handler;
|
|
25904
|
+
const isTaskHandler = "createTask" in handler;
|
|
25905
|
+
if (isTaskHandler) {
|
|
25906
|
+
if (!extra.taskStore) {
|
|
25907
|
+
throw new Error("No task store provided.");
|
|
25908
|
+
}
|
|
25909
|
+
const taskExtra = { ...extra, taskStore: extra.taskStore };
|
|
25910
|
+
if (tool.inputSchema) {
|
|
25911
|
+
const typedHandler = handler;
|
|
25912
|
+
return await Promise.resolve(typedHandler.createTask(args, taskExtra));
|
|
25913
|
+
} else {
|
|
25914
|
+
const typedHandler = handler;
|
|
25915
|
+
return await Promise.resolve(typedHandler.createTask(taskExtra));
|
|
25916
|
+
}
|
|
25917
|
+
}
|
|
25918
|
+
if (tool.inputSchema) {
|
|
25919
|
+
const typedHandler = handler;
|
|
25920
|
+
return await Promise.resolve(typedHandler(args, extra));
|
|
25921
|
+
} else {
|
|
25922
|
+
const typedHandler = handler;
|
|
25923
|
+
return await Promise.resolve(typedHandler(extra));
|
|
25924
|
+
}
|
|
25925
|
+
}
|
|
25926
|
+
/**
|
|
25927
|
+
* Handles automatic task polling for tools with taskSupport 'optional'.
|
|
25928
|
+
*/
|
|
25929
|
+
async handleAutomaticTaskPolling(tool, request, extra) {
|
|
25930
|
+
var _a;
|
|
25931
|
+
if (!extra.taskStore) {
|
|
25932
|
+
throw new Error("No task store provided for task-capable tool.");
|
|
25933
|
+
}
|
|
25934
|
+
const args = await this.validateToolInput(tool, request.params.arguments, request.params.name);
|
|
25935
|
+
const handler = tool.handler;
|
|
25936
|
+
const taskExtra = { ...extra, taskStore: extra.taskStore };
|
|
25937
|
+
const createTaskResult = args ? await Promise.resolve(handler.createTask(args, taskExtra)) : (
|
|
25938
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25939
|
+
await Promise.resolve(handler.createTask(taskExtra))
|
|
25940
|
+
);
|
|
25941
|
+
const taskId = createTaskResult.task.taskId;
|
|
25942
|
+
let task = createTaskResult.task;
|
|
25943
|
+
const pollInterval = (_a = task.pollInterval) !== null && _a !== void 0 ? _a : 5e3;
|
|
25944
|
+
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
25945
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
25946
|
+
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
25947
|
+
if (!updatedTask) {
|
|
25948
|
+
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
25949
|
+
}
|
|
25950
|
+
task = updatedTask;
|
|
25951
|
+
}
|
|
25952
|
+
return await extra.taskStore.getTaskResult(taskId);
|
|
25953
|
+
}
|
|
24663
25954
|
setCompletionRequestHandler() {
|
|
24664
25955
|
if (this._completionHandlerInitialized) {
|
|
24665
25956
|
return;
|
|
@@ -24815,7 +26106,9 @@ var McpServer = class {
|
|
|
24815
26106
|
const argsObj = normalizeObjectSchema(prompt.argsSchema);
|
|
24816
26107
|
const parseResult = await safeParseAsync3(argsObj, request.params.arguments);
|
|
24817
26108
|
if (!parseResult.success) {
|
|
24818
|
-
|
|
26109
|
+
const error2 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
26110
|
+
const errorMessage = getParseErrorMessage(error2);
|
|
26111
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request.params.name}: ${errorMessage}`);
|
|
24819
26112
|
}
|
|
24820
26113
|
const args = parseResult.data;
|
|
24821
26114
|
const cb = prompt.callback;
|
|
@@ -24967,7 +26260,7 @@ var McpServer = class {
|
|
|
24967
26260
|
this._registeredPrompts[name] = registeredPrompt;
|
|
24968
26261
|
return registeredPrompt;
|
|
24969
26262
|
}
|
|
24970
|
-
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, _meta,
|
|
26263
|
+
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, execution, _meta, handler) {
|
|
24971
26264
|
validateAndWarnToolName(name);
|
|
24972
26265
|
const registeredTool = {
|
|
24973
26266
|
title,
|
|
@@ -24975,8 +26268,9 @@ var McpServer = class {
|
|
|
24975
26268
|
inputSchema: getZodSchemaObject(inputSchema),
|
|
24976
26269
|
outputSchema: getZodSchemaObject(outputSchema),
|
|
24977
26270
|
annotations,
|
|
26271
|
+
execution,
|
|
24978
26272
|
_meta,
|
|
24979
|
-
|
|
26273
|
+
handler,
|
|
24980
26274
|
enabled: true,
|
|
24981
26275
|
disable: () => registeredTool.update({ enabled: false }),
|
|
24982
26276
|
enable: () => registeredTool.update({ enabled: true }),
|
|
@@ -24997,7 +26291,7 @@ var McpServer = class {
|
|
|
24997
26291
|
if (typeof updates.paramsSchema !== "undefined")
|
|
24998
26292
|
registeredTool.inputSchema = objectFromShape(updates.paramsSchema);
|
|
24999
26293
|
if (typeof updates.callback !== "undefined")
|
|
25000
|
-
registeredTool.
|
|
26294
|
+
registeredTool.handler = updates.callback;
|
|
25001
26295
|
if (typeof updates.annotations !== "undefined")
|
|
25002
26296
|
registeredTool.annotations = updates.annotations;
|
|
25003
26297
|
if (typeof updates._meta !== "undefined")
|
|
@@ -25028,9 +26322,9 @@ var McpServer = class {
|
|
|
25028
26322
|
}
|
|
25029
26323
|
if (rest.length > 1) {
|
|
25030
26324
|
const firstArg = rest[0];
|
|
25031
|
-
if (
|
|
26325
|
+
if (isZodRawShapeCompat(firstArg)) {
|
|
25032
26326
|
inputSchema = rest.shift();
|
|
25033
|
-
if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !
|
|
26327
|
+
if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShapeCompat(rest[0])) {
|
|
25034
26328
|
annotations = rest.shift();
|
|
25035
26329
|
}
|
|
25036
26330
|
} else if (typeof firstArg === "object" && firstArg !== null) {
|
|
@@ -25038,7 +26332,7 @@ var McpServer = class {
|
|
|
25038
26332
|
}
|
|
25039
26333
|
}
|
|
25040
26334
|
const callback = rest[0];
|
|
25041
|
-
return this._createRegisteredTool(name, void 0, description, inputSchema, outputSchema, annotations, void 0, callback);
|
|
26335
|
+
return this._createRegisteredTool(name, void 0, description, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, void 0, callback);
|
|
25042
26336
|
}
|
|
25043
26337
|
/**
|
|
25044
26338
|
* Registers a tool with a config object and callback.
|
|
@@ -25048,7 +26342,7 @@ var McpServer = class {
|
|
|
25048
26342
|
throw new Error(`Tool ${name} is already registered`);
|
|
25049
26343
|
}
|
|
25050
26344
|
const { title, description, inputSchema, outputSchema, annotations, _meta } = config2;
|
|
25051
|
-
return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, _meta, cb);
|
|
26345
|
+
return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, _meta, cb);
|
|
25052
26346
|
}
|
|
25053
26347
|
prompt(name, ...rest) {
|
|
25054
26348
|
if (this._registeredPrompts[name]) {
|
|
@@ -25127,20 +26421,29 @@ var EMPTY_OBJECT_JSON_SCHEMA = {
|
|
|
25127
26421
|
type: "object",
|
|
25128
26422
|
properties: {}
|
|
25129
26423
|
};
|
|
25130
|
-
function isZodRawShape(obj) {
|
|
25131
|
-
if (typeof obj !== "object" || obj === null)
|
|
25132
|
-
return false;
|
|
25133
|
-
const isEmptyObject = Object.keys(obj).length === 0;
|
|
25134
|
-
return isEmptyObject || Object.values(obj).some(isZodTypeLike);
|
|
25135
|
-
}
|
|
25136
26424
|
function isZodTypeLike(value) {
|
|
25137
26425
|
return value !== null && typeof value === "object" && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
|
|
25138
26426
|
}
|
|
26427
|
+
function isZodSchemaInstance(obj) {
|
|
26428
|
+
return "_def" in obj || "_zod" in obj || isZodTypeLike(obj);
|
|
26429
|
+
}
|
|
26430
|
+
function isZodRawShapeCompat(obj) {
|
|
26431
|
+
if (typeof obj !== "object" || obj === null) {
|
|
26432
|
+
return false;
|
|
26433
|
+
}
|
|
26434
|
+
if (isZodSchemaInstance(obj)) {
|
|
26435
|
+
return false;
|
|
26436
|
+
}
|
|
26437
|
+
if (Object.keys(obj).length === 0) {
|
|
26438
|
+
return true;
|
|
26439
|
+
}
|
|
26440
|
+
return Object.values(obj).some(isZodTypeLike);
|
|
26441
|
+
}
|
|
25139
26442
|
function getZodSchemaObject(schema) {
|
|
25140
26443
|
if (!schema) {
|
|
25141
26444
|
return void 0;
|
|
25142
26445
|
}
|
|
25143
|
-
if (
|
|
26446
|
+
if (isZodRawShapeCompat(schema)) {
|
|
25144
26447
|
return objectFromShape(schema);
|
|
25145
26448
|
}
|
|
25146
26449
|
return schema;
|
|
@@ -25198,7 +26501,6 @@ function requestBodyToZod(requestBody, components) {
|
|
|
25198
26501
|
} else if ("text/plain" in requestBody.content && requestBody.content["text/plain"].schema) {
|
|
25199
26502
|
schema = external_exports.string();
|
|
25200
26503
|
} else {
|
|
25201
|
-
console.error(`Unsupported media type in request body: ${JSON.stringify(requestBody.content, null, 2)}`);
|
|
25202
26504
|
return external_exports.never();
|
|
25203
26505
|
}
|
|
25204
26506
|
if (!requestBody.required) {
|
|
@@ -25246,7 +26548,13 @@ function jsonToZodValidation(_schema, components) {
|
|
|
25246
26548
|
let combinator;
|
|
25247
26549
|
if (schema.allOf) {
|
|
25248
26550
|
const schemas = schema.allOf.map((s) => schemaToZod(s, components));
|
|
25249
|
-
combinator = schemas.length > 0 ? schemas.reduce((acc, s) =>
|
|
26551
|
+
combinator = schemas.length > 0 ? schemas.reduce((acc, s) => zodMerge(acc, s)) : external_exports.unknown();
|
|
26552
|
+
if (combinator && isZodObject(combinator)) {
|
|
26553
|
+
const { discriminatorKey, discriminatorValue } = findDiscriminator(schema, components);
|
|
26554
|
+
if (discriminatorKey && discriminatorValue) {
|
|
26555
|
+
combinator = combinator.extend({ [discriminatorKey]: external_exports.literal(discriminatorValue) });
|
|
26556
|
+
}
|
|
26557
|
+
}
|
|
25250
26558
|
}
|
|
25251
26559
|
if (schema.oneOf) {
|
|
25252
26560
|
const schemas = schema.oneOf.map((s) => schemaToZod(s, components));
|
|
@@ -25287,14 +26595,9 @@ function jsonToZodValidation(_schema, components) {
|
|
|
25287
26595
|
const shape = {};
|
|
25288
26596
|
if (schema.properties) {
|
|
25289
26597
|
for (const [key, property] of Object.entries(schema.properties)) {
|
|
25290
|
-
|
|
25291
|
-
|
|
25292
|
-
shape[key] =
|
|
25293
|
-
} else {
|
|
25294
|
-
shape[key] = schemaToZod(property, components);
|
|
25295
|
-
if (!schema.required?.includes(key)) {
|
|
25296
|
-
shape[key] = shape[key].nullish();
|
|
25297
|
-
}
|
|
26598
|
+
shape[key] = schemaToZod(property, components);
|
|
26599
|
+
if (!schema.required?.includes(key)) {
|
|
26600
|
+
shape[key] = shape[key].nullish();
|
|
25298
26601
|
}
|
|
25299
26602
|
}
|
|
25300
26603
|
}
|
|
@@ -25302,7 +26605,7 @@ function jsonToZodValidation(_schema, components) {
|
|
|
25302
26605
|
if (schema.additionalProperties) {
|
|
25303
26606
|
return objectSchema.passthrough();
|
|
25304
26607
|
}
|
|
25305
|
-
return combinator ?
|
|
26608
|
+
return combinator ? zodMerge(combinator, objectSchema) : objectSchema;
|
|
25306
26609
|
}
|
|
25307
26610
|
}
|
|
25308
26611
|
}
|
|
@@ -25329,7 +26632,7 @@ function resolveRef(ref, components) {
|
|
|
25329
26632
|
throw new Error(`Unknown components section: ${section}`);
|
|
25330
26633
|
}
|
|
25331
26634
|
const resolved = group[name];
|
|
25332
|
-
if (
|
|
26635
|
+
if (resolved === void 0 || resolved === null) {
|
|
25333
26636
|
throw new Error(`Reference not found: ${ref}`);
|
|
25334
26637
|
}
|
|
25335
26638
|
if (resolved && typeof resolved === "object" && "$ref" in resolved && typeof resolved.$ref === "string") {
|
|
@@ -25337,6 +26640,29 @@ function resolveRef(ref, components) {
|
|
|
25337
26640
|
}
|
|
25338
26641
|
return resolved;
|
|
25339
26642
|
}
|
|
26643
|
+
function findDiscriminator(schema, components) {
|
|
26644
|
+
const partWithDiscriminator = schema.allOf?.map((s) => deref(s, components)).find((s) => typeof s === "object" && "discriminator" in s);
|
|
26645
|
+
const discriminator = partWithDiscriminator?.discriminator;
|
|
26646
|
+
if (discriminator?.mapping) {
|
|
26647
|
+
const discriminatorMappingEntry = Object.entries(discriminator.mapping ?? {}).find(
|
|
26648
|
+
([, discriminatorRef]) => resolveRef(discriminatorRef, components) === schema
|
|
26649
|
+
);
|
|
26650
|
+
if (discriminatorMappingEntry) {
|
|
26651
|
+
const [discriminatorValue] = discriminatorMappingEntry;
|
|
26652
|
+
return { discriminatorKey: discriminator.propertyName, discriminatorValue };
|
|
26653
|
+
}
|
|
26654
|
+
}
|
|
26655
|
+
return {};
|
|
26656
|
+
}
|
|
26657
|
+
function zodMerge(a, b) {
|
|
26658
|
+
if (isZodObject(a) && isZodObject(b)) {
|
|
26659
|
+
return a.extend(b.shape);
|
|
26660
|
+
}
|
|
26661
|
+
return external_exports.intersection(a, b);
|
|
26662
|
+
}
|
|
26663
|
+
function isZodObject(obj) {
|
|
26664
|
+
return "shape" in obj && "extend" in obj;
|
|
26665
|
+
}
|
|
25340
26666
|
|
|
25341
26667
|
// src/utils.ts
|
|
25342
26668
|
function info(...parts) {
|
|
@@ -25383,8 +26709,8 @@ function generateMcpTools(config2) {
|
|
|
25383
26709
|
const tool = generateMcpTool({ method, path: `${defaultServerUrl}${path2}`, operation }, config2);
|
|
25384
26710
|
info(`Generated tool: ${tool.name} for ${method} ${path2}`);
|
|
25385
26711
|
tools.push(tool);
|
|
25386
|
-
} catch (
|
|
25387
|
-
err(`Failed to generate tool for ${method} ${path2}:`,
|
|
26712
|
+
} catch (error2) {
|
|
26713
|
+
err(`Failed to generate tool for ${method} ${path2}:`, error2);
|
|
25388
26714
|
}
|
|
25389
26715
|
}
|
|
25390
26716
|
}
|
|
@@ -25419,8 +26745,8 @@ function generateMcpTool(description, config2) {
|
|
|
25419
26745
|
},
|
|
25420
26746
|
body: "data" in params ? JSON.stringify(params.data, null, 2) : void 0
|
|
25421
26747
|
});
|
|
25422
|
-
} catch (
|
|
25423
|
-
err(`Failed to fetch ${url}. Are you sure that the server is running?`,
|
|
26748
|
+
} catch (error2) {
|
|
26749
|
+
err(`Failed to fetch ${url}. Are you sure that the server is running?`, error2);
|
|
25424
26750
|
return {
|
|
25425
26751
|
content: [
|
|
25426
26752
|
{
|
|
@@ -25431,17 +26757,17 @@ function generateMcpTool(description, config2) {
|
|
|
25431
26757
|
isError: true
|
|
25432
26758
|
};
|
|
25433
26759
|
}
|
|
26760
|
+
const isJsonResponse = response.headers.get("Content-Type")?.includes("application/json");
|
|
25434
26761
|
if (!response.ok) {
|
|
25435
26762
|
const errorObj = {
|
|
25436
26763
|
url,
|
|
25437
26764
|
method,
|
|
25438
26765
|
body: "data" in params ? params.data : void 0,
|
|
25439
|
-
response: await
|
|
26766
|
+
response: isJsonResponse ? await response.json() : await response.text()
|
|
25440
26767
|
};
|
|
25441
26768
|
const errorMsg = JSON.stringify(errorObj, null, 2);
|
|
25442
|
-
return { content: [{ type: "text", text: errorMsg }], isError: true };
|
|
26769
|
+
return { content: [{ type: "text", text: "```json\n" + errorMsg + "\n```" }], isError: true };
|
|
25443
26770
|
}
|
|
25444
|
-
const isJsonResponse = response.headers.get("Content-Type")?.includes("application/json");
|
|
25445
26771
|
try {
|
|
25446
26772
|
if (isJsonResponse) {
|
|
25447
26773
|
const text = JSON.stringify(await response.json(), null, 2);
|
|
@@ -25450,8 +26776,8 @@ function generateMcpTool(description, config2) {
|
|
|
25450
26776
|
const text = await response.text();
|
|
25451
26777
|
return { content: [{ type: "text", text }] };
|
|
25452
26778
|
}
|
|
25453
|
-
} catch (
|
|
25454
|
-
return { content: [{ type: "text", text: String(
|
|
26779
|
+
} catch (error2) {
|
|
26780
|
+
return { content: [{ type: "text", text: String(error2) }], isError: true };
|
|
25455
26781
|
}
|
|
25456
26782
|
}
|
|
25457
26783
|
const inputSchema = {};
|
|
@@ -25531,8 +26857,8 @@ function read() {
|
|
|
25531
26857
|
try {
|
|
25532
26858
|
const data = readFileSync(STORAGE_PATH, { encoding: "utf8" });
|
|
25533
26859
|
return JSON.parse(data);
|
|
25534
|
-
} catch (
|
|
25535
|
-
err("Failed to read storage from file", STORAGE_PATH,
|
|
26860
|
+
} catch (error2) {
|
|
26861
|
+
err("Failed to read storage from file", STORAGE_PATH, error2);
|
|
25536
26862
|
return {};
|
|
25537
26863
|
}
|
|
25538
26864
|
}
|
|
@@ -25541,8 +26867,8 @@ function read() {
|
|
|
25541
26867
|
function write(newStorage) {
|
|
25542
26868
|
try {
|
|
25543
26869
|
writeFile(STORAGE_PATH, JSON.stringify(newStorage, null, 2));
|
|
25544
|
-
} catch (
|
|
25545
|
-
err(`Failed to write storage to file: ${STORAGE_PATH}`,
|
|
26870
|
+
} catch (error2) {
|
|
26871
|
+
err(`Failed to write storage to file: ${STORAGE_PATH}`, error2);
|
|
25546
26872
|
}
|
|
25547
26873
|
}
|
|
25548
26874
|
|
|
@@ -25550,18 +26876,13 @@ function write(newStorage) {
|
|
|
25550
26876
|
async function lookupOpenApiSpec(managementApiUrl2, secret) {
|
|
25551
26877
|
const workingDir2 = process.cwd();
|
|
25552
26878
|
let openApiSpec2 = await fetchOpenApiSpec(managementApiUrl2, secret);
|
|
25553
|
-
if (
|
|
25554
|
-
openApiSpec2
|
|
25555
|
-
}
|
|
25556
|
-
if (!openApiSpec2) {
|
|
25557
|
-
openApiSpec2 = await fetchOpenApiSpec(managementApiUrl2, secret);
|
|
25558
|
-
if (!openApiSpec2) {
|
|
25559
|
-
return;
|
|
25560
|
-
}
|
|
25561
|
-
if (workingDir2 && process.env.CACHE_OPENAPI !== "false") {
|
|
26879
|
+
if (workingDir2 && process.env.CACHE_OPENAPI !== "false") {
|
|
26880
|
+
if (openApiSpec2) {
|
|
25562
26881
|
const openApiSpecs = storage.openapiSpecs ?? {};
|
|
25563
26882
|
openApiSpecs[workingDir2] = openApiSpec2;
|
|
25564
26883
|
storage.openapiSpecs = openApiSpecs;
|
|
26884
|
+
} else {
|
|
26885
|
+
openApiSpec2 = storage.openapiSpecs?.[workingDir2];
|
|
25565
26886
|
}
|
|
25566
26887
|
}
|
|
25567
26888
|
return openApiSpec2;
|
|
@@ -25575,8 +26896,8 @@ async function fetchOpenApiSpec(url, secret) {
|
|
|
25575
26896
|
headers["Authorization"] = `Bearer ${secret}`;
|
|
25576
26897
|
}
|
|
25577
26898
|
response = await fetch(url, { headers });
|
|
25578
|
-
} catch (
|
|
25579
|
-
err(`Failed to fetch OpenAPI spec from ${url}. Are you sure that the server is running?`,
|
|
26899
|
+
} catch (error2) {
|
|
26900
|
+
err(`Failed to fetch OpenAPI spec from ${url}. Are you sure that the server is running?`, error2);
|
|
25580
26901
|
return;
|
|
25581
26902
|
}
|
|
25582
26903
|
if (!response.ok) {
|
|
@@ -25597,18 +26918,7 @@ var managementApiUrl = process.env.MANAGEMENT_API_URL;
|
|
|
25597
26918
|
if (!managementApiUrl) {
|
|
25598
26919
|
err(
|
|
25599
26920
|
"MANAGEMENT_API_URL environment variable is not set.",
|
|
25600
|
-
"Please configure your mcp config to set the MANAGEMENT_API_URL environment variable
|
|
25601
|
-
{
|
|
25602
|
-
mcpServers: {
|
|
25603
|
-
xperience: {
|
|
25604
|
-
type: "stdio",
|
|
25605
|
-
command: "@kentico/management-api-mcp",
|
|
25606
|
-
env: {
|
|
25607
|
-
MANAGEMENT_API_URL: "https://localhost:12345/kentico-api/management"
|
|
25608
|
-
}
|
|
25609
|
-
}
|
|
25610
|
-
}
|
|
25611
|
-
}
|
|
26921
|
+
"Please configure your mcp config to set the MANAGEMENT_API_URL environment variable."
|
|
25612
26922
|
);
|
|
25613
26923
|
process.exit(1);
|
|
25614
26924
|
}
|