modality-kit 0.12.12 → 0.12.14

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
@@ -5510,14 +5510,16 @@ class JSONRPCManager extends JSONRPCCall {
5510
5510
  case "request":
5511
5511
  return await this.processRequest(validation.message, options);
5512
5512
  case "notification":
5513
- return this.processNotification(validation.message, options);
5513
+ this.processNotification(validation.message, options);
5514
+ break;
5514
5515
  case "response":
5515
5516
  const response = validation.message;
5516
5517
  logger2.info("Received response message, handling internally", [
5517
5518
  response,
5518
5519
  response.id
5519
5520
  ]);
5520
- return this.handleResponse(response);
5521
+ this.handleResponse(response);
5522
+ break;
5521
5523
  case "batch":
5522
5524
  return await this.processBatchRequest(validation.message, options);
5523
5525
  default:
@@ -5565,15 +5567,14 @@ class JSONRPCManager extends JSONRPCCall {
5565
5567
  try {
5566
5568
  const methodConfig = this.methods.get(notification.method);
5567
5569
  if (!methodConfig) {
5568
- throw new ERROR_METHOD_NOT_FOUND(`Notification method '${notification.method}' not found`);
5570
+ throw new ERROR_METHOD_NOT_FOUND(`Notification method '${notification.method}' not handled.`);
5569
5571
  }
5570
5572
  if (this.eventHandlers.onMethodCall) {
5571
5573
  this.eventHandlers.onMethodCall(notification.method, notification.params, context);
5572
5574
  }
5573
5575
  return await methodConfig.handler(notification.params, context);
5574
5576
  } catch (error) {
5575
- console.error(`Error executing notification '${notification.method}':`, error);
5576
- throw error;
5577
+ logger2.info(`Notification get exception: '${notification.method}':`, error);
5577
5578
  }
5578
5579
  }
5579
5580
  async processBatchRequest(batchRequest, options = {}) {
@@ -5599,7 +5600,11 @@ class JSONRPCManager extends JSONRPCCall {
5599
5600
  if (error.message.includes("connection")) {
5600
5601
  return JSONRPCUtils.createError(-32002 /* CONNECTION_ERROR */, STANDARD_ERROR_MESSAGES[-32002 /* CONNECTION_ERROR */]);
5601
5602
  }
5602
- return JSONRPCUtils.createError(error?.code || -32603 /* INTERNAL_ERROR */, STANDARD_ERROR_MESSAGES[-32603 /* INTERNAL_ERROR */], { originalError: error.message });
5603
+ const code = error?.code || -32603 /* INTERNAL_ERROR */;
5604
+ const errorType = STANDARD_ERROR_MESSAGES[code];
5605
+ return JSONRPCUtils.createError(code, error.message || errorType, {
5606
+ errorType
5607
+ });
5603
5608
  }
5604
5609
  sendMessage(message, options) {
5605
5610
  console.warn("JSONRPCManager.sendMessage not implemented - message not sent:");
@@ -5650,8 +5655,8 @@ class JSONRPCManager extends JSONRPCCall {
5650
5655
  }
5651
5656
  } catch (err) {
5652
5657
  const error = err;
5653
- console.error("Error handling WebSocket message:", error);
5654
- const errorResponse = JSONRPCUtils.createErrorResponse(JSONRPCUtils.createError(-32603 /* INTERNAL_ERROR */, "Internal error"), null);
5658
+ console.error("Error handling validateMessage:", error);
5659
+ const errorResponse = JSONRPCUtils.createErrorResponse(this.config.errorHandler(error), null);
5655
5660
  return this.sendMessage(errorResponse, options);
5656
5661
  }
5657
5662
  }
@@ -5956,5 +5961,6 @@ export {
5956
5961
  JSONRPCManager,
5957
5962
  JSONRPCErrorCode,
5958
5963
  JSONRPCCall,
5959
- ErrorCode
5964
+ ErrorCode,
5965
+ ERROR_METHOD_NOT_FOUND
5960
5966
  };
@@ -18,6 +18,7 @@ export { JSONRPCManager } from "./jsonrpc-manager";
18
18
  export { JSONRPCErrorCode } from "./schemas/jsonrpc";
19
19
  export type { JSONRPCManagerEvents, JSONRPCManagerConfig, } from "./jsonrpc-manager";
20
20
  export type { JSONRPCMessage, JSONRPCRequest, JSONRPCNotification, JSONRPCResponse, JSONRPCBatchRequest, JSONRPCBatchResponse, JSONRPCErrorResponse, JSONRPCValidationResult, JSONRPCError, JSONRPCParams, CommandExecuteParams, NotificationSendParams, } from "./schemas/jsonrpc";
21
+ export { ERROR_METHOD_NOT_FOUND } from "./jsonrpc-manager";
21
22
  /**
22
23
  * For test tool
23
24
  */
@@ -1,4 +1,12 @@
1
+ /**
2
+ * JSON-RPC Manager
3
+ *
4
+ * Clean JSON-RPC 2.0 implementation for communication.
5
+ * Provides method registration, routing, and lifecycle management.
6
+ */
7
+ import { ErrorCode } from "./util_error";
1
8
  import { JSONRPCCall } from "./util_pending";
9
+ import { JSONRPCErrorCode } from "./schemas/jsonrpc";
2
10
  import type { JSONRPCRequest, JSONRPCMessage, JSONRPCError, JSONRPCParams } from "./schemas/jsonrpc";
3
11
  /**
4
12
  * Method handler function signature
@@ -43,6 +51,9 @@ export interface JSONRPCManagerEvents<TContext> {
43
51
  onMethodResponse?: (method: string, result: any, context: TContext) => void;
44
52
  onMethodError?: (method: string, error: JSONRPCError, context: TContext) => void;
45
53
  }
54
+ export declare class ERROR_METHOD_NOT_FOUND extends ErrorCode {
55
+ readonly code = JSONRPCErrorCode.METHOD_NOT_FOUND;
56
+ }
46
57
  /**
47
58
  * Central JSON-RPC Manager class
48
59
  */
@@ -74,7 +85,7 @@ export declare class JSONRPCManager<TContext> extends JSONRPCCall {
74
85
  /**
75
86
  * Send a message (to be overridden by implementation)
76
87
  */
77
- protected sendMessage(message: JSONRPCMessage, options: TContext): any;
88
+ protected sendMessage(message: JSONRPCMessage, options?: TContext): any;
78
89
  /**
79
90
  * Send a JSON-RPC notification (no response expected)
80
91
  */
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.12.12",
2
+ "version": "0.12.14",
3
3
  "name": "modality-kit",
4
4
  "repository": {
5
5
  "type": "git",
@@ -28,8 +28,8 @@
28
28
  "build:clean": "find ./dist -name '*.*' | xargs rm -rf",
29
29
  "build:types": "bun tsc -p ./",
30
30
  "build:src": "bun build src/index.ts --outdir dist",
31
- "build": "bun run build:clean && bun run build:src && bun run build:types",
32
- "dev": "bunx concurrently 'bunx --watch tsc -p ./' 'bun build:src -- --watch --sourcemap=inline'",
31
+ "build": "bun run build:clean && bun run build:types && bun run build:src",
32
+ "dev": "bunx concurrently 'bun --watch tsc -p ./' 'bun build:src -- --watch --sourcemap=inline'",
33
33
  "test": "bun test",
34
34
  "prepublishOnly": "npm run build && npm run test"
35
35
  },