@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.
package/dist/index.mjs CHANGED
@@ -1264,6 +1264,10 @@ var MAIL_COMMANDS = {
1264
1264
  search: "extension_mail_search",
1265
1265
  /** CREATE a mailbox (reports whether it was already there) */
1266
1266
  createMailbox: "extension_mail_create_mailbox",
1267
+ /** DELETE a mailbox (never INBOX) */
1268
+ deleteMailbox: "extension_mail_delete_mailbox",
1269
+ /** RENAME a mailbox (never INBOX) */
1270
+ renameMailbox: "extension_mail_rename_mailbox",
1267
1271
  /** Delete messages for good: `\Deleted` plus UID EXPUNGE of exactly those UIDs */
1268
1272
  deleteMessages: "extension_mail_delete_messages",
1269
1273
  /** Set or unset IMAP flags on a UID set */
@@ -2819,6 +2823,25 @@ var MailAPI = class {
2819
2823
  );
2820
2824
  return created;
2821
2825
  }
2826
+ /**
2827
+ * Delete a mailbox. `mailbox` is the IMAP-encoded name (modified UTF-7), like in every other
2828
+ * call. `INBOX` can be neither deleted nor renamed; the host refuses it. Whether the mailbox's
2829
+ * messages and child mailboxes go with it, and whether a missing mailbox is an error, is up to
2830
+ * the server. Needs the same `fetch` permission as the other IMAP calls.
2831
+ */
2832
+ async deleteMailboxAsync(imap, mailbox) {
2833
+ return this.client.request(MAIL_COMMANDS.deleteMailbox, { imap, mailbox });
2834
+ }
2835
+ /**
2836
+ * Rename a mailbox from `from` to `to`, both IMAP-encoded names (modified UTF-7). `to` may
2837
+ * contain the server's hierarchy delimiter to move the mailbox in the tree; `*` and `%` are not
2838
+ * allowed. `INBOX` can be neither deleted nor renamed; the host refuses it. Whether child
2839
+ * mailboxes follow and whether an existing `to` is an error is up to the server. Needs the same
2840
+ * `fetch` permission as the other IMAP calls.
2841
+ */
2842
+ async renameMailboxAsync(imap, from, to) {
2843
+ return this.client.request(MAIL_COMMANDS.renameMailbox, { imap, from, to });
2844
+ }
2822
2845
  /**
2823
2846
  * Delete messages for good: flags exactly these UIDs `\Deleted` and expunges exactly them, so
2824
2847
  * other messages marked `\Deleted` stay. Refused with an error on a server without UIDPLUS,
@@ -3104,6 +3127,7 @@ function validateInput(schema, value) {
3104
3127
  var PROTOCOL_VERSION = "2025-11-25";
3105
3128
  var METHOD_NOT_FOUND = -32601;
3106
3129
  var INVALID_PARAMS = -32602;
3130
+ var INTERNAL_ERROR = -32603;
3107
3131
  function textResult(text, isError) {
3108
3132
  return { content: [{ type: "text", text }], isError };
3109
3133
  }
@@ -3189,11 +3213,30 @@ var ToolsServer = class {
3189
3213
  }
3190
3214
  if (!controller.signal.aborted) this.reply(id, result);
3191
3215
  }
3216
+ /**
3217
+ * Answers `id`. An answer that cannot be sent gets an error instead, so the host never waits for
3218
+ * an answer that will not come.
3219
+ */
3192
3220
  reply(id, result) {
3193
- this.options.send({ jsonrpc: "2.0", id, result });
3221
+ try {
3222
+ this.send({ jsonrpc: "2.0", id, result });
3223
+ } catch (error) {
3224
+ const reason = error instanceof Error ? error.message : String(error);
3225
+ console.warn(`[vault-sdk] tools: answer ${String(id)} could not be sent: ${reason}`);
3226
+ this.error(id, INTERNAL_ERROR, `the answer could not be sent: ${reason}`);
3227
+ }
3194
3228
  }
3195
3229
  error(id, code, message) {
3196
- this.options.send({ jsonrpc: "2.0", id, error: { code, message } });
3230
+ this.send({ jsonrpc: "2.0", id, error: { code, message } });
3231
+ }
3232
+ /**
3233
+ * Sends a JSON copy. The manifest of a Nuxt extension comes from its runtime config, a Vue
3234
+ * reactive proxy, and `postMessage` cannot clone a proxy: the input schemas of `tools/list`
3235
+ * would throw a `DataCloneError` and the host would never get the list. JSON-RPC is JSON, so the
3236
+ * copy loses nothing.
3237
+ */
3238
+ send(message) {
3239
+ this.options.send(JSON.parse(JSON.stringify(message)));
3197
3240
  }
3198
3241
  };
3199
3242