@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.js CHANGED
@@ -579,7 +579,14 @@ var HAEXSPACE_MESSAGE_TYPES = {
579
579
  *
580
580
  * Payload: `{ type: PORT_READY }` — no data.
581
581
  */
582
- PORT_READY: "haexspace:port:ready"
582
+ PORT_READY: "haexspace:port:ready",
583
+ /**
584
+ * One MCP message of the tool connection (holzi spec 018), in both directions over the
585
+ * MessagePort: the host calls the extension's tools, `sdk.tools` answers.
586
+ *
587
+ * Payload: `{ type: MCP, message }`, where `message` is a JSON-RPC 2.0 object.
588
+ */
589
+ MCP: "haexspace:mcp"
583
590
  };
584
591
 
585
592
  // src/polyfills/debug.ts
@@ -787,6 +794,25 @@ var PermissionErrorCode = /* @__PURE__ */ ((PermissionErrorCode2) => {
787
794
  PermissionErrorCode2[PermissionErrorCode2["PROMPT_REQUIRED"] = 1004] = "PROMPT_REQUIRED";
788
795
  return PermissionErrorCode2;
789
796
  })(PermissionErrorCode || {});
797
+ var HostErrorCode = /* @__PURE__ */ ((HostErrorCode2) => {
798
+ HostErrorCode2[HostErrorCode2["SECURITY_VIOLATION"] = 1e3] = "SECURITY_VIOLATION";
799
+ HostErrorCode2[HostErrorCode2["NOT_FOUND"] = 1001] = "NOT_FOUND";
800
+ HostErrorCode2[HostErrorCode2["PERMISSION_DENIED"] = 1002] = "PERMISSION_DENIED";
801
+ HostErrorCode2[HostErrorCode2["PERMISSION_PROMPT_REQUIRED"] = 1004] = "PERMISSION_PROMPT_REQUIRED";
802
+ HostErrorCode2[HostErrorCode2["DATABASE"] = 2e3] = "DATABASE";
803
+ HostErrorCode2[HostErrorCode2["FILESYSTEM"] = 2001] = "FILESYSTEM";
804
+ HostErrorCode2[HostErrorCode2["HTTP"] = 2002] = "HTTP";
805
+ HostErrorCode2[HostErrorCode2["SHELL"] = 2003] = "SHELL";
806
+ HostErrorCode2[HostErrorCode2["WEB"] = 2005] = "WEB";
807
+ HostErrorCode2[HostErrorCode2["MANIFEST"] = 3e3] = "MANIFEST";
808
+ HostErrorCode2[HostErrorCode2["VALIDATION"] = 3001] = "VALIDATION";
809
+ HostErrorCode2[HostErrorCode2["ENCRYPTED_DATA_DAMAGED"] = 3010] = "ENCRYPTED_DATA_DAMAGED";
810
+ HostErrorCode2[HostErrorCode2["LIMIT_EXCEEDED"] = 7e3] = "LIMIT_EXCEEDED";
811
+ HostErrorCode2[HostErrorCode2["NOT_SUPPORTED"] = 8e3] = "NOT_SUPPORTED";
812
+ HostErrorCode2[HostErrorCode2["NOT_AVAILABLE"] = 8001] = "NOT_AVAILABLE";
813
+ HostErrorCode2[HostErrorCode2["DISABLED"] = 8002] = "DISABLED";
814
+ return HostErrorCode2;
815
+ })(HostErrorCode || {});
790
816
  function isPermissionDeniedError(error) {
791
817
  return typeof error === "object" && error !== null && "code" in error && error.code === 1002 /* DENIED */;
792
818
  }
@@ -1036,6 +1062,21 @@ var REMOTE_STORAGE_COMMANDS = {
1036
1062
  list: "extension_remote_storage_list"
1037
1063
  };
1038
1064
 
