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