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