modality-kit 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +55 -15
- package/dist/types/JSONRPCUtils.d.ts +74 -0
- package/dist/types/__tests__/lruCache.test.d.ts +1 -0
- package/dist/types/index.d.ts +7 -1
- package/dist/types/lruCache.d.ts +8 -0
- package/dist/types/schemas/jsonrpc.d.ts +0 -67
- package/dist/types/util_tests/isTestEnvironment.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5018,7 +5018,23 @@ var JSONRPCErrorCode;
|
|
|
5018
5018
|
JSONRPCErrorCode2[JSONRPCErrorCode2["RATE_LIMIT_ERROR"] = -32005] = "RATE_LIMIT_ERROR";
|
|
5019
5019
|
JSONRPCErrorCode2[JSONRPCErrorCode2["VALIDATION_ERROR"] = -32006] = "VALIDATION_ERROR";
|
|
5020
5020
|
})(JSONRPCErrorCode ||= {});
|
|
5021
|
+
var STANDARD_ERROR_MESSAGES = {
|
|
5022
|
+
[-32700 /* PARSE_ERROR */]: "Parse error",
|
|
5023
|
+
[-32600 /* INVALID_REQUEST */]: "Invalid Request",
|
|
5024
|
+
[-32601 /* METHOD_NOT_FOUND */]: "Method not found",
|
|
5025
|
+
[-32602 /* INVALID_PARAMS */]: "Invalid params",
|
|
5026
|
+
[-32603 /* INTERNAL_ERROR */]: "Internal error",
|
|
5027
|
+
[-32099 /* SERVER_ERROR_START */]: "Server error",
|
|
5028
|
+
[-32000 /* SERVER_ERROR_END */]: "Server error",
|
|
5029
|
+
[-32001 /* TIMEOUT_ERROR */]: "Request timeout",
|
|
5030
|
+
[-32002 /* CONNECTION_ERROR */]: "Connection error",
|
|
5031
|
+
[-32003 /* AUTHENTICATION_ERROR */]: "Authentication required",
|
|
5032
|
+
[-32004 /* AUTHORIZATION_ERROR */]: "Authorization failed",
|
|
5033
|
+
[-32005 /* RATE_LIMIT_ERROR */]: "Rate limit exceeded",
|
|
5034
|
+
[-32006 /* VALIDATION_ERROR */]: "Validation error"
|
|
5035
|
+
};
|
|
5021
5036
|
|
|
5037
|
+
// src/JSONRPCUtils.ts
|
|
5022
5038
|
class JSONRPCUtils {
|
|
5023
5039
|
static validateMessage(message) {
|
|
5024
5040
|
if (Array.isArray(message)) {
|
|
@@ -5153,21 +5169,6 @@ class JSONRPCUtils {
|
|
|
5153
5169
|
}
|
|
5154
5170
|
}
|
|
5155
5171
|
}
|
|
5156
|
-
var STANDARD_ERROR_MESSAGES = {
|
|
5157
|
-
[-32700 /* PARSE_ERROR */]: "Parse error",
|
|
5158
|
-
[-32600 /* INVALID_REQUEST */]: "Invalid Request",
|
|
5159
|
-
[-32601 /* METHOD_NOT_FOUND */]: "Method not found",
|
|
5160
|
-
[-32602 /* INVALID_PARAMS */]: "Invalid params",
|
|
5161
|
-
[-32603 /* INTERNAL_ERROR */]: "Internal error",
|
|
5162
|
-
[-32099 /* SERVER_ERROR_START */]: "Server error",
|
|
5163
|
-
[-32000 /* SERVER_ERROR_END */]: "Server error",
|
|
5164
|
-
[-32001 /* TIMEOUT_ERROR */]: "Request timeout",
|
|
5165
|
-
[-32002 /* CONNECTION_ERROR */]: "Connection error",
|
|
5166
|
-
[-32003 /* AUTHENTICATION_ERROR */]: "Authentication required",
|
|
5167
|
-
[-32004 /* AUTHORIZATION_ERROR */]: "Authorization failed",
|
|
5168
|
-
[-32005 /* RATE_LIMIT_ERROR */]: "Rate limit exceeded",
|
|
5169
|
-
[-32006 /* VALIDATION_ERROR */]: "Validation error"
|
|
5170
|
-
};
|
|
5171
5172
|
|
|
5172
5173
|
// src/util_pending.ts
|
|
5173
5174
|
class PendingOperationsBase {
|
|
@@ -5886,10 +5887,48 @@ class WebSocketClient {
|
|
|
5886
5887
|
}
|
|
5887
5888
|
}
|
|
5888
5889
|
}
|
|
5890
|
+
// src/lruCache.ts
|
|
5891
|
+
class LruCache {
|
|
5892
|
+
values = new Map;
|
|
5893
|
+
max;
|
|
5894
|
+
constructor(max = 100) {
|
|
5895
|
+
this.max = max;
|
|
5896
|
+
}
|
|
5897
|
+
has(key) {
|
|
5898
|
+
return this.values.has(key);
|
|
5899
|
+
}
|
|
5900
|
+
get(key) {
|
|
5901
|
+
const value = this.values.get(key);
|
|
5902
|
+
if (value) {
|
|
5903
|
+
this.values.delete(key);
|
|
5904
|
+
this.values.set(key, value);
|
|
5905
|
+
}
|
|
5906
|
+
return value;
|
|
5907
|
+
}
|
|
5908
|
+
set(key, value) {
|
|
5909
|
+
if (this.values.size >= this.max) {
|
|
5910
|
+
const itemsToEvictCount = Math.max(1, Math.floor(this.max * 0.25));
|
|
5911
|
+
const keys = this.values.keys();
|
|
5912
|
+
let count = 0;
|
|
5913
|
+
while (count < itemsToEvictCount) {
|
|
5914
|
+
const next = keys.next();
|
|
5915
|
+
if (next.done) {
|
|
5916
|
+
break;
|
|
5917
|
+
}
|
|
5918
|
+
this.values.delete(next.value);
|
|
5919
|
+
count++;
|
|
5920
|
+
}
|
|
5921
|
+
}
|
|
5922
|
+
this.values.set(key, value);
|
|
5923
|
+
}
|
|
5924
|
+
}
|
|
5925
|
+
// src/util_tests/isTestEnvironment.ts
|
|
5926
|
+
var isTestEnvironment = globalThis.Bun?.main?.includes?.("test");
|
|
5889
5927
|
export {
|
|
5890
5928
|
withErrorHandling,
|
|
5891
5929
|
setupAITools,
|
|
5892
5930
|
loadVersion,
|
|
5931
|
+
isTestEnvironment,
|
|
5893
5932
|
getLoggerInstance,
|
|
5894
5933
|
formatSuccessResponse,
|
|
5895
5934
|
formatErrorResponse,
|
|
@@ -5898,6 +5937,7 @@ export {
|
|
|
5898
5937
|
compressWithLanguageDetection as compressText,
|
|
5899
5938
|
WebSocketClient,
|
|
5900
5939
|
exports_schemas_symbol as SymbolTypes,
|
|
5940
|
+
LruCache,
|
|
5901
5941
|
JSONRPCUtils,
|
|
5902
5942
|
JSONRPCManager,
|
|
5903
5943
|
JSONRPCErrorCode,
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC 2.0 Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Utility class for JSON-RPC message handling, validation, and creation.
|
|
5
|
+
* Extracted from schemas/jsonrpc.ts for independent use.
|
|
6
|
+
*/
|
|
7
|
+
import { JSONRPCErrorCode, type JSONRPCParams, type JSONRPCId, type JSONRPCRequest, type JSONRPCNotification, type JSONRPCSuccessResponse, type JSONRPCErrorResponse, type JSONRPCError, type JSONRPCResponse, type JSONRPCMessage, type JSONRPCValidationResult } from './schemas/jsonrpc.js';
|
|
8
|
+
/**
|
|
9
|
+
* Utility functions for JSON-RPC message handling
|
|
10
|
+
*/
|
|
11
|
+
export declare class JSONRPCUtils {
|
|
12
|
+
/**
|
|
13
|
+
* Validate a JSON-RPC message (supports batch requests)
|
|
14
|
+
*/
|
|
15
|
+
static validateMessage(message: any): JSONRPCValidationResult;
|
|
16
|
+
/**
|
|
17
|
+
* Validate a single JSON-RPC message
|
|
18
|
+
*/
|
|
19
|
+
static validateSingleMessage(message: any): JSONRPCValidationResult;
|
|
20
|
+
/**
|
|
21
|
+
* Create a JSON-RPC request
|
|
22
|
+
*/
|
|
23
|
+
static createRequest(method: string, params?: JSONRPCParams, options?: {
|
|
24
|
+
customId?: JSONRPCId;
|
|
25
|
+
}): JSONRPCRequest;
|
|
26
|
+
/**
|
|
27
|
+
* Create a JSON-RPC notification
|
|
28
|
+
*/
|
|
29
|
+
static createNotification(method: string, params?: JSONRPCParams): JSONRPCNotification;
|
|
30
|
+
/**
|
|
31
|
+
* Create a JSON-RPC success response
|
|
32
|
+
*/
|
|
33
|
+
static createSuccessResponse(result: any, id: JSONRPCId): JSONRPCSuccessResponse;
|
|
34
|
+
/**
|
|
35
|
+
* Create a JSON-RPC error response
|
|
36
|
+
*/
|
|
37
|
+
static createErrorResponse(error: JSONRPCError, id: JSONRPCId): JSONRPCErrorResponse;
|
|
38
|
+
/**
|
|
39
|
+
* Create a standard JSON-RPC error
|
|
40
|
+
*/
|
|
41
|
+
static createError(code: JSONRPCErrorCode | number, message: string, data?: any): JSONRPCError;
|
|
42
|
+
/**
|
|
43
|
+
* Generate a unique ID for requests
|
|
44
|
+
*/
|
|
45
|
+
static generateId(): string;
|
|
46
|
+
/**
|
|
47
|
+
* Check if a message is a JSON-RPC request
|
|
48
|
+
*/
|
|
49
|
+
static isRequest(message: any): message is JSONRPCRequest;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a message is a JSON-RPC notification
|
|
52
|
+
*/
|
|
53
|
+
static isNotification(message: any): message is JSONRPCNotification;
|
|
54
|
+
/**
|
|
55
|
+
* Check if a message is a JSON-RPC response
|
|
56
|
+
*/
|
|
57
|
+
static isResponse(message: any): message is JSONRPCResponse;
|
|
58
|
+
/**
|
|
59
|
+
* Check if a response is a success response
|
|
60
|
+
*/
|
|
61
|
+
static isSuccessResponse(response: JSONRPCResponse): response is JSONRPCSuccessResponse;
|
|
62
|
+
/**
|
|
63
|
+
* Check if a response is an error response
|
|
64
|
+
*/
|
|
65
|
+
static isErrorResponse(response: JSONRPCResponse): response is JSONRPCErrorResponse;
|
|
66
|
+
/**
|
|
67
|
+
* Serialize a JSON-RPC message to string
|
|
68
|
+
*/
|
|
69
|
+
static serialize(message: JSONRPCMessage): string;
|
|
70
|
+
/**
|
|
71
|
+
* Deserialize a JSON-RPC message from string
|
|
72
|
+
*/
|
|
73
|
+
static deserialize(data: string): JSONRPCMessage | null;
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,8 +10,14 @@ export { loadVersion } from "./util_version";
|
|
|
10
10
|
export { compressWithLanguageDetection as compressText } from "./util_text_compression";
|
|
11
11
|
export { JSONRPCCall, createDataPendingOperations } from "./util_pending";
|
|
12
12
|
export type { DataPendingOperation, PendingOperation } from "./util_pending";
|
|
13
|
-
export { JSONRPCUtils
|
|
13
|
+
export { JSONRPCUtils } from "./JSONRPCUtils";
|
|
14
|
+
export { JSONRPCErrorCode } from "./schemas/jsonrpc";
|
|
14
15
|
export type { JSONRPCMessage, JSONRPCRequest, JSONRPCNotification, JSONRPCResponse, JSONRPCBatchRequest, JSONRPCBatchResponse, JSONRPCErrorResponse, JSONRPCValidationResult, JSONRPCError, JSONRPCParams, CommandExecuteParams, NotificationSendParams, } from "./schemas/jsonrpc";
|
|
15
16
|
export { JSONRPCManager } from "./jsonrpc-manager";
|
|
16
17
|
export type { JSONRPCManagerEvents, JSONRPCManagerConfig, } from "./jsonrpc-manager";
|
|
17
18
|
export { WebSocketClient } from "./websocket-client";
|
|
19
|
+
export { LruCache } from "./lruCache";
|
|
20
|
+
/**
|
|
21
|
+
* For test tool
|
|
22
|
+
*/
|
|
23
|
+
export { isTestEnvironment } from "./util_tests/isTestEnvironment";
|
|
@@ -153,73 +153,6 @@ export interface JSONRPCValidationResult {
|
|
|
153
153
|
/** Parsed message type */
|
|
154
154
|
messageType?: "request" | "notification" | "response" | "batch";
|
|
155
155
|
}
|
|
156
|
-
/**
|
|
157
|
-
* Utility functions for JSON-RPC message handling
|
|
158
|
-
*/
|
|
159
|
-
export declare class JSONRPCUtils {
|
|
160
|
-
/**
|
|
161
|
-
* Validate a JSON-RPC message (supports batch requests)
|
|
162
|
-
*/
|
|
163
|
-
static validateMessage(message: any): JSONRPCValidationResult;
|
|
164
|
-
/**
|
|
165
|
-
* Validate a single JSON-RPC message
|
|
166
|
-
*/
|
|
167
|
-
static validateSingleMessage(message: any): JSONRPCValidationResult;
|
|
168
|
-
/**
|
|
169
|
-
* Create a JSON-RPC request
|
|
170
|
-
*/
|
|
171
|
-
static createRequest(method: string, params?: JSONRPCParams, options?: {
|
|
172
|
-
customId?: JSONRPCId;
|
|
173
|
-
}): JSONRPCRequest;
|
|
174
|
-
/**
|
|
175
|
-
* Create a JSON-RPC notification
|
|
176
|
-
*/
|
|
177
|
-
static createNotification(method: string, params?: JSONRPCParams): JSONRPCNotification;
|
|
178
|
-
/**
|
|
179
|
-
* Create a JSON-RPC success response
|
|
180
|
-
*/
|
|
181
|
-
static createSuccessResponse(result: any, id: JSONRPCId): JSONRPCSuccessResponse;
|
|
182
|
-
/**
|
|
183
|
-
* Create a JSON-RPC error response
|
|
184
|
-
*/
|
|
185
|
-
static createErrorResponse(error: JSONRPCError, id: JSONRPCId): JSONRPCErrorResponse;
|
|
186
|
-
/**
|
|
187
|
-
* Create a standard JSON-RPC error
|
|
188
|
-
*/
|
|
189
|
-
static createError(code: JSONRPCErrorCode | number, message: string, data?: any): JSONRPCError;
|
|
190
|
-
/**
|
|
191
|
-
* Generate a unique ID for requests
|
|
192
|
-
*/
|
|
193
|
-
static generateId(): string;
|
|
194
|
-
/**
|
|
195
|
-
* Check if a message is a JSON-RPC request
|
|
196
|
-
*/
|
|
197
|
-
static isRequest(message: any): message is JSONRPCRequest;
|
|
198
|
-
/**
|
|
199
|
-
* Check if a message is a JSON-RPC notification
|
|
200
|
-
*/
|
|
201
|
-
static isNotification(message: any): message is JSONRPCNotification;
|
|
202
|
-
/**
|
|
203
|
-
* Check if a message is a JSON-RPC response
|
|
204
|
-
*/
|
|
205
|
-
static isResponse(message: any): message is JSONRPCResponse;
|
|
206
|
-
/**
|
|
207
|
-
* Check if a response is a success response
|
|
208
|
-
*/
|
|
209
|
-
static isSuccessResponse(response: JSONRPCResponse): response is JSONRPCSuccessResponse;
|
|
210
|
-
/**
|
|
211
|
-
* Check if a response is an error response
|
|
212
|
-
*/
|
|
213
|
-
static isErrorResponse(response: JSONRPCResponse): response is JSONRPCErrorResponse;
|
|
214
|
-
/**
|
|
215
|
-
* Serialize a JSON-RPC message to string
|
|
216
|
-
*/
|
|
217
|
-
static serialize(message: JSONRPCMessage): string;
|
|
218
|
-
/**
|
|
219
|
-
* Deserialize a JSON-RPC message from string
|
|
220
|
-
*/
|
|
221
|
-
static deserialize(data: string): JSONRPCMessage | null;
|
|
222
|
-
}
|
|
223
156
|
/**
|
|
224
157
|
* Standard error messages for common JSON-RPC errors
|
|
225
158
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isTestEnvironment: boolean;
|
package/package.json
CHANGED