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