modality-kit 0.9.0 → 0.9.1

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
@@ -5474,62 +5474,6 @@ class JSONRPCManager extends JSONRPCCall {
5474
5474
  };
5475
5475
  this.eventHandlers = eventHandlers;
5476
5476
  }
5477
- registerMethod(methodName, config) {
5478
- if (this.methods.has(methodName)) {
5479
- throw new Error(`Method '${methodName}' is already registered`);
5480
- }
5481
- this.methods.set(methodName, config);
5482
- console.log(`Registered JSON-RPC method: ${methodName}`);
5483
- }
5484
- unregisterMethod(methodName) {
5485
- const removed = this.methods.delete(methodName);
5486
- if (removed) {
5487
- console.log(`Unregistered JSON-RPC method: ${methodName}`);
5488
- }
5489
- return removed;
5490
- }
5491
- getRegisteredMethods() {
5492
- return Array.from(this.methods.keys());
5493
- }
5494
- handleRequest(method, params, options = {}) {
5495
- const { promise, request } = super.handleRequest(method, params, options);
5496
- this.sendMessage(request, options);
5497
- return { promise, request };
5498
- }
5499
- sendNotification(method, params, options) {
5500
- const notification = JSONRPCUtils.createNotification(method, params);
5501
- this.sendMessage(notification, options);
5502
- }
5503
- sendMessage(message, options) {
5504
- console.warn("JSONRPCManager.sendMessage not implemented - message not sent:", message, options);
5505
- }
5506
- async validateMessage(data, options = {}) {
5507
- try {
5508
- const messageStr = typeof data === "string" ? data : data.toString();
5509
- const message = JSONRPCUtils.deserialize(messageStr);
5510
- if (!message) {
5511
- console.error("Failed to parse JSON-RPC message:", messageStr);
5512
- const errorResponse = JSONRPCUtils.createErrorResponse(JSONRPCUtils.createError(-32700 /* PARSE_ERROR */, "Parse error"), null);
5513
- this.sendMessage(errorResponse, options);
5514
- return;
5515
- }
5516
- const validation = JSONRPCUtils.validateMessage(message);
5517
- if (!validation.valid) {
5518
- const errorResponse = JSONRPCUtils.createErrorResponse(validation.error, message.id || null);
5519
- this.sendMessage(errorResponse, options);
5520
- return;
5521
- }
5522
- const response = await this.processMessage(validation, options);
5523
- if (response && (!Array.isArray(response) || response.length > 0)) {
5524
- this.sendMessage(response, options);
5525
- }
5526
- } catch (err) {
5527
- const error = err;
5528
- console.error("Error handling WebSocket message:", error);
5529
- const errorResponse = JSONRPCUtils.createErrorResponse(JSONRPCUtils.createError(-32603 /* INTERNAL_ERROR */, "Internal error"), null);
5530
- this.sendMessage(errorResponse, options);
5531
- }
5532
- }
5533
5477
  async processMessage(validation, options = {}) {
5534
5478
  try {
5535
5479
  switch (validation.messageType) {
@@ -5633,6 +5577,62 @@ class JSONRPCManager extends JSONRPCCall {
5633
5577
  }
5634
5578
  return JSONRPCUtils.createError(-32603 /* INTERNAL_ERROR */, STANDARD_ERROR_MESSAGES[-32603 /* INTERNAL_ERROR */], { originalError: error.message });
5635
5579
  }
5580
+ sendMessage(message, options) {
5581
+ console.warn("JSONRPCManager.sendMessage not implemented - message not sent:", message, options);
5582
+ }
5583
+ sendNotification(method, params, options) {
5584
+ const notification = JSONRPCUtils.createNotification(method, params);
5585
+ this.sendMessage(notification, options);
5586
+ }
5587
+ registerMethod(methodName, config) {
5588
+ if (this.methods.has(methodName)) {
5589
+ throw new Error(`Method '${methodName}' is already registered`);
5590
+ }
5591
+ this.methods.set(methodName, config);
5592
+ console.log(`Registered JSON-RPC method: ${methodName}`);
5593
+ }
5594
+ unregisterMethod(methodName) {
5595
+ const removed = this.methods.delete(methodName);
5596
+ if (removed) {
5597
+ console.log(`Unregistered JSON-RPC method: ${methodName}`);
5598
+ }
5599
+ return removed;
5600
+ }
5601
+ getRegisteredMethods() {
5602
+ return Array.from(this.methods.keys());
5603
+ }
5604
+ handleRequest(method, params, options = {}) {
5605
+ const { promise, request } = super.handleRequest(method, params, options);
5606
+ this.sendMessage(request, options);
5607
+ return { promise, request };
5608
+ }
5609
+ async validateMessage(data, options = {}) {
5610
+ try {
5611
+ const messageStr = typeof data === "string" ? data : data.toString();
5612
+ const message = JSONRPCUtils.deserialize(messageStr);
5613
+ if (!message) {
5614
+ console.error("Failed to parse JSON-RPC message:", messageStr);
5615
+ const errorResponse = JSONRPCUtils.createErrorResponse(JSONRPCUtils.createError(-32700 /* PARSE_ERROR */, "Parse error"), null);
5616
+ this.sendMessage(errorResponse, options);
5617
+ return;
5618
+ }
5619
+ const validation = JSONRPCUtils.validateMessage(message);
5620
+ if (!validation.valid) {
5621
+ const errorResponse = JSONRPCUtils.createErrorResponse(validation.error, message.id || null);
5622
+ this.sendMessage(errorResponse, options);
5623
+ return;
5624
+ }
5625
+ const response = await this.processMessage(validation, options);
5626
+ if (response && (!Array.isArray(response) || response.length > 0)) {
5627
+ this.sendMessage(response, options);
5628
+ }
5629
+ } catch (err) {
5630
+ const error = err;
5631
+ console.error("Error handling WebSocket message:", error);
5632
+ const errorResponse = JSONRPCUtils.createErrorResponse(JSONRPCUtils.createError(-32603 /* INTERNAL_ERROR */, "Internal error"), null);
5633
+ this.sendMessage(errorResponse, options);
5634
+ }
5635
+ }
5636
5636
  getStats() {
5637
5637
  const parentStats = super.getStats();
5638
5638
  return {
@@ -58,56 +58,56 @@ export declare class JSONRPCManager<TContext> extends JSONRPCCall {
58
58
  private eventHandlers;
59
59
  constructor(config?: JSONRPCManagerConfig<TContext>, eventHandlers?: JSONRPCManagerEvents<TContext>);
60
60
  /**
61
- * Register a JSON-RPC method
61
+ * Process incoming JSON-RPC message (supports batch requests)
62
62
  */
63
- registerMethod<T = JSONRPCParams>(methodName: string, config: JSONRPCMethodConfig<TContext, T>): void;
63
+ private processMessage;
64
64
  /**
65
- * Unregister a JSON-RPC method
65
+ * Process a JSON-RPC request
66
66
  */
67
- unregisterMethod(methodName: string): boolean;
67
+ private processRequest;
68
68
  /**
69
- * Get registered method names
69
+ * Process a JSON-RPC notification
70
70
  */
71
- getRegisteredMethods(): string[];
71
+ private processNotification;
72
72
  /**
73
- * Send a JSON-RPC request and return a promise for the response
73
+ * Process a JSON-RPC batch request
74
74
  */
75
- handleRequest(method: string, params?: any, options?: any): {
76
- promise: Promise<any>;
77
- request: JSONRPCRequest;
78
- };
75
+ private processBatchRequest;
79
76
  /**
80
- * Send a JSON-RPC notification (no response expected)
77
+ * Default error handler
81
78
  */
82
- sendNotification(method: string, params: any, options: TContext): void;
79
+ private defaultErrorHandler;
83
80
  /**
84
81
  * Send a message (to be overridden by WebSocket implementation)
85
82
  */
86
83
  protected sendMessage(message: JSONRPCMessage, options: TContext): void;
87
84
  /**
88
- * Process incoming WebSocket message
85
+ * Send a JSON-RPC notification (no response expected)
89
86
  */
90
- validateMessage(data: string | Buffer, options?: any): Promise<void>;
87
+ sendNotification(method: string, params: any, options: TContext): void;
91
88
  /**
92
- * Process incoming JSON-RPC message (supports batch requests)
89
+ * Register a JSON-RPC method
93
90
  */
94
- private processMessage;
91
+ registerMethod<T = JSONRPCParams>(methodName: string, config: JSONRPCMethodConfig<TContext, T>): void;
95
92
  /**
96
- * Process a JSON-RPC request
93
+ * Unregister a JSON-RPC method
97
94
  */
98
- private processRequest;
95
+ unregisterMethod(methodName: string): boolean;
99
96
  /**
100
- * Process a JSON-RPC notification
97
+ * Get registered method names
101
98
  */
102
- private processNotification;
99
+ getRegisteredMethods(): string[];
103
100
  /**
104
- * Process a JSON-RPC batch request
101
+ * Send a JSON-RPC request and return a promise for the response
105
102
  */
106
- private processBatchRequest;
103
+ handleRequest(method: string, params?: any, options?: any): {
104
+ promise: Promise<any>;
105
+ request: JSONRPCRequest;
106
+ };
107
107
  /**
108
- * Default error handler
108
+ * Process incoming WebSocket message
109
109
  */
110
- private defaultErrorHandler;
110
+ validateMessage(data: string | Buffer, options?: any): Promise<void>;
111
111
  /**
112
112
  * Get manager statistics
113
113
  */
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.9.0",
2
+ "version": "0.9.1",
3
3
  "name": "modality-kit",
4
4
  "repository": {
5
5
  "type": "git",