@haex-space/vault-sdk 5.4.1 → 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/index.mjs CHANGED
@@ -3104,6 +3104,7 @@ function validateInput(schema, value) {
3104
3104
  var PROTOCOL_VERSION = "2025-11-25";
3105
3105
  var METHOD_NOT_FOUND = -32601;
3106
3106
  var INVALID_PARAMS = -32602;
3107
+ var INTERNAL_ERROR = -32603;
3107
3108
  function textResult(text, isError) {
3108
3109
  return { content: [{ type: "text", text }], isError };
3109
3110
  }
@@ -3189,11 +3190,30 @@ var ToolsServer = class {
3189
3190
  }
3190
3191
  if (!controller.signal.aborted) this.reply(id, result);
3191
3192
  }
3193
+ /**
3194
+ * Answers `id`. An answer that cannot be sent gets an error instead, so the host never waits for
3195
+ * an answer that will not come.
3196
+ */
3192
3197
  reply(id, result) {
3193
- this.options.send({ jsonrpc: "2.0", id, result });
3198
+ try {
3199
+ this.send({ jsonrpc: "2.0", id, result });
3200
+ } catch (error) {
3201
+ const reason = error instanceof Error ? error.message : String(error);
3202
+ console.warn(`[vault-sdk] tools: answer ${String(id)} could not be sent: ${reason}`);
3203
+ this.error(id, INTERNAL_ERROR, `the answer could not be sent: ${reason}`);
3204
+ }
3194
3205
  }
3195
3206
  error(id, code, message) {
3196
- this.options.send({ jsonrpc: "2.0", id, error: { code, message } });
3207
+ this.send({ jsonrpc: "2.0", id, error: { code, message } });
3208
+ }
3209
+ /**
3210
+ * Sends a JSON copy. The manifest of a Nuxt extension comes from its runtime config, a Vue
3211
+ * reactive proxy, and `postMessage` cannot clone a proxy: the input schemas of `tools/list`
3212
+ * would throw a `DataCloneError` and the host would never get the list. JSON-RPC is JSON, so the
3213
+ * copy loses nothing.
3214
+ */
3215
+ send(message) {
3216
+ this.options.send(JSON.parse(JSON.stringify(message)));
3197
3217
  }
3198
3218
  };
3199
3219