@haex-space/vault-sdk 5.4.1 → 5.5.0

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.
@@ -398,6 +398,10 @@ var MAIL_COMMANDS = {
398
398
  search: "extension_mail_search",
399
399
  /** CREATE a mailbox (reports whether it was already there) */
400
400
  createMailbox: "extension_mail_create_mailbox",
401
+ /** DELETE a mailbox (never INBOX) */
402
+ deleteMailbox: "extension_mail_delete_mailbox",
403
+ /** RENAME a mailbox (never INBOX) */
404
+ renameMailbox: "extension_mail_rename_mailbox",
401
405
  /** Delete messages for good: `\Deleted` plus UID EXPUNGE of exactly those UIDs */
402
406
  deleteMessages: "extension_mail_delete_messages",
403
407
  /** Set or unset IMAP flags on a UID set */
@@ -1929,6 +1933,25 @@ var MailAPI = class {
1929
1933
  );
1930
1934
  return created;
1931
1935
  }
1936
+ /**
1937
+ * Delete a mailbox. `mailbox` is the IMAP-encoded name (modified UTF-7), like in every other
1938
+ * call. `INBOX` can be neither deleted nor renamed; the host refuses it. Whether the mailbox's
1939
+ * messages and child mailboxes go with it, and whether a missing mailbox is an error, is up to
1940
+ * the server. Needs the same `fetch` permission as the other IMAP calls.
1941
+ */
1942
+ async deleteMailboxAsync(imap, mailbox) {
1943
+ return this.client.request(MAIL_COMMANDS.deleteMailbox, { imap, mailbox });
1944
+ }
1945
+ /**
1946
+ * Rename a mailbox from `from` to `to`, both IMAP-encoded names (modified UTF-7). `to` may
1947
+ * contain the server's hierarchy delimiter to move the mailbox in the tree; `*` and `%` are not
1948
+ * allowed. `INBOX` can be neither deleted nor renamed; the host refuses it. Whether child
1949
+ * mailboxes follow and whether an existing `to` is an error is up to the server. Needs the same
1950
+ * `fetch` permission as the other IMAP calls.
1951
+ */
1952
+ async renameMailboxAsync(imap, from, to) {
1953
+ return this.client.request(MAIL_COMMANDS.renameMailbox, { imap, from, to });
1954
+ }
1932
1955
  /**
1933
1956
  * Delete messages for good: flags exactly these UIDs `\Deleted` and expunges exactly them, so
1934
1957
  * other messages marked `\Deleted` stay. Refused with an error on a server without UIDPLUS,
@@ -2203,6 +2226,7 @@ function validateInput(schema, value) {
2203
2226
  var PROTOCOL_VERSION = "2025-11-25";
2204
2227
  var METHOD_NOT_FOUND = -32601;
2205
2228
  var INVALID_PARAMS = -32602;
2229
+ var INTERNAL_ERROR = -32603;
2206
2230
  function textResult(text, isError) {
2207
2231
  return { content: [{ type: "text", text }], isError };
2208
2232
  }
@@ -2288,11 +2312,30 @@ var ToolsServer = class {
2288
2312
  }
2289
2313
  if (!controller.signal.aborted) this.reply(id, result);
2290
2314
  }
2315
+ /**
2316
+ * Answers `id`. An answer that cannot be sent gets an error instead, so the host never waits for
2317
+ * an answer that will not come.
2318
+ */
2291
2319
  reply(id, result) {
2292
- this.options.send({ jsonrpc: "2.0", id, result });
2320
+ try {
2321
+ this.send({ jsonrpc: "2.0", id, result });
2322
+ } catch (error) {
2323
+ const reason = error instanceof Error ? error.message : String(error);
2324
+ console.warn(`[vault-sdk] tools: answer ${String(id)} could not be sent: ${reason}`);
2325
+ this.error(id, INTERNAL_ERROR, `the answer could not be sent: ${reason}`);
2326
+ }
2293
2327
  }
2294
2328
  error(id, code, message) {
2295
- this.options.send({ jsonrpc: "2.0", id, error: { code, message } });
2329
+ this.send({ jsonrpc: "2.0", id, error: { code, message } });
2330
+ }
2331
+ /**
2332
+ * Sends a JSON copy. The manifest of a Nuxt extension comes from its runtime config, a Vue
2333
+ * reactive proxy, and `postMessage` cannot clone a proxy: the input schemas of `tools/list`
2334
+ * would throw a `DataCloneError` and the host would never get the list. JSON-RPC is JSON, so the
2335
+ * copy loses nothing.
2336
+ */
2337
+ send(message) {
2338
+ this.options.send(JSON.parse(JSON.stringify(message)));
2296
2339
  }
2297
2340
  };
2298
2341