lotus-wisdom-mcp 0.8.3 → 0.8.4
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 +6 -3
- package/dist/bundle.js +149 -25
- package/dist/journey.html +15 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -412,9 +412,12 @@ bun run start
|
|
|
412
412
|
```
|
|
413
413
|
|
|
414
414
|
The build installs the app's locked dependencies and rebuilds the tracked
|
|
415
|
-
`dist/bundle.js` and `dist/journey.html` artifacts. Check app types
|
|
416
|
-
`cd app && bunx tsc --noEmit`; see
|
|
417
|
-
for the worker typecheck,
|
|
415
|
+
`dist/bundle.js` and `dist/journey.html` artifacts. Check app types and build
|
|
416
|
+
regressions with `cd app && bunx tsc --noEmit && bun run test`; see
|
|
417
|
+
[worker validation](worker/README.md#local-dev) for the worker typecheck,
|
|
418
|
+
dry-run build, and local HTTP regression. The app's local Vite plugin inlines
|
|
419
|
+
JavaScript and CSS into one HTML resource, with tests for dynamic imports and
|
|
420
|
+
HTML escaping.
|
|
418
421
|
|
|
419
422
|
Dependabot uses the `bun` ecosystem for the root, app, and worker packages so
|
|
420
423
|
updates include their `bun.lock` files. CI verifies all three packages on pull
|
package/dist/bundle.js
CHANGED
|
@@ -3109,6 +3109,7 @@ var require_utils = __commonJS({
|
|
|
3109
3109
|
"use strict";
|
|
3110
3110
|
var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
3111
3111
|
var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
3112
|
+
var isPort = RegExp.prototype.test.bind(/^\d*$/u);
|
|
3112
3113
|
var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
|
|
3113
3114
|
var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
|
|
3114
3115
|
var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
|
|
@@ -3574,8 +3575,12 @@ var require_utils = __commonJS({
|
|
|
3574
3575
|
uriTokens.push(host);
|
|
3575
3576
|
}
|
|
3576
3577
|
if (typeof component.port === "number" || typeof component.port === "string") {
|
|
3578
|
+
const port = String(component.port);
|
|
3579
|
+
if (!isPort(port)) {
|
|
3580
|
+
throw new TypeError("URI port is malformed.");
|
|
3581
|
+
}
|
|
3577
3582
|
uriTokens.push(":");
|
|
3578
|
-
uriTokens.push(
|
|
3583
|
+
uriTokens.push(port);
|
|
3579
3584
|
}
|
|
3580
3585
|
return uriTokens.length ? uriTokens.join("") : void 0;
|
|
3581
3586
|
}
|
|
@@ -4018,12 +4023,15 @@ var require_fast_uri = __commonJS({
|
|
|
4018
4023
|
}
|
|
4019
4024
|
return false;
|
|
4020
4025
|
}
|
|
4026
|
+
function isIPLiteral(host) {
|
|
4027
|
+
return host[0] === "[" && host[host.length - 1] === "]";
|
|
4028
|
+
}
|
|
4021
4029
|
function hasMalformedComponentPercentEncoding(matches) {
|
|
4022
4030
|
const host = matches[4];
|
|
4023
|
-
return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !(host
|
|
4031
|
+
return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
|
|
4024
4032
|
}
|
|
4025
4033
|
function canonicalizeHost(parsed, options, schemeHandler, isIP) {
|
|
4026
|
-
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && parsed.host
|
|
4034
|
+
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
4027
4035
|
try {
|
|
4028
4036
|
parsed.host = new URL("http://" + parsed.host).hostname;
|
|
4029
4037
|
} catch (e) {
|
|
@@ -4110,10 +4118,11 @@ var require_fast_uri = __commonJS({
|
|
|
4110
4118
|
if (parsed.host) {
|
|
4111
4119
|
const ipv4result = isIPv4(parsed.host);
|
|
4112
4120
|
if (ipv4result === false) {
|
|
4113
|
-
const bracketedIPLiteral = parsed.host
|
|
4121
|
+
const bracketedIPLiteral = isIPLiteral(parsed.host);
|
|
4122
|
+
const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
|
|
4114
4123
|
const ipv6result = normalizeIPv6(parsed.host);
|
|
4115
4124
|
isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
|
|
4116
|
-
malformedIPLiteral =
|
|
4125
|
+
malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
|
|
4117
4126
|
parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
|
|
4118
4127
|
if (malformedIPLiteral) {
|
|
4119
4128
|
parsed.error = parsed.error || "URI host is malformed.";
|
|
@@ -4136,14 +4145,17 @@ var require_fast_uri = __commonJS({
|
|
|
4136
4145
|
parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
|
|
4137
4146
|
}
|
|
4138
4147
|
const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4148
|
+
if (!malformedIPLiteral) {
|
|
4149
|
+
malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
|
|
4150
|
+
}
|
|
4151
|
+
if (uri.indexOf("%") !== -1 && parsed.host !== void 0 && !malformedIPLiteral) {
|
|
4152
|
+
let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
|
|
4153
|
+
if (!isIP) {
|
|
4154
|
+
host = normalizePercentEncoding(host.toLowerCase());
|
|
4146
4155
|
}
|
|
4156
|
+
parsed.host = reescapeHostDelimiters(host, isIP);
|
|
4157
|
+
}
|
|
4158
|
+
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
4147
4159
|
if (parsed.path) {
|
|
4148
4160
|
parsed.path = normalizePathEncoding(parsed.path);
|
|
4149
4161
|
}
|
|
@@ -11470,6 +11482,7 @@ __export(util_exports, {
|
|
|
11470
11482
|
required: () => required,
|
|
11471
11483
|
safeExtend: () => safeExtend,
|
|
11472
11484
|
shallowClone: () => shallowClone,
|
|
11485
|
+
sizeCaps: () => sizeCaps,
|
|
11473
11486
|
slugify: () => slugify,
|
|
11474
11487
|
stringifyPrimitive: () => stringifyPrimitive,
|
|
11475
11488
|
toZod: () => toZod,
|
|
@@ -11989,6 +12002,18 @@ function prefixIssues(path, issues) {
|
|
|
11989
12002
|
function unwrapMessage(message) {
|
|
11990
12003
|
return typeof message === "string" ? message : message?.message;
|
|
11991
12004
|
}
|
|
12005
|
+
function sizeCaps(defChecks) {
|
|
12006
|
+
const caps = [];
|
|
12007
|
+
for (const ch of defChecks ?? []) {
|
|
12008
|
+
const d = ch._zod.def;
|
|
12009
|
+
if (!/_(length|size)$|_equals$/.test(d.check))
|
|
12010
|
+
break;
|
|
12011
|
+
const max = d.maximum ?? d.length ?? d.size;
|
|
12012
|
+
if (max >= 0)
|
|
12013
|
+
caps.push([max, ch]);
|
|
12014
|
+
}
|
|
12015
|
+
return caps;
|
|
12016
|
+
}
|
|
11992
12017
|
function attachSchema(issues, start, inst) {
|
|
11993
12018
|
var _a3;
|
|
11994
12019
|
for (let i = start; i < issues.length; i++) {
|
|
@@ -13409,7 +13434,7 @@ ${content.join("\n")}
|
|
|
13409
13434
|
var version = {
|
|
13410
13435
|
major: 4,
|
|
13411
13436
|
minor: 6,
|
|
13412
|
-
patch:
|
|
13437
|
+
patch: 7
|
|
13413
13438
|
};
|
|
13414
13439
|
|
|
13415
13440
|
// node_modules/zod/v4/core/schemas.js
|
|
@@ -14165,6 +14190,31 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
|
14165
14190
|
return payload;
|
|
14166
14191
|
};
|
|
14167
14192
|
});
|
|
14193
|
+
function capSize(inst, size) {
|
|
14194
|
+
const caps = sizeCaps(inst._zod.def.checks);
|
|
14195
|
+
if (!caps.length)
|
|
14196
|
+
return;
|
|
14197
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
14198
|
+
const parse3 = inst._zod.parse;
|
|
14199
|
+
inst._zod.parse = (payload, ctx) => {
|
|
14200
|
+
const n = size(payload.value);
|
|
14201
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
14202
|
+
for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
|
|
14203
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
14204
|
+
const start = payload.issues.length;
|
|
14205
|
+
ch._zod.check(payload);
|
|
14206
|
+
payload.issues[start].continue = false;
|
|
14207
|
+
attachSchema(payload.issues, start, inst);
|
|
14208
|
+
return payload;
|
|
14209
|
+
}
|
|
14210
|
+
}
|
|
14211
|
+
}
|
|
14212
|
+
return parse3(payload, ctx);
|
|
14213
|
+
};
|
|
14214
|
+
}
|
|
14215
|
+
var arraySize = (input2) => Array.isArray(input2) ? input2.length : -1;
|
|
14216
|
+
var mapSize = (input2) => input2 instanceof Map ? input2.size : -1;
|
|
14217
|
+
var setSize = (input2) => input2 instanceof Set ? input2.size : -1;
|
|
14168
14218
|
function handleArrayResult(result, final, index) {
|
|
14169
14219
|
if (result.issues.length) {
|
|
14170
14220
|
final.issues.push(...prefixIssues(index, result.issues));
|
|
@@ -14208,6 +14258,7 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
14208
14258
|
}
|
|
14209
14259
|
return payload;
|
|
14210
14260
|
};
|
|
14261
|
+
capSize(inst, arraySize);
|
|
14211
14262
|
});
|
|
14212
14263
|
function handlePropertyResult(result, final, key, input2, optin, optout) {
|
|
14213
14264
|
const isPresent = key in input2;
|
|
@@ -15164,6 +15215,7 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
|
15164
15215
|
return Promise.all(proms).then(() => payload);
|
|
15165
15216
|
return payload;
|
|
15166
15217
|
};
|
|
15218
|
+
capSize(inst, mapSize);
|
|
15167
15219
|
});
|
|
15168
15220
|
function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx) {
|
|
15169
15221
|
if (keyResult.issues.length) {
|
|
@@ -15230,6 +15282,7 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
|
|
|
15230
15282
|
return Promise.all(proms).then(() => payload);
|
|
15231
15283
|
return payload;
|
|
15232
15284
|
};
|
|
15285
|
+
capSize(inst, setSize);
|
|
15233
15286
|
});
|
|
15234
15287
|
function handleSetResult(result, final) {
|
|
15235
15288
|
if (result.issues.length) {
|
|
@@ -24760,9 +24813,15 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
24760
24813
|
doc.write(`}`);
|
|
24761
24814
|
return outputVar;
|
|
24762
24815
|
}
|
|
24816
|
+
function generateSizeGate(doc, schema, size) {
|
|
24817
|
+
for (const [max, check2] of sizeCaps(schema._zod.def.checks)) {
|
|
24818
|
+
doc.write(`if (${size} > ${numericOperand(max, check2._zod.def.check)}) return INVALID;`);
|
|
24819
|
+
}
|
|
24820
|
+
}
|
|
24763
24821
|
function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
24764
24822
|
const def = schema._zod.def;
|
|
24765
24823
|
doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
|
|
24824
|
+
generateSizeGate(doc, schema, `${accessor}.length`);
|
|
24766
24825
|
const outputVar = buildsValue ? newVar(ctx) : null;
|
|
24767
24826
|
const iVar = newVar(ctx);
|
|
24768
24827
|
const elemVar = newVar(ctx);
|
|
@@ -25162,6 +25221,7 @@ function literalPropertyKey(ctx, key) {
|
|
|
25162
25221
|
function generateMapCheck(doc, ctx, schema, accessor) {
|
|
25163
25222
|
const def = schema._zod.def;
|
|
25164
25223
|
doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
|
|
25224
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
25165
25225
|
const outputVar = newVar(ctx);
|
|
25166
25226
|
const kVar = newVar(ctx);
|
|
25167
25227
|
const valVar = newVar(ctx);
|
|
@@ -25178,6 +25238,7 @@ function generateMapCheck(doc, ctx, schema, accessor) {
|
|
|
25178
25238
|
function generateSetCheck(doc, ctx, schema, accessor) {
|
|
25179
25239
|
const def = schema._zod.def;
|
|
25180
25240
|
doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
|
|
25241
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
25181
25242
|
const outputVar = newVar(ctx);
|
|
25182
25243
|
const valVar = newVar(ctx);
|
|
25183
25244
|
doc.write(`const ${outputVar} = new Set();`);
|
|
@@ -33879,6 +33940,9 @@ var Protocol = class {
|
|
|
33879
33940
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
33880
33941
|
const handleTaskResult = async () => {
|
|
33881
33942
|
const taskId = request.params.taskId;
|
|
33943
|
+
if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
|
|
33944
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
33945
|
+
}
|
|
33882
33946
|
if (this._taskMessageQueue) {
|
|
33883
33947
|
let queuedMessage;
|
|
33884
33948
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -33909,12 +33973,12 @@ var Protocol = class {
|
|
|
33909
33973
|
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
33910
33974
|
}
|
|
33911
33975
|
if (!isTerminal(task.status)) {
|
|
33912
|
-
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
33976
|
+
await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
|
|
33913
33977
|
return await handleTaskResult();
|
|
33914
33978
|
}
|
|
33915
33979
|
if (isTerminal(task.status)) {
|
|
33916
33980
|
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
33917
|
-
this._clearTaskQueue(taskId);
|
|
33981
|
+
this._clearTaskQueue(taskId, extra.sessionId);
|
|
33918
33982
|
return {
|
|
33919
33983
|
...result,
|
|
33920
33984
|
_meta: {
|
|
@@ -33951,7 +34015,7 @@ var Protocol = class {
|
|
|
33951
34015
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
33952
34016
|
}
|
|
33953
34017
|
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
33954
|
-
this._clearTaskQueue(request.params.taskId);
|
|
34018
|
+
this._clearTaskQueue(request.params.taskId, extra.sessionId);
|
|
33955
34019
|
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
33956
34020
|
if (!cancelledTask) {
|
|
33957
34021
|
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
@@ -34079,6 +34143,19 @@ var Protocol = class {
|
|
|
34079
34143
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
34080
34144
|
const capturedTransport = this._transport;
|
|
34081
34145
|
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
34146
|
+
const sessionId = capturedTransport?.sessionId;
|
|
34147
|
+
const store = this._taskStore;
|
|
34148
|
+
let relatedTaskFound = true;
|
|
34149
|
+
let relatedTaskLookup;
|
|
34150
|
+
if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
|
|
34151
|
+
relatedTaskFound = false;
|
|
34152
|
+
relatedTaskLookup = (async () => {
|
|
34153
|
+
if (!await store.getTask(relatedTaskId, sessionId)) {
|
|
34154
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
|
|
34155
|
+
}
|
|
34156
|
+
relatedTaskFound = true;
|
|
34157
|
+
})();
|
|
34158
|
+
}
|
|
34082
34159
|
if (handler === void 0) {
|
|
34083
34160
|
const errorResponse = {
|
|
34084
34161
|
jsonrpc: "2.0",
|
|
@@ -34088,7 +34165,10 @@ var Protocol = class {
|
|
|
34088
34165
|
message: "Method not found"
|
|
34089
34166
|
}
|
|
34090
34167
|
};
|
|
34091
|
-
if (relatedTaskId &&
|
|
34168
|
+
if (relatedTaskId && relatedTaskLookup) {
|
|
34169
|
+
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
34170
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error62) => this._onerror(new Error(`Failed to send an error response: ${error62}`)));
|
|
34171
|
+
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
34092
34172
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
34093
34173
|
type: "error",
|
|
34094
34174
|
message: errorResponse,
|
|
@@ -34139,7 +34219,10 @@ var Protocol = class {
|
|
|
34139
34219
|
closeSSEStream: extra?.closeSSEStream,
|
|
34140
34220
|
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
34141
34221
|
};
|
|
34142
|
-
Promise.resolve().then(() => {
|
|
34222
|
+
(relatedTaskLookup ?? Promise.resolve()).then(() => {
|
|
34223
|
+
if (relatedTaskLookup && abortController.signal.aborted) {
|
|
34224
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
34225
|
+
}
|
|
34143
34226
|
if (taskCreationParams) {
|
|
34144
34227
|
this.assertTaskHandlerCapability(request.method);
|
|
34145
34228
|
}
|
|
@@ -34174,7 +34257,7 @@ var Protocol = class {
|
|
|
34174
34257
|
...error62["data"] !== void 0 && { data: error62["data"] }
|
|
34175
34258
|
}
|
|
34176
34259
|
};
|
|
34177
|
-
if (relatedTaskId && this._taskMessageQueue) {
|
|
34260
|
+
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
34178
34261
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
34179
34262
|
type: "error",
|
|
34180
34263
|
message: errorResponse,
|
|
@@ -34654,7 +34737,7 @@ var Protocol = class {
|
|
|
34654
34737
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
34655
34738
|
}
|
|
34656
34739
|
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
34657
|
-
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
34740
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
|
|
34658
34741
|
}
|
|
34659
34742
|
/**
|
|
34660
34743
|
* Clears the message queue for a task and rejects any pending request resolvers.
|
|
@@ -34683,12 +34766,13 @@ var Protocol = class {
|
|
|
34683
34766
|
* Uses polling to check for updates at the task's configured poll interval.
|
|
34684
34767
|
* @param taskId The task ID to wait for
|
|
34685
34768
|
* @param signal Abort signal to cancel the wait
|
|
34769
|
+
* @param sessionId Session of the request that waits, passed to the task store
|
|
34686
34770
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
34687
34771
|
*/
|
|
34688
|
-
async _waitForTaskUpdate(taskId, signal) {
|
|
34772
|
+
async _waitForTaskUpdate(taskId, signal, sessionId) {
|
|
34689
34773
|
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
34690
34774
|
try {
|
|
34691
|
-
const task = await this._taskStore?.getTask(taskId);
|
|
34775
|
+
const task = await this._taskStore?.getTask(taskId, sessionId);
|
|
34692
34776
|
if (task?.pollInterval) {
|
|
34693
34777
|
interval = task.pollInterval;
|
|
34694
34778
|
}
|
|
@@ -35567,6 +35651,42 @@ var ExperimentalMcpServerTasks = class {
|
|
|
35567
35651
|
};
|
|
35568
35652
|
|
|
35569
35653
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
|
|
35654
|
+
function toolInputElementCount(value, max) {
|
|
35655
|
+
let count = 0;
|
|
35656
|
+
const stack = [value];
|
|
35657
|
+
while (stack.length > 0) {
|
|
35658
|
+
const node2 = stack.pop();
|
|
35659
|
+
if (node2 === null || typeof node2 !== "object")
|
|
35660
|
+
continue;
|
|
35661
|
+
if (Array.isArray(node2)) {
|
|
35662
|
+
for (const child of node2) {
|
|
35663
|
+
if (++count > max)
|
|
35664
|
+
return count;
|
|
35665
|
+
if (child !== null && typeof child === "object")
|
|
35666
|
+
stack.push(child);
|
|
35667
|
+
}
|
|
35668
|
+
} else {
|
|
35669
|
+
for (const key in node2) {
|
|
35670
|
+
if (!Object.prototype.hasOwnProperty.call(node2, key))
|
|
35671
|
+
continue;
|
|
35672
|
+
if (++count > max)
|
|
35673
|
+
return count;
|
|
35674
|
+
const child = node2[key];
|
|
35675
|
+
if (child !== null && typeof child === "object")
|
|
35676
|
+
stack.push(child);
|
|
35677
|
+
}
|
|
35678
|
+
}
|
|
35679
|
+
}
|
|
35680
|
+
return count;
|
|
35681
|
+
}
|
|
35682
|
+
function resolveMaxToolInputElements(value) {
|
|
35683
|
+
if (value === void 0 || value === Infinity)
|
|
35684
|
+
return void 0;
|
|
35685
|
+
if (typeof value !== "number" || Number.isNaN(value) || value < 1) {
|
|
35686
|
+
throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(value)}`);
|
|
35687
|
+
}
|
|
35688
|
+
return value;
|
|
35689
|
+
}
|
|
35570
35690
|
var McpServer = class {
|
|
35571
35691
|
constructor(serverInfo, options) {
|
|
35572
35692
|
this._registeredResources = {};
|
|
@@ -35578,6 +35698,7 @@ var McpServer = class {
|
|
|
35578
35698
|
this._resourceHandlersInitialized = false;
|
|
35579
35699
|
this._promptHandlersInitialized = false;
|
|
35580
35700
|
this.server = new Server(serverInfo, options);
|
|
35701
|
+
this._maxToolInputElements = resolveMaxToolInputElements(options?.maxToolInputElements);
|
|
35581
35702
|
}
|
|
35582
35703
|
/**
|
|
35583
35704
|
* Access experimental features.
|
|
@@ -35708,12 +35829,15 @@ var McpServer = class {
|
|
|
35708
35829
|
* Validates tool input arguments against the tool's input schema.
|
|
35709
35830
|
*/
|
|
35710
35831
|
async validateToolInput(tool, args, toolName) {
|
|
35832
|
+
if (this._maxToolInputElements !== void 0 && toolInputElementCount(args, this._maxToolInputElements) > this._maxToolInputElements) {
|
|
35833
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for tool ${toolName}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);
|
|
35834
|
+
}
|
|
35711
35835
|
if (!tool.inputSchema) {
|
|
35712
35836
|
return void 0;
|
|
35713
35837
|
}
|
|
35714
35838
|
const inputObj = normalizeObjectSchema(tool.inputSchema);
|
|
35715
35839
|
const schemaToParse = inputObj ?? tool.inputSchema;
|
|
35716
|
-
const parseResult = await safeParseAsync2(schemaToParse, args);
|
|
35840
|
+
const parseResult = await safeParseAsync2(schemaToParse, args ?? {});
|
|
35717
35841
|
if (!parseResult.success) {
|
|
35718
35842
|
const error62 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
35719
35843
|
const errorMessage = getParseErrorMessage(error62);
|
|
@@ -35951,7 +36075,7 @@ var McpServer = class {
|
|
|
35951
36075
|
}
|
|
35952
36076
|
if (prompt.argsSchema) {
|
|
35953
36077
|
const argsObj = normalizeObjectSchema(prompt.argsSchema);
|
|
35954
|
-
const parseResult = await safeParseAsync2(argsObj, request.params.arguments);
|
|
36078
|
+
const parseResult = await safeParseAsync2(argsObj, request.params.arguments ?? {});
|
|
35955
36079
|
if (!parseResult.success) {
|
|
35956
36080
|
const error62 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
35957
36081
|
const errorMessage = getParseErrorMessage(error62);
|
|
@@ -36709,7 +36833,7 @@ function structuredContentFor(result) {
|
|
|
36709
36833
|
}
|
|
36710
36834
|
|
|
36711
36835
|
// src/shared/version.ts
|
|
36712
|
-
var VERSION = "0.8.
|
|
36836
|
+
var VERSION = "0.8.4";
|
|
36713
36837
|
|
|
36714
36838
|
// src/shared/tool-defs.ts
|
|
36715
36839
|
var SERVER_NAME = "lotus-wisdom";
|