@haex-space/vault-sdk 5.4.0 → 5.4.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/react.js CHANGED
@@ -2663,6 +2663,7 @@ function validateInput(schema, value) {
2663
2663
  var PROTOCOL_VERSION = "2025-11-25";
2664
2664
  var METHOD_NOT_FOUND = -32601;
2665
2665
  var INVALID_PARAMS = -32602;
2666
+ var INTERNAL_ERROR = -32603;
2666
2667
  function textResult(text, isError) {
2667
2668
  return { content: [{ type: "text", text }], isError };
2668
2669
  }
@@ -2748,11 +2749,30 @@ var ToolsServer = class {
2748
2749
  }
2749
2750
  if (!controller.signal.aborted) this.reply(id, result);
2750
2751
  }
2752
+ /**
2753
+ * Answers `id`. An answer that cannot be sent gets an error instead, so the host never waits for
2754
+ * an answer that will not come.
2755
+ */
2751
2756
  reply(id, result) {
2752
- this.options.send({ jsonrpc: "2.0", id, result });
2757
+ try {
2758
+ this.send({ jsonrpc: "2.0", id, result });
2759
+ } catch (error) {
2760
+ const reason = error instanceof Error ? error.message : String(error);
2761
+ console.warn(`[vault-sdk] tools: answer ${String(id)} could not be sent: ${reason}`);
2762
+ this.error(id, INTERNAL_ERROR, `the answer could not be sent: ${reason}`);
2763
+ }
2753
2764
  }
2754
2765
  error(id, code, message) {
2755
- this.options.send({ jsonrpc: "2.0", id, error: { code, message } });
2766
+ this.send({ jsonrpc: "2.0", id, error: { code, message } });
2767
+ }
2768
+ /**
2769
+ * Sends a JSON copy. The manifest of a Nuxt extension comes from its runtime config, a Vue
2770
+ * reactive proxy, and `postMessage` cannot clone a proxy: the input schemas of `tools/list`
2771
+ * would throw a `DataCloneError` and the host would never get the list. JSON-RPC is JSON, so the
2772
+ * copy loses nothing.
2773
+ */
2774
+ send(message) {
2775
+ this.options.send(JSON.parse(JSON.stringify(message)));
2756
2776
  }
2757
2777
  };
2758
2778