modality-kit 0.12.14 → 0.12.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -5180,7 +5180,17 @@ class JSONRPCUtils {
|
|
|
5180
5180
|
}
|
|
5181
5181
|
static deserialize(data) {
|
|
5182
5182
|
try {
|
|
5183
|
-
|
|
5183
|
+
let messageStr;
|
|
5184
|
+
if (typeof data !== "string") {
|
|
5185
|
+
if (Buffer.isBuffer(data)) {
|
|
5186
|
+
messageStr = data.toString();
|
|
5187
|
+
} else {
|
|
5188
|
+
return data;
|
|
5189
|
+
}
|
|
5190
|
+
} else {
|
|
5191
|
+
messageStr = data;
|
|
5192
|
+
}
|
|
5193
|
+
return JSON.parse(messageStr);
|
|
5184
5194
|
} catch {
|
|
5185
5195
|
return null;
|
|
5186
5196
|
}
|
|
@@ -5489,6 +5499,10 @@ class ERROR_METHOD_NOT_FOUND extends ErrorCode {
|
|
|
5489
5499
|
code = -32601 /* METHOD_NOT_FOUND */;
|
|
5490
5500
|
}
|
|
5491
5501
|
|
|
5502
|
+
class ERROR_PARSE_ERROR extends ErrorCode {
|
|
5503
|
+
code = -32700 /* PARSE_ERROR */;
|
|
5504
|
+
}
|
|
5505
|
+
|
|
5492
5506
|
class JSONRPCManager extends JSONRPCCall {
|
|
5493
5507
|
methods = new Map;
|
|
5494
5508
|
config;
|
|
@@ -5508,7 +5522,7 @@ class JSONRPCManager extends JSONRPCCall {
|
|
|
5508
5522
|
try {
|
|
5509
5523
|
switch (validation.messageType) {
|
|
5510
5524
|
case "request":
|
|
5511
|
-
return await this.
|
|
5525
|
+
return await this.processMethod(validation.message, options);
|
|
5512
5526
|
case "notification":
|
|
5513
5527
|
this.processNotification(validation.message, options);
|
|
5514
5528
|
break;
|
|
@@ -5526,11 +5540,11 @@ class JSONRPCManager extends JSONRPCCall {
|
|
|
5526
5540
|
return JSONRPCUtils.createErrorResponse(JSONRPCUtils.createError(-32600 /* INVALID_REQUEST */, "Unknown message type"), validation.message.id || null);
|
|
5527
5541
|
}
|
|
5528
5542
|
} catch (error) {
|
|
5529
|
-
|
|
5543
|
+
logger2.error("Error processing JSON-RPC message:", error);
|
|
5530
5544
|
return JSONRPCUtils.createErrorResponse(this.config.errorHandler(error), validation.message.id || null);
|
|
5531
5545
|
}
|
|
5532
5546
|
}
|
|
5533
|
-
async
|
|
5547
|
+
async processMethod(request, options = {}) {
|
|
5534
5548
|
const context = {
|
|
5535
5549
|
...options,
|
|
5536
5550
|
request,
|
|
@@ -5550,7 +5564,7 @@ class JSONRPCManager extends JSONRPCCall {
|
|
|
5550
5564
|
}
|
|
5551
5565
|
return JSONRPCUtils.createSuccessResponse(result, request.id);
|
|
5552
5566
|
} catch (error) {
|
|
5553
|
-
|
|
5567
|
+
logger2.error(`Error executing method '${request.method}':`, error);
|
|
5554
5568
|
const jsonrpcError = this.config.errorHandler(error, context);
|
|
5555
5569
|
if (this.eventHandlers.onMethodError) {
|
|
5556
5570
|
this.eventHandlers.onMethodError(request.method, jsonrpcError, context);
|
|
@@ -5584,7 +5598,7 @@ class JSONRPCManager extends JSONRPCCall {
|
|
|
5584
5598
|
}
|
|
5585
5599
|
const promises = batchRequest.map((item) => {
|
|
5586
5600
|
if (JSONRPCUtils.isRequest(item)) {
|
|
5587
|
-
return this.
|
|
5601
|
+
return this.processMethod(item, options);
|
|
5588
5602
|
} else if (JSONRPCUtils.isNotification(item)) {
|
|
5589
5603
|
return this.processNotification(item, options);
|
|
5590
5604
|
}
|
|
@@ -5606,10 +5620,6 @@ class JSONRPCManager extends JSONRPCCall {
|
|
|
5606
5620
|
errorType
|
|
5607
5621
|
});
|
|
5608
5622
|
}
|
|
5609
|
-
sendMessage(message, options) {
|
|
5610
|
-
console.warn("JSONRPCManager.sendMessage not implemented - message not sent:");
|
|
5611
|
-
console.dir({ message, options }, { depth: null, color: true });
|
|
5612
|
-
}
|
|
5613
5623
|
sendNotification(method, params, options) {
|
|
5614
5624
|
const notification = JSONRPCUtils.createNotification(method, params);
|
|
5615
5625
|
return this.sendMessage(notification, options);
|
|
@@ -5623,7 +5633,7 @@ class JSONRPCManager extends JSONRPCCall {
|
|
|
5623
5633
|
unregisterMethod(methodName) {
|
|
5624
5634
|
const removed = this.methods.delete(methodName);
|
|
5625
5635
|
if (removed) {
|
|
5626
|
-
|
|
5636
|
+
logger2.info(`Unregistered JSON-RPC method: ${methodName}`);
|
|
5627
5637
|
}
|
|
5628
5638
|
return removed;
|
|
5629
5639
|
}
|
|
@@ -5637,12 +5647,9 @@ class JSONRPCManager extends JSONRPCCall {
|
|
|
5637
5647
|
}
|
|
5638
5648
|
async validateMessage(data, options = {}) {
|
|
5639
5649
|
try {
|
|
5640
|
-
const
|
|
5641
|
-
const message = JSONRPCUtils.deserialize(messageStr);
|
|
5650
|
+
const message = JSONRPCUtils.deserialize(data);
|
|
5642
5651
|
if (!message) {
|
|
5643
|
-
|
|
5644
|
-
const errorResponse = JSONRPCUtils.createErrorResponse(JSONRPCUtils.createError(-32700 /* PARSE_ERROR */, "Parse error"), null);
|
|
5645
|
-
return this.sendMessage(errorResponse, options);
|
|
5652
|
+
throw new ERROR_PARSE_ERROR("Failed to parse JSON-RPC message");
|
|
5646
5653
|
}
|
|
5647
5654
|
const validation = JSONRPCUtils.validateMessage(message);
|
|
5648
5655
|
if (!validation.valid) {
|
|
@@ -5655,7 +5662,7 @@ class JSONRPCManager extends JSONRPCCall {
|
|
|
5655
5662
|
}
|
|
5656
5663
|
} catch (err) {
|
|
5657
5664
|
const error = err;
|
|
5658
|
-
|
|
5665
|
+
logger2.error("Error handling validateMessage:", error);
|
|
5659
5666
|
const errorResponse = JSONRPCUtils.createErrorResponse(this.config.errorHandler(error), null);
|
|
5660
5667
|
return this.sendMessage(errorResponse, options);
|
|
5661
5668
|
}
|
|
@@ -57,7 +57,7 @@ export declare class ERROR_METHOD_NOT_FOUND extends ErrorCode {
|
|
|
57
57
|
/**
|
|
58
58
|
* Central JSON-RPC Manager class
|
|
59
59
|
*/
|
|
60
|
-
export declare class JSONRPCManager<TContext> extends JSONRPCCall {
|
|
60
|
+
export declare abstract class JSONRPCManager<TContext> extends JSONRPCCall {
|
|
61
61
|
private methods;
|
|
62
62
|
private config;
|
|
63
63
|
private eventHandlers;
|
|
@@ -69,7 +69,7 @@ export declare class JSONRPCManager<TContext> extends JSONRPCCall {
|
|
|
69
69
|
/**
|
|
70
70
|
* Process a JSON-RPC request
|
|
71
71
|
*/
|
|
72
|
-
private
|
|
72
|
+
private processMethod;
|
|
73
73
|
/**
|
|
74
74
|
* Process a JSON-RPC notification
|
|
75
75
|
*/
|
|
@@ -85,7 +85,7 @@ export declare class JSONRPCManager<TContext> extends JSONRPCCall {
|
|
|
85
85
|
/**
|
|
86
86
|
* Send a message (to be overridden by implementation)
|
|
87
87
|
*/
|
|
88
|
-
protected sendMessage(message: JSONRPCMessage, options?: TContext): any;
|
|
88
|
+
protected abstract sendMessage(message: JSONRPCMessage, options?: TContext): any;
|
|
89
89
|
/**
|
|
90
90
|
* Send a JSON-RPC notification (no response expected)
|
|
91
91
|
*/
|
|
@@ -113,7 +113,7 @@ export declare class JSONRPCManager<TContext> extends JSONRPCCall {
|
|
|
113
113
|
/**
|
|
114
114
|
* Process incoming WebSocket message
|
|
115
115
|
*/
|
|
116
|
-
validateMessage(data: string | Buffer, options?: any): Promise<void>;
|
|
116
|
+
validateMessage(data: string | Buffer | Record<string, any>, options?: any): Promise<void>;
|
|
117
117
|
/**
|
|
118
118
|
* Get manager statistics
|
|
119
119
|
*/
|
|
@@ -49,12 +49,13 @@ export interface AITool<T extends Record<string, unknown> | undefined = any, TPa
|
|
|
49
49
|
canAccess?: (auth: T) => boolean;
|
|
50
50
|
description?: string;
|
|
51
51
|
execute: (args: ToolParameters.InferOutput<TParams>, context?: any) => Promise<any>;
|
|
52
|
-
name
|
|
52
|
+
name?: string;
|
|
53
53
|
inputSchema?: TParams;
|
|
54
54
|
timeoutMs?: number;
|
|
55
55
|
}
|
|
56
56
|
export interface FastMCPTool<T extends Record<string, unknown> | undefined = any, TParams extends ToolParameters = ToolParameters> extends AITool<T, TParams> {
|
|
57
57
|
parameters?: TParams;
|
|
58
|
+
name: string;
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
* Type for a collection of AI tools with preserved schema types
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.12.
|
|
2
|
+
"version": "0.12.16",
|
|
3
3
|
"name": "modality-kit",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"author": "Hill <hill@kimo.com>",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@types/bun": "^1.2.
|
|
14
|
+
"@types/bun": "^1.2.23",
|
|
15
15
|
"typescript": "^5.9.2",
|
|
16
16
|
"zod": "^3.25.76"
|
|
17
17
|
},
|