@haex-space/vault-sdk 4.1.0 → 4.3.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.
Files changed (55) hide show
  1. package/README.md +69 -0
  2. package/dist/cli/index.js +2 -1
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/cli/index.mjs +2 -1
  5. package/dist/cli/index.mjs.map +1 -1
  6. package/dist/{client-Cx4ZyQFL.d.mts → client-CDox5_KH.d.mts} +263 -27
  7. package/dist/{client-CD5QZi7F.d.ts → client-pppDo5Q3.d.ts} +263 -27
  8. package/dist/haex_bundle_bg.wasm +0 -0
  9. package/dist/index.d.mts +45 -6
  10. package/dist/index.d.ts +45 -6
  11. package/dist/index.js +363 -14
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +360 -15
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/node.d.mts +1 -1
  16. package/dist/node.d.ts +1 -1
  17. package/dist/node.js +2 -1
  18. package/dist/node.js.map +1 -1
  19. package/dist/node.mjs +2 -1
  20. package/dist/node.mjs.map +1 -1
  21. package/dist/nuxt.js +10 -2
  22. package/dist/nuxt.js.map +1 -1
  23. package/dist/nuxt.mjs +10 -2
  24. package/dist/nuxt.mjs.map +1 -1
  25. package/dist/react.d.mts +2 -2
  26. package/dist/react.d.ts +2 -2
  27. package/dist/react.js +339 -14
  28. package/dist/react.js.map +1 -1
  29. package/dist/react.mjs +339 -14
  30. package/dist/react.mjs.map +1 -1
  31. package/dist/runtime/nuxt.plugin.client.d.mts +2 -2
  32. package/dist/runtime/nuxt.plugin.client.d.ts +2 -2
  33. package/dist/runtime/nuxt.plugin.client.js +329 -14
  34. package/dist/runtime/nuxt.plugin.client.js.map +1 -1
  35. package/dist/runtime/nuxt.plugin.client.mjs +329 -14
  36. package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
  37. package/dist/svelte.d.mts +2 -2
  38. package/dist/svelte.d.ts +2 -2
  39. package/dist/svelte.js +339 -14
  40. package/dist/svelte.js.map +1 -1
  41. package/dist/svelte.mjs +339 -14
  42. package/dist/svelte.mjs.map +1 -1
  43. package/dist/{types-BwFKGH70.d.mts → types-DoNvKiW_.d.mts} +75 -1
  44. package/dist/{types-BwFKGH70.d.ts → types-DoNvKiW_.d.ts} +75 -1
  45. package/dist/vite.js +8 -1
  46. package/dist/vite.js.map +1 -1
  47. package/dist/vite.mjs +8 -1
  48. package/dist/vite.mjs.map +1 -1
  49. package/dist/vue.d.mts +2 -2
  50. package/dist/vue.d.ts +2 -2
  51. package/dist/vue.js +339 -14
  52. package/dist/vue.js.map +1 -1
  53. package/dist/vue.mjs +339 -14
  54. package/dist/vue.mjs.map +1 -1
  55. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -577,7 +577,14 @@ var HAEXSPACE_MESSAGE_TYPES = {
577
577
  *
578
578
  * Payload: `{ type: PORT_READY }` — no data.
579
579
  */
580
- PORT_READY: "haexspace:port:ready"
580
+ PORT_READY: "haexspace:port:ready",
581
+ /**
582
+ * One MCP message of the tool connection (holzi spec 018), in both directions over the
583
+ * MessagePort: the host calls the extension's tools, `sdk.tools` answers.
584
+ *
585
+ * Payload: `{ type: MCP, message }`, where `message` is a JSON-RPC 2.0 object.
586
+ */
587
+ MCP: "haexspace:mcp"
581
588
  };
582
589
 
583
590
  // src/polyfills/debug.ts
@@ -785,6 +792,25 @@ var PermissionErrorCode = /* @__PURE__ */ ((PermissionErrorCode2) => {
785
792
  PermissionErrorCode2[PermissionErrorCode2["PROMPT_REQUIRED"] = 1004] = "PROMPT_REQUIRED";
786
793
  return PermissionErrorCode2;
787
794
  })(PermissionErrorCode || {});