1065
+ // src/commands/encryptedFolders.ts
1066
+ init_cjs_shims();
1067
+ var ENCRYPTED_FOLDER_COMMANDS = {
1068
+ /** Let the user pick an encrypted folder of a storage and grant access to it */
1069
+ choose: "extension_encrypted_folder_choose",
1070
+ /** List the entries of a folder inside an encrypted folder */
1071
+ list: "extension_encrypted_folder_list",
1072
+ /** Download and decrypt a file */
1073
+ download: "extension_encrypted_folder_download",
1074
+ /** Encrypt and upload a file */
1075
+ upload: "extension_encrypted_folder_upload",
1076
+ /** Delete a file or folder */
1077
+ delete: "extension_encrypted_folder_delete"
1078
+ };
1079
+
1039
1080
  // src/commands/localsend.ts
1040
1081
  init_cjs_shims();
1041
1082
  var LOCALSEND_COMMANDS = {
@@ -1180,6 +1221,7 @@ var TAURI_COMMANDS = {
1180
1221
  externalBridge: EXTERNAL_BRIDGE_COMMANDS,
1181
1222
  extension: EXTENSION_COMMANDS,
1182
1223
  remoteStorage: REMOTE_STORAGE_COMMANDS,
1224
+ encryptedFolders: ENCRYPTED_FOLDER_COMMANDS,
1183
1225
  localsend: LOCALSEND_COMMANDS,
1184
1226
  spaces: SPACE_COMMANDS,
1185
1227
  shell: SHELL_COMMANDS,
@@ -1793,26 +1835,32 @@ var BackendManagement = class {
1793
1835
  );
1794
1836
  }
1795
1837
  /**
1796
- * Add a new storage backend
1797
- * @param request - Backend configuration
1838
+ * Propose a new storage. The host asks the user; credentials are entered
1839
+ * only there. Resolves with the new storage, which the extension may then
1840
+ * read and write.
1841
+ * @param request - The proposal, without credentials
1798
1842
  * @returns Created backend info
1799
1843
  */
1800
1844
  async add(request) {
1801
1845
  return this.client.request(
1802
1846
  REMOTE_STORAGE_COMMANDS.addBackend,
1803
- { request }
1847
+ { request },
1848
+ // No deadline: the host waits for the user's answer in its dialog.
1849
+ { timeout: null }
1804
1850
  );
1805
1851
  }
1806
1852
  /**
1807
- * Update a storage backend
1808
- * Only provided fields are updated. Credentials are preserved if not provided.
1853
+ * Change a storage after the user confirms it in the host.
1854
+ * Only provided fields are updated; new credentials are entered in the host.
1809
1855
  * @param request - Update request with backendId and fields to update
1810
1856
  * @returns Updated backend info
1811
1857
  */
1812
1858
  async update(request) {
1813
1859
  return this.client.request(
1814
1860
  REMOTE_STORAGE_COMMANDS.updateBackend,
1815
- { request }
1861
+ { request },
1862
+ // No deadline: the host waits for the user's answer in its dialog.
1863
+ { timeout: null }
1816
1864
  );
1817
1865
  }
1818
1866
  /**
@@ -1820,17 +1868,100 @@ var BackendManagement = class {
1820
1868
  * @param backendId - Backend ID to remove
1821
1869
  */
1822
1870
  async remove(backendId) {
1823
- await this.client.request(REMOTE_STORAGE_COMMANDS.removeBackend, {
1824
- backendId
1825
- });
1871
+ await this.client.request(
1872
+ REMOTE_STORAGE_COMMANDS.removeBackend,
1873
+ { backendId },
1874
+ { timeout: null }
1875
+ );
1826
1876
  }
1827
1877
  /**
1828
1878
  * Test connection to a storage backend
1829
1879
  * @param backendId - Backend ID to test
1830
1880
  */
1831
1881
  async test(backendId) {
1832
- await this.client.request(REMOTE_STORAGE_COMMANDS.testBackend, {
1833
- backendId
1882
+ await this.client.request(
1883
+ REMOTE_STORAGE_COMMANDS.testBackend,
1884
+ { backendId },
1885
+ { timeout: null }
1886
+ );
1887
+ }
1888
+ };
1889
+
1890
+ // src/api/encryptedFolders.ts
1891
+ init_cjs_shims();
1892
+ init_vaultKey();
1893
+ var EncryptedFoldersAPI = class {
1894
+ constructor(client) {
1895
+ this.client = client;
1896
+ }
1897
+ /**
1898
+ * Let the user choose one of the storage's encrypted folders and grant
1899
+ * access to it. The host shows its own window and waits for the answer.
1900
+ * Needs the `remoteStorage` permission for the storage (else 1002 without
1901
+ * asking); 1002 as well when the user refuses.
1902
+ * @param storageId - Storage the folder lies in
1903
+ * @param access - Access the extension asks for
1904
+ * @returns The chosen folder, or `null` when the user closed the chooser without choosing
1905
+ */
1906
+ async choose(storageId, access) {
1907
+ const choice = await this.client.request(
1908
+ ENCRYPTED_FOLDER_COMMANDS.choose,
1909
+ { request: { storageId, access } },
1910
+ // No deadline: the host waits for the user's answer in its window.
1911
+ { timeout: null }
1912
+ );
1913
+ return choice ?? null;
1914
+ }
1915
+ /**
1916
+ * List a folder inside an encrypted folder (permission `read`).
1917
+ * @param storageId - Storage the folder lies in
1918
+ * @param folderId - Folder from {@link EncryptedFoldersAPI.choose}
1919
+ * @param path - Path relative to the encrypted folder; `''` (default) for its root
1920
+ * @returns The entries with their decrypted names
1921
+ */
1922
+ async list(storageId, folderId, path = "") {
1923
+ const result = await this.client.request(
1924
+ ENCRYPTED_FOLDER_COMMANDS.list,
1925
+ { request: { storageId, folderId, path } }
1926
+ );
1927
+ return result.entries;
1928
+ }
1929
+ /**
1930
+ * Download and decrypt a file (permission `read`).
1931
+ * @param storageId - Storage the folder lies in
1932
+ * @param folderId - Folder from {@link EncryptedFoldersAPI.choose}
1933
+ * @param path - Path of the file, relative to the encrypted folder
1934
+ * @returns The decrypted content
1935
+ */
1936
+ async download(storageId, folderId, path) {
1937
+ const base64 = await this.client.request(
1938
+ ENCRYPTED_FOLDER_COMMANDS.download,
1939
+ { request: { storageId, folderId, path } }
1940
+ );
1941
+ return base64ToArrayBuffer(base64);
1942
+ }
1943
+ /**
1944
+ * Encrypt and upload a file (permission `readWrite`). Missing parent
1945
+ * folders are created.
1946
+ * @param storageId - Storage the folder lies in
1947
+ * @param folderId - Folder from {@link EncryptedFoldersAPI.choose}
1948
+ * @param path - Path of the file, relative to the encrypted folder
1949
+ * @param data - Content of the file
1950
+ */
1951
+ async upload(storageId, folderId, path, data) {
1952
+ await this.client.request(ENCRYPTED_FOLDER_COMMANDS.upload, {
1953
+ request: { storageId, folderId, path, data: arrayBufferToBase64(data) }
1954
+ });
1955
+ }
1956
+ /**
1957
+ * Delete a file or folder (permission `readWrite`).
1958
+ * @param storageId - Storage the folder lies in
1959
+ * @param folderId - Folder from {@link EncryptedFoldersAPI.choose}
1960
+ * @param path - Path relative to the encrypted folder
1961
+ */
1962
+ async delete(storageId, folderId, path) {
1963
+ await this.client.request(ENCRYPTED_FOLDER_COMMANDS.delete, {
1964
+ request: { storageId, folderId, path }
1834
1965
  });
1835
1966
  }
1836
1967
  };
@@ -2441,6 +2572,202 @@ var DialogAPI = class {
2441
2572
  }
2442
2573
  };
2443
2574
 
2575
+ // src/api/tools/index.ts
2576
+ init_cjs_shims();
2577
+
2578
+ // src/api/tools/server.ts
2579
+ init_cjs_shims();
2580
+
2581
+ // src/api/tools/schema.ts
2582
+ init_cjs_shims();
2583
+ function fail(field, message) {
2584
+ return { ok: false, field, message };
2585
+ }
2586
+ function typeMatches(type, value) {
2587
+ switch (type) {
2588
+ case "object":
2589
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2590
+ case "array":
2591
+ return Array.isArray(value);
2592
+ case "integer":
2593
+ return Number.isInteger(value);
2594
+ case "number":
2595
+ return typeof value === "number" && Number.isFinite(value);
2596
+ case "string":
2597
+ return typeof value === "string";
2598
+ case "boolean":
2599
+ return typeof value === "boolean";
2600
+ default:
2601
+ return false;
2602
+ }
2603
+ }
2604
+ function validateAt(schema, value, field) {
2605
+ if (!typeMatches(schema.type, value)) return fail(field, `expected ${String(schema.type)}`);
2606
+ if (schema.enum && !schema.enum.includes(value)) {
2607
+ return fail(field, `expected one of ${schema.enum.join(", ")}`);
2608
+ }
2609
+ if (schema.type === "array" && schema.items) {
2610
+ const items = value;
2611
+ for (let i = 0; i < items.length; i++) {
2612
+ const result = validateAt(schema.items, items[i], `${field}[${i}]`);
2613
+ if (!result.ok) return result;
2614
+ }
2615
+ }
2616
+ if (schema.type === "object") {
2617
+ const record = value;
2618
+ const properties = schema.properties ?? {};
2619
+ const prefix = field === "" ? "" : `${field}.`;
2620
+ if (schema.properties) {
2621
+ for (const key of Object.keys(record)) {
2622
+ if (!Object.hasOwn(properties, key)) return fail(`${prefix}${key}`, "unknown property");
2623
+ }
2624
+ }
2625
+ for (const key of schema.required ?? []) {
2626
+ if (record[key] === void 0) return fail(`${prefix}${key}`, "required");
2627
+ }
2628
+ for (const [key, child] of Object.entries(properties)) {
2629
+ if (record[key] === void 0) continue;
2630
+ const result = validateAt(child, record[key], `${prefix}${key}`);
2631
+ if (!result.ok) return result;
2632
+ }
2633
+ }
2634
+ return { ok: true };
2635
+ }
2636
+ function validateInput(schema, value) {
2637
+ return validateAt(schema, value, "");
2638
+ }
2639
+
2640
+ // src/api/tools/server.ts
2641
+ var PROTOCOL_VERSION = "2025-11-25";
2642
+ var METHOD_NOT_FOUND = -32601;
2643
+ var INVALID_PARAMS = -32602;
2644
+ function textResult(text, isError) {
2645
+ return { content: [{ type: "text", text }], isError };
2646
+ }
2647
+ function asText(value) {
2648
+ if (typeof value === "string") return value;
2649
+ if (value === void 0) return "";
2650
+ return JSON.stringify(value);
2651
+ }
2652
+ function isId(value) {
2653
+ return typeof value === "string" || typeof value === "number";
2654
+ }
2655
+ var ToolsServer = class {
2656
+ constructor(options) {
2657
+ this.options = options;
2658
+ this.running = /* @__PURE__ */ new Map();
2659
+ }
2660
+ /**
2661
+ * Handles one JSON-RPC message from the host. A tool call runs on its own and answers when it is
2662
+ * done, so a long call never holds up `ping` or the cancellation of that very call.
2663
+ */
2664
+ async receive(message) {
2665
+ if (typeof message !== "object" || message === null) return;
2666
+ const { id, method, params } = message;
2667
+ if (typeof method !== "string") return;
2668
+ const args = typeof params === "object" && params !== null ? params : {};
2669
+ if (!isId(id)) {
2670
+ if (method === "notifications/cancelled" && isId(args.requestId)) {
2671
+ this.running.get(args.requestId)?.abort();
2672
+ }
2673
+ return;
2674
+ }
2675
+ switch (method) {
2676
+ case "initialize":
2677
+ return this.reply(id, {
2678
+ protocolVersion: PROTOCOL_VERSION,
2679
+ capabilities: { tools: {} },
2680
+ serverInfo: {
2681
+ name: this.options.manifest?.name ?? "",
2682
+ version: this.options.manifest?.version ?? ""
2683
+ }
2684
+ });
2685
+ case "ping":
2686
+ return this.reply(id, {});
2687
+ case "tools/list": {
2688
+ const tools = this.tools().map(({ name, title, description, inputSchema }) => ({
2689
+ name,
2690
+ title: title.en,
2691
+ description,
2692
+ inputSchema
2693
+ }));
2694
+ return this.reply(id, { tools });
2695
+ }
2696
+ case "tools/call":
2697
+ void this.call(id, args);
2698
+ return;
2699
+ default:
2700
+ return this.error(id, METHOD_NOT_FOUND, method);
2701
+ }
2702
+ }
2703
+ /** The declared tools that have a handler. */
2704
+ tools() {
2705
+ return (this.options.manifest?.tools ?? []).filter((tool) => this.options.handlers.has(tool.name));
2706
+ }
2707
+ async call(id, params) {
2708
+ const tool = this.tools().find((candidate) => candidate.name === params.name);
2709
+ const handler = tool && this.options.handlers.get(tool.name);
2710
+ if (!tool || !handler) return this.error(id, INVALID_PARAMS, `unknown tool ${String(params.name)}`);
2711
+ const input = params.arguments ?? {};
2712
+ const checked = validateInput(tool.inputSchema, input);
2713
+ if (!checked.ok) {
2714
+ return this.reply(id, textResult(`invalid input: ${checked.field}: ${checked.message}`, true));
2715
+ }
2716
+ const controller = new AbortController();
2717
+ this.running.set(id, controller);
2718
+ let result;
2719
+ try {
2720
+ const output = await handler(input, { signal: controller.signal });
2721
+ result = textResult(asText(output), false);
2722
+ } catch (error) {
2723
+ result = textResult(error instanceof Error ? error.message : String(error), true);
2724
+ } finally {
2725
+ this.running.delete(id);
2726
+ }
2727
+ if (!controller.signal.aborted) this.reply(id, result);
2728
+ }
2729
+ reply(id, result) {
2730
+ this.options.send({ jsonrpc: "2.0", id, result });
2731
+ }
2732
+ error(id, code, message) {
2733
+ this.options.send({ jsonrpc: "2.0", id, error: { code, message } });
2734
+ }
2735
+ };
2736
+
2737
+ // src/api/tools/index.ts
2738
+ var ToolsAPI = class {
2739
+ constructor(options) {
2740
+ this.options = options;
2741
+ this.handlers = /* @__PURE__ */ new Map();
2742
+ const manifest = options.manifest;
2743
+ this.server = new ToolsServer({
2744
+ get manifest() {
2745
+ return manifest();
2746
+ },
2747
+ handlers: this.handlers,
2748
+ send: options.send
2749
+ });
2750
+ }
2751
+ /**
2752
+ * Runs `handler` when the host calls the tool `name`. The tool must be declared in the manifest.
2753
+ * Returns a function that unregisters the handler; the host then no longer sees the tool.
2754
+ */
2755
+ register(name, handler) {
2756
+ const declared = this.options.manifest()?.tools?.some((tool) => tool.name === name) ?? false;
2757
+ if (!declared) {
2758
+ throw new Error(`The tool ${name} is not declared in the manifest's tools`);
2759
+ }
2760
+ this.handlers.set(name, handler);
2761
+ return () => {
2762
+ if (this.handlers.get(name) === handler) this.handlers.delete(name);
2763
+ };
2764
+ }
2765
+ /** Handles one MCP message from the host. Called by the SDK for `haexspace:mcp` port messages. */
2766
+ receive(message) {
2767
+ return this.server.receive(message);
2768
+ }
2769
+ };
2770
+
2444
2771
  // src/client/tableName.ts
2445
2772
  init_cjs_shims();
2446
2773
  function validatePublicKey(publicKey) {
@@ -2822,7 +3149,11 @@ function createMessageHandler(config, pendingRequests, extensionInfo, onEvent) {
2822
3149
  }
2823
3150
  };
2824
3151
  }
2825
- function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest, onActionRequest) {
3152
+ function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest, onActionRequest, onMcpMessage) {
3153
+ if (event.type === HAEXSPACE_MESSAGE_TYPES.MCP) {
3154
+ onMcpMessage?.(event.message);
3155
+ return;
3156
+ }
2826
3157
  if (event.type === HAEXTENSION_EVENTS.CONTEXT_CHANGED) {
2827
3158
  const contextEvent = event;
2828
3159
  onContextChanged(contextEvent.data.context);
@@ -3094,6 +3425,7 @@ var HaexVaultSdk = class {
3094
3425
  this.web = new WebAPI(this);
3095
3426
  this.permissions = new PermissionsAPI(this);
3096
3427
  this.remoteStorage = new RemoteStorageAPI(this);
3428
+ this.encryptedFolders = new EncryptedFoldersAPI(this);
3097
3429
  this.localsend = new LocalSendAPI(this);
3098
3430
  this.spaces = new SpacesAPI(this);
3099
3431
  this.shell = new ShellAPI(this);
@@ -3102,6 +3434,10 @@ var HaexVaultSdk = class {
3102
3434
  this.notifications = new NotificationsAPI(this);
3103
3435
  this.tab = new TabAPI(this);
3104
3436
  this.dialog = new DialogAPI(this);
3437
+ this.tools = new ToolsAPI({
3438
+ manifest: () => this.config.manifest,
3439
+ send: (message) => this.sendMcpMessage(message)
3440
+ });
3105
3441
  installConsoleForwarding(this.config.debug);
3106
3442
  this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
3107
3443
  const data = event.data;
@@ -3409,9 +3745,18 @@ var HaexVaultSdk = class {
3409
3745
  this.notifySubscribersInternal();
3410
3746
  },
3411
3747
  (extEvent) => this.handleExternalRequestInternal(extEvent.data),
3412
- (actionEvent) => this.handleActionRequestInternal(actionEvent.data)
3748
+ (actionEvent) => this.handleActionRequestInternal(actionEvent.data),
3749
+ (message) => void this.tools.receive(message)
3413
3750
  );
3414
3751
  }
3752
+ /** Sends one MCP message of the tool connection to the host on the port. */
3753
+ sendMcpMessage(message) {
3754
+ if (!this.hostPort) {
3755
+ this.log("Dropped an MCP message: no host port yet");
3756
+ return;
3757
+ }
3758
+ this.hostPort.postMessage({ type: HAEXSPACE_MESSAGE_TYPES.MCP, message });
3759
+ }
3415
3760
  async handleExternalRequestInternal(request) {
3416
3761
  await handleExternalRequest(request, this.externalRequestHandlers, this.respondToExternalRequest.bind(this), this.log.bind(this));
3417
3762
  }
@@ -3958,7 +4303,9 @@ exports.COSE_ALGORITHM = COSE_ALGORITHM;
3958
4303
  exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
3959
4304
  exports.DatabaseAPI = DatabaseAPI;
3960
4305
  exports.DialogAPI = DialogAPI;
4306
+ exports.ENCRYPTED_FOLDER_COMMANDS = ENCRYPTED_FOLDER_COMMANDS;
3961
4307
  exports.EXTERNAL_EVENTS = EXTERNAL_EVENTS;
4308
+ exports.EncryptedFoldersAPI = EncryptedFoldersAPI;
3962
4309
  exports.ErrorCode = ErrorCode;
3963
4310
  exports.ExternalConnectionErrorCode = ExternalConnectionErrorCode;
3964
4311
  exports.ExternalConnectionState = ExternalConnectionState;
@@ -3967,6 +4314,7 @@ exports.HAEXSPACE_MESSAGE_TYPES = HAEXSPACE_MESSAGE_TYPES;
3967
4314
  exports.HAEXTENSION_EVENTS = HAEXTENSION_EVENTS;
3968
4315
  exports.HaexVaultSdk = HaexVaultSdk;
3969
4316
  exports.HaexVaultSdkError = HaexVaultSdkError;
4317
+ exports.HostErrorCode = HostErrorCode;
3970
4318
  exports.KnownPath = KnownPath;
3971
4319
  exports.LOCALSEND_EVENTS = LOCALSEND_EVENTS;
3972
4320
  exports.LocalSendAPI = LocalSendAPI;
@@ -3989,6 +4337,7 @@ exports.SpacesAPI = SpacesAPI;
3989
4337
  exports.TABLE_SEPARATOR = TABLE_SEPARATOR;
3990
4338
  exports.TAURI_COMMANDS = TAURI_COMMANDS;
3991
4339
  exports.TabAPI = TabAPI;
4340
+ exports.ToolsAPI = ToolsAPI;
3992
4341
  exports.WebAPI = WebAPI;
3993
4342
  exports.arrayBufferToBase64 = arrayBufferToBase64;
3994
4343
  exports.base58btcDecode = base58btcDecode;