@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.
@@ -2201,6 +2201,7 @@ function validateInput(schema, value) {
2201
2201
  var PROTOCOL_VERSION = "2025-11-25";
2202
2202
  var METHOD_NOT_FOUND = -32601;
2203
2203
  var INVALID_PARAMS = -32602;
2204
+ var INTERNAL_ERROR = -32603;
2204
2205
  function textResult(text, isError) {
2205
2206
  return { content: [{ type: "text", text }], isError };
2206
2207
  }
@@ -2286,11 +2287,30 @@ var ToolsServer = class {
2286
2287
  }
2287
2288
  if (!controller.signal.aborted) this.reply(id, result);
2288
2289
  }
2290
+ /**
2291
+ * Answers `id`. An answer that cannot be sent gets an error instead, so the host never waits for
2292
+ * an answer that will not come.
2293
+ */
2289
2294
  reply(id, result) {
2290
- this.options.send({ jsonrpc: "2.0", id, result });
2295
+ try {
2296
+ this.send({ jsonrpc: "2.0", id, result });
2297
+ } catch (error) {
2298
+ const reason = error instanceof Error ? error.message : String(error);
2299
+ console.warn(`[vault-sdk] tools: answer ${String(id)} could not be sent: ${reason}`);
2300
+ this.error(id, INTERNAL_ERROR, `the answer could not be sent: ${reason}`);
2301
+ }
2291
2302
  }
2292
2303
  error(id, code, message) {
2293
- this.options.send({ jsonrpc: "2.0", id, error: { code, message } });
2304
+ this.send({ jsonrpc: "2.0", id, error: { code, message } });
2305
+ }
2306
+ /**
2307
+ * Sends a JSON copy. The manifest of a Nuxt extension comes from its runtime config, a Vue
2308
+ * reactive proxy, and `postMessage` cannot clone a proxy: the input schemas of `tools/list`
2309
+ * would throw a `DataCloneError` and the host would never get the list. JSON-RPC is JSON, so the
2310
+ * copy loses nothing.
2311
+ */
2312
+ send(message) {
2313
+ this.options.send(JSON.parse(JSON.stringify(message)));
2294
2314
  }
2295
2315
  };
2296
2316