795
+ var HostErrorCode = /* @__PURE__ */ ((HostErrorCode2) => {
796
+ HostErrorCode2[HostErrorCode2["SECURITY_VIOLATION"] = 1e3] = "SECURITY_VIOLATION";
797
+ HostErrorCode2[HostErrorCode2["NOT_FOUND"] = 1001] = "NOT_FOUND";
798
+ HostErrorCode2[HostErrorCode2["PERMISSION_DENIED"] = 1002] = "PERMISSION_DENIED";
799
+ HostErrorCode2[HostErrorCode2["PERMISSION_PROMPT_REQUIRED"] = 1004] = "PERMISSION_PROMPT_REQUIRED";
800
+ HostErrorCode2[HostErrorCode2["DATABASE"] = 2e3] = "DATABASE";
801
+ HostErrorCode2[HostErrorCode2["FILESYSTEM"] = 2001] = "FILESYSTEM";
802
+ HostErrorCode2[HostErrorCode2["HTTP"] = 2002] = "HTTP";
803
+ HostErrorCode2[HostErrorCode2["SHELL"] = 2003] = "SHELL";
804
+ HostErrorCode2[HostErrorCode2["WEB"] = 2005] = "WEB";
805
+ HostErrorCode2[HostErrorCode2["MANIFEST"] = 3e3] = "MANIFEST";
806
+ HostErrorCode2[HostErrorCode2["VALIDATION"] = 3001] = "VALIDATION";
807
+ HostErrorCode2[HostErrorCode2["ENCRYPTED_DATA_DAMAGED"] = 3010] = "ENCRYPTED_DATA_DAMAGED";
808
+ HostErrorCode2[HostErrorCode2["LIMIT_EXCEEDED"] = 7e3] = "LIMIT_EXCEEDED";
809
+ HostErrorCode2[HostErrorCode2["NOT_SUPPORTED"] = 8e3] = "NOT_SUPPORTED";
810
+ HostErrorCode2[HostErrorCode2["NOT_AVAILABLE"] = 8001] = "NOT_AVAILABLE";
811
+ HostErrorCode2[HostErrorCode2["DISABLED"] = 8002] = "DISABLED";
812
+ return HostErrorCode2;
813
+ })(HostErrorCode || {});
788
814
  function isPermissionDeniedError(error) {
789
815
  return typeof error === "object" && error !== null && "code" in error && error.code === 1002 /* DENIED */;
790
816
  }
@@ -1034,6 +1060,21 @@ var REMOTE_STORAGE_COMMANDS = {
1034
1060
  list: "extension_remote_storage_list"
1035
1061
  };
1036
1062
 
1063
+ // src/commands/encryptedFolders.ts
1064
+ init_esm_shims();
1065
+ var ENCRYPTED_FOLDER_COMMANDS = {
1066
+ /** Let the user pick an encrypted folder of a storage and grant access to it */
1067
+ choose: "extension_encrypted_folder_choose",
1068
+ /** List the entries of a folder inside an encrypted folder */
1069
+ list: "extension_encrypted_folder_list",
1070
+ /** Download and decrypt a file */
1071
+ download: "extension_encrypted_folder_download",
1072
+ /** Encrypt and upload a file */
1073
+ upload: "extension_encrypted_folder_upload",
1074
+ /** Delete a file or folder */
1075
+ delete: "extension_encrypted_folder_delete"
1076
+ };
1077
+
1037
1078
  // src/commands/localsend.ts
1038
1079
  init_esm_shims();
1039
1080
  var LOCALSEND_COMMANDS = {
@@ -1178,6 +1219,7 @@ var TAURI_COMMANDS = {
1178
1219
  externalBridge: EXTERNAL_BRIDGE_COMMANDS,
1179
1220
  extension: EXTENSION_COMMANDS,
1180
1221
  remoteStorage: REMOTE_STORAGE_COMMANDS,
1222
+ encryptedFolders: ENCRYPTED_FOLDER_COMMANDS,
1181
1223
  localsend: LOCALSEND_COMMANDS,
1182
1224
  spaces: SPACE_COMMANDS,
1183
1225
  shell: SHELL_COMMANDS,
@@ -1791,26 +1833,32 @@ var BackendManagement = class {
1791
1833
  );
1792
1834
  }
1793
1835
  /**
1794
- * Add a new storage backend
1795
- * @param request - Backend configuration
1836
+ * Propose a new storage. The host asks the user; credentials are entered
1837
+ * only there. Resolves with the new storage, which the extension may then
1838
+ * read and write.
1839
+ * @param request - The proposal, without credentials
1796
1840
  * @returns Created backend info
1797
1841
  */
1798
1842
  async add(request) {
1799
1843
  return this.client.request(
1800
1844
  REMOTE_STORAGE_COMMANDS.addBackend,
1801
- { request }
1845
+ { request },
1846
+ // No deadline: the host waits for the user's answer in its dialog.
1847
+ { timeout: null }
1802
1848
  );
1803
1849
  }
1804
1850
  /**
1805
- * Update a storage backend
1806
- * Only provided fields are updated. Credentials are preserved if not provided.
1851
+ * Change a storage after the user confirms it in the host.
1852
+ * Only provided fields are updated; new credentials are entered in the host.
1807
1853
  * @param request - Update request with backendId and fields to update
1808
1854
  * @returns Updated backend info
1809
1855
  */
1810
1856
  async update(request) {
1811
1857
  return this.client.request(
1812
1858
  REMOTE_STORAGE_COMMANDS.updateBackend,
1813
- { request }
1859
+ { request },
1860
+ // No deadline: the host waits for the user's answer in its dialog.
1861
+ { timeout: null }
1814
1862
  );
1815
1863
  }
1816
1864
  /**
@@ -1818,17 +1866,100 @@ var BackendManagement = class {
1818
1866
  * @param backendId - Backend ID to remove
1819
1867
  */
1820
1868
  async remove(backendId) {
1821
- await this.client.request(REMOTE_STORAGE_COMMANDS.removeBackend, {
1822
- backendId
1823
- });
1869
+ await this.client.request(
1870
+ REMOTE_STORAGE_COMMANDS.removeBackend,
1871
+ { backendId },
1872
+ { timeout: null }
1873
+ );
1824
1874
  }
1825
1875
  /**
1826
1876
  * Test connection to a storage backend
1827
1877
  * @param backendId - Backend ID to test
1828
1878
  */
1829
1879
  async test(backendId) {
1830
- await this.client.request(REMOTE_STORAGE_COMMANDS.testBackend, {
1831
- backendId
1880
+ await this.client.request(
1881
+ REMOTE_STORAGE_COMMANDS.testBackend,
1882
+ { backendId },
1883
+ { timeout: null }
1884
+ );
1885
+ }
1886
+ };
1887
+
1888
+ // src/api/encryptedFolders.ts
1889
+ init_esm_shims();
1890
+ init_vaultKey();
1891
+ var EncryptedFoldersAPI = class {
1892
+ constructor(client) {
1893
+ this.client = client;
1894
+ }
1895
+ /**
1896
+ * Let the user choose one of the storage's encrypted folders and grant
1897
+ * access to it. The host shows its own window and waits for the answer.
1898
+ * Needs the `remoteStorage` permission for the storage (else 1002 without
1899
+ * asking); 1002 as well when the user refuses.
1900
+ * @param storageId - Storage the folder lies in
1901
+ * @param access - Access the extension asks for
1902
+ * @returns The chosen folder, or `null` when the user closed the chooser without choosing
1903
+ */
1904
+ async choose(storageId, access) {
1905
+ const choice = await this.client.request(
1906
+ ENCRYPTED_FOLDER_COMMANDS.choose,
1907
+ { request: { storageId, access } },
1908
+ // No deadline: the host waits for the user's answer in its window.
1909
+ { timeout: null }
1910
+ );
1911
+ return choice ?? null;
1912
+ }
1913
+ /**
1914
+ * List a folder inside an encrypted folder (permission `read`).
1915
+ * @param storageId - Storage the folder lies in
1916
+ * @param folderId - Folder from {@link EncryptedFoldersAPI.choose}
1917
+ * @param path - Path relative to the encrypted folder; `''` (default) for its root
1918
+ * @returns The entries with their decrypted names
1919
+ */
1920
+ async list(storageId, folderId, path2 = "") {
1921
+ const result = await this.client.request(
1922
+ ENCRYPTED_FOLDER_COMMANDS.list,
1923
+ { request: { storageId, folderId, path: path2 } }
1924
+ );
1925
+ return result.entries;
1926
+ }
1927
+ /**
1928
+ * Download and decrypt a file (permission `read`).
1929
+ * @param storageId - Storage the folder lies in
1930
+ * @param folderId - Folder from {@link EncryptedFoldersAPI.choose}
1931
+ * @param path - Path of the file, relative to the encrypted folder
1932
+ * @returns The decrypted content
1933
+ */
1934
+ async download(storageId, folderId, path2) {
1935
+ const base64 = await this.client.request(
1936
+ ENCRYPTED_FOLDER_COMMANDS.download,
1937
+ { request: { storageId, folderId, path: path2 } }
1938
+ );
1939
+ return base64ToArrayBuffer(base64);
1940
+ }
1941
+ /**
1942
+ * Encrypt and upload a file (permission `readWrite`). Missing parent
1943
+ * folders are created.
1944
+ * @param storageId - Storage the folder lies in
1945
+ * @param folderId - Folder from {@link EncryptedFoldersAPI.choose}
1946
+ * @param path - Path of the file, relative to the encrypted folder
1947
+ * @param data - Content of the file
1948
+ */
1949
+ async upload(storageId, folderId, path2, data) {
1950
+ await this.client.request(ENCRYPTED_FOLDER_COMMANDS.upload, {
1951
+ request: { storageId, folderId, path: path2, data: arrayBufferToBase64(data) }
1952
+ });
1953
+ }
1954
+ /**
1955
+ * Delete a file or folder (permission `readWrite`).
1956
+ * @param storageId - Storage the folder lies in
1957
+ * @param folderId - Folder from {@link EncryptedFoldersAPI.choose}
1958
+ * @param path - Path relative to the encrypted folder
1959
+ */
1960
+ async delete(storageId, folderId, path2) {
1961
+ await this.client.request(ENCRYPTED_FOLDER_COMMANDS.delete, {
1962
+ request: { storageId, folderId, path: path2 }
1832
1963
  });
1833
1964
  }
1834
1965
  };
@@ -2439,6 +2570,202 @@ var DialogAPI = class {
2439
2570
  }
2440
2571
  };
2441
2572
 
2573
+ // src/api/tools/index.ts
2574
+ init_esm_shims();
2575
+
2576
+ // src/api/tools/server.ts
2577
+ init_esm_shims();
2578
+
2579
+ // src/api/tools/schema.ts
2580
+ init_esm_shims();
2581
+ function fail(field, message) {
2582
+ return { ok: false, field, message };
2583
+ }
2584
+ function typeMatches(type, value) {
2585
+ switch (type) {
2586
+ case "object":
2587
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2588
+ case "array":
2589
+ return Array.isArray(value);
2590
+ case "integer":
2591
+ return Number.isInteger(value);
2592
+ case "number":
2593
+ return typeof value === "number" && Number.isFinite(value);
2594
+ case "string":
2595
+ return typeof value === "string";
2596
+ case "boolean":
2597
+ return typeof value === "boolean";
2598
+ default:
2599
+ return false;
2600
+ }
2601
+ }
2602
+ function validateAt(schema, value, field) {
2603
+ if (!typeMatches(schema.type, value)) return fail(field, `expected ${String(schema.type)}`);
2604
+ if (schema.enum && !schema.enum.includes(value)) {
2605
+ return fail(field, `expected one of ${schema.enum.join(", ")}`);
2606
+ }
2607
+ if (schema.type === "array" && schema.items) {
2608
+ const items = value;
2609
+ for (let i = 0; i < items.length; i++) {
2610
+ const result = validateAt(schema.items, items[i], `${field}[${i}]`);
2611
+ if (!result.ok) return result;
2612
+ }
2613
+ }
2614
+ if (schema.type === "object") {
2615
+ const record = value;
2616
+ const properties = schema.properties ?? {};
2617
+ const prefix = field === "" ? "" : `${field}.`;
2618
+ if (schema.properties) {
2619
+ for (const key of Object.keys(record)) {
2620
+ if (!Object.hasOwn(properties, key)) return fail(`${prefix}${key}`, "unknown property");
2621
+ }
2622
+ }
2623
+ for (const key of schema.required ?? []) {
2624
+ if (record[key] === void 0) return fail(`${prefix}${key}`, "required");
2625
+ }
2626
+ for (const [key, child] of Object.entries(properties)) {
2627
+ if (record[key] === void 0) continue;
2628
+ const result = validateAt(child, record[key], `${prefix}${key}`);
2629
+ if (!result.ok) return result;
2630
+ }
2631
+ }
2632
+ return { ok: true };
2633
+ }
2634
+ function validateInput(schema, value) {
2635
+ return validateAt(schema, value, "");
2636
+ }
2637
+
2638
+ // src/api/tools/server.ts
2639
+ var PROTOCOL_VERSION = "2025-11-25";
2640
+ var METHOD_NOT_FOUND = -32601;
2641
+ var INVALID_PARAMS = -32602;
2642
+ function textResult(text, isError) {
2643
+ return { content: [{ type: "text", text }], isError };
2644
+ }
2645
+ function asText(value) {
2646
+ if (typeof value === "string") return value;
2647
+ if (value === void 0) return "";
2648
+ return JSON.stringify(value);
2649
+ }
2650
+ function isId(value) {
2651
+ return typeof value === "string" || typeof value === "number";
2652
+ }
2653
+ var ToolsServer = class {
2654
+ constructor(options) {
2655
+ this.options = options;
2656
+ this.running = /* @__PURE__ */ new Map();
2657
+ }
2658
+ /**
2659
+ * Handles one JSON-RPC message from the host. A tool call runs on its own and answers when it is
2660
+ * done, so a long call never holds up `ping` or the cancellation of that very call.
2661
+ */
2662
+ async receive(message) {
2663
+ if (typeof message !== "object" || message === null) return;
2664
+ const { id, method, params } = message;
2665
+ if (typeof method !== "string") return;
2666
+ const args = typeof params === "object" && params !== null ? params : {};
2667
+ if (!isId(id)) {
2668
+ if (method === "notifications/cancelled" && isId(args.requestId)) {
2669
+ this.running.get(args.requestId)?.abort();
2670
+ }
2671
+ return;
2672
+ }
2673
+ switch (method) {
2674
+ case "initialize":
2675
+ return this.reply(id, {
2676
+ protocolVersion: PROTOCOL_VERSION,
2677
+ capabilities: { tools: {} },
2678
+ serverInfo: {
2679
+ name: this.options.manifest?.name ?? "",
2680
+ version: this.options.manifest?.version ?? ""
2681
+ }
2682
+ });
2683
+ case "ping":
2684
+ return this.reply(id, {});
2685
+ case "tools/list": {
2686
+ const tools = this.tools().map(({ name, title, description, inputSchema }) => ({
2687
+ name,
2688
+ title: title.en,
2689
+ description,
2690
+ inputSchema
2691
+ }));
2692
+ return this.reply(id, { tools });
2693
+ }
2694
+ case "tools/call":
2695
+ void this.call(id, args);
2696
+ return;
2697
+ default:
2698
+ return this.error(id, METHOD_NOT_FOUND, method);
2699
+ }
2700
+ }
2701
+ /** The declared tools that have a handler. */
2702
+ tools() {
2703
+ return (this.options.manifest?.tools ?? []).filter((tool) => this.options.handlers.has(tool.name));
2704
+ }
2705
+ async call(id, params) {
2706
+ const tool = this.tools().find((candidate) => candidate.name === params.name);
2707
+ const handler = tool && this.options.handlers.get(tool.name);
2708
+ if (!tool || !handler) return this.error(id, INVALID_PARAMS, `unknown tool ${String(params.name)}`);
2709
+ const input = params.arguments ?? {};
2710
+ const checked = validateInput(tool.inputSchema, input);
2711
+ if (!checked.ok) {
2712
+ return this.reply(id, textResult(`invalid input: ${checked.field}: ${checked.message}`, true));
2713
+ }
2714
+ const controller = new AbortController();
2715
+ this.running.set(id, controller);
2716
+ let result;
2717
+ try {
2718
+ const output = await handler(input, { signal: controller.signal });
2719
+ result = textResult(asText(output), false);
2720
+ } catch (error) {
2721
+ result = textResult(error instanceof Error ? error.message : String(error), true);
2722
+ } finally {
2723
+ this.running.delete(id);
2724
+ }
2725
+ if (!controller.signal.aborted) this.reply(id, result);
2726
+ }
2727
+ reply(id, result) {
2728
+ this.options.send({ jsonrpc: "2.0", id, result });
2729
+ }
2730
+ error(id, code, message) {
2731
+ this.options.send({ jsonrpc: "2.0", id, error: { code, message } });
2732
+ }
2733
+ };
2734
+
2735
+ // src/api/tools/index.ts
2736
+ var ToolsAPI = class {
2737
+ constructor(options) {
2738
+ this.options = options;
2739
+ this.handlers = /* @__PURE__ */ new Map();
2740
+ const manifest = options.manifest;
2741
+ this.server = new ToolsServer({
2742
+ get manifest() {
2743
+ return manifest();
2744
+ },
2745
+ handlers: this.handlers,
2746
+ send: options.send
2747
+ });
2748
+ }
2749
+ /**
2750
+ * Runs `handler` when the host calls the tool `name`. The tool must be declared in the manifest.
2751
+ * Returns a function that unregisters the handler; the host then no longer sees the tool.
2752
+ */
2753
+ register(name, handler) {
2754
+ const declared = this.options.manifest()?.tools?.some((tool) => tool.name === name) ?? false;
2755
+ if (!declared) {
2756
+ throw new Error(`The tool ${name} is not declared in the manifest's tools`);
2757
+ }
2758
+ this.handlers.set(name, handler);
2759
+ return () => {
2760
+ if (this.handlers.get(name) === handler) this.handlers.delete(name);
2761
+ };
2762
+ }
2763
+ /** Handles one MCP message from the host. Called by the SDK for `haexspace:mcp` port messages. */
2764
+ receive(message) {
2765
+ return this.server.receive(message);
2766
+ }
2767
+ };
2768
+
2442
2769
  // src/client/tableName.ts
2443
2770
  init_esm_shims();
2444
2771
  function validatePublicKey(publicKey) {
@@ -2820,7 +3147,11 @@ function createMessageHandler(config, pendingRequests, extensionInfo, onEvent) {
2820
3147
  }
2821
3148
  };
2822
3149
  }
2823
- function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest, onActionRequest) {
3150
+ function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest, onActionRequest, onMcpMessage) {
3151
+ if (event.type === HAEXSPACE_MESSAGE_TYPES.MCP) {
3152
+ onMcpMessage?.(event.message);
3153
+ return;
3154
+ }
2824
3155
  if (event.type === HAEXTENSION_EVENTS.CONTEXT_CHANGED) {
2825
3156
  const contextEvent = event;
2826
3157
  onContextChanged(contextEvent.data.context);
@@ -3092,6 +3423,7 @@ var HaexVaultSdk = class {
3092
3423
  this.web = new WebAPI(this);
3093
3424
  this.permissions = new PermissionsAPI(this);
3094
3425
  this.remoteStorage = new RemoteStorageAPI(this);
3426
+ this.encryptedFolders = new EncryptedFoldersAPI(this);
3095
3427
  this.localsend = new LocalSendAPI(this);
3096
3428
  this.spaces = new SpacesAPI(this);
3097
3429
  this.shell = new ShellAPI(this);
@@ -3100,6 +3432,10 @@ var HaexVaultSdk = class {
3100
3432
  this.notifications = new NotificationsAPI(this);
3101
3433
  this.tab = new TabAPI(this);
3102
3434
  this.dialog = new DialogAPI(this);
3435
+ this.tools = new ToolsAPI({
3436
+ manifest: () => this.config.manifest,
3437
+ send: (message) => this.sendMcpMessage(message)
3438
+ });
3103
3439
  installConsoleForwarding(this.config.debug);
3104
3440
  this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
3105
3441
  const data = event.data;
@@ -3407,9 +3743,18 @@ var HaexVaultSdk = class {
3407
3743
  this.notifySubscribersInternal();
3408
3744
  },
3409
3745
  (extEvent) => this.handleExternalRequestInternal(extEvent.data),
3410
- (actionEvent) => this.handleActionRequestInternal(actionEvent.data)
3746
+ (actionEvent) => this.handleActionRequestInternal(actionEvent.data),
3747
+ (message) => void this.tools.receive(message)
3411
3748
  );
3412
3749
  }
3750
+ /** Sends one MCP message of the tool connection to the host on the port. */
3751
+ sendMcpMessage(message) {
3752
+ if (!this.hostPort) {
3753
+ this.log("Dropped an MCP message: no host port yet");
3754
+ return;
3755
+ }
3756
+ this.hostPort.postMessage({ type: HAEXSPACE_MESSAGE_TYPES.MCP, message });
3757
+ }
3413
3758
  async handleExternalRequestInternal(request) {
3414
3759
  await handleExternalRequest(request, this.externalRequestHandlers, this.respondToExternalRequest.bind(this), this.log.bind(this));
3415
3760
  }
@@ -3952,6 +4297,6 @@ function createHaexVaultSdk(config = {}) {
3952
4297
  return new HaexVaultSdk(config);
3953
4298
  }
3954
4299
 
3955
- export { COSE_ALGORITHM, DEFAULT_TIMEOUT, DatabaseAPI, DialogAPI, EXTERNAL_EVENTS, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, KEY_AGREEMENT_ALGO, KnownPath, LOCALSEND_EVENTS, LocalSendAPI, MAIL_COMMANDS, MAIL_EVENTS, MailAPI, NOTIFICATION_COMMANDS, NOTIFICATION_EVENTS, NotificationsAPI, PASSWORD_COMMANDS, PasswordsAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SHELL_EVENTS, SIGNING_ALGO, SPACE_COMMANDS, ShellAPI, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, TabAPI, WebAPI, arrayBufferToBase64, base58btcDecode, base58btcEncode, base64ToArrayBuffer, canExternalClientSendRequests, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceNameAsync, decryptString, decryptVaultKey, decryptVaultName, decryptWithPrivateKeyAsync, deriveKeyFromPassword, didKeyToPublicKeyAsync, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceNameAsync, encryptString, encryptVaultKey, encryptWithPublicKeyAsync, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generateIdentityAsync, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, getTableName, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, publicKeyToDidKeyAsync, signClaimPresentationAsync, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, unwrapKey, verifyClaimPresentationAsync, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
4300
+ export { COSE_ALGORITHM, DEFAULT_TIMEOUT, DatabaseAPI, DialogAPI, ENCRYPTED_FOLDER_COMMANDS, EXTERNAL_EVENTS, EncryptedFoldersAPI, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, HostErrorCode, KEY_AGREEMENT_ALGO, KnownPath, LOCALSEND_EVENTS, LocalSendAPI, MAIL_COMMANDS, MAIL_EVENTS, MailAPI, NOTIFICATION_COMMANDS, NOTIFICATION_EVENTS, NotificationsAPI, PASSWORD_COMMANDS, PasswordsAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SHELL_EVENTS, SIGNING_ALGO, SPACE_COMMANDS, ShellAPI, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, TabAPI, ToolsAPI, WebAPI, arrayBufferToBase64, base58btcDecode, base58btcEncode, base64ToArrayBuffer, canExternalClientSendRequests, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceNameAsync, decryptString, decryptVaultKey, decryptVaultName, decryptWithPrivateKeyAsync, deriveKeyFromPassword, didKeyToPublicKeyAsync, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceNameAsync, encryptString, encryptVaultKey, encryptWithPublicKeyAsync, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generateIdentityAsync, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, getTableName, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, publicKeyToDidKeyAsync, signClaimPresentationAsync, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, unwrapKey, verifyClaimPresentationAsync, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
3956
4301
  //# sourceMappingURL=index.mjs.map
3957
4302
  //# sourceMappingURL=index.mjs.map