@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.
- package/README.md +69 -0
- package/dist/cli/index.js +2 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +2 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{client-Cx4ZyQFL.d.mts → client-CDox5_KH.d.mts} +263 -27
- package/dist/{client-CD5QZi7F.d.ts → client-pppDo5Q3.d.ts} +263 -27
- package/dist/haex_bundle_bg.wasm +0 -0
- package/dist/index.d.mts +45 -6
- package/dist/index.d.ts +45 -6
- package/dist/index.js +363 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +360 -15
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +2 -1
- package/dist/node.js.map +1 -1
- package/dist/node.mjs +2 -1
- package/dist/node.mjs.map +1 -1
- package/dist/nuxt.js +10 -2
- package/dist/nuxt.js.map +1 -1
- package/dist/nuxt.mjs +10 -2
- package/dist/nuxt.mjs.map +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +339 -14
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +339 -14
- package/dist/react.mjs.map +1 -1
- package/dist/runtime/nuxt.plugin.client.d.mts +2 -2
- package/dist/runtime/nuxt.plugin.client.d.ts +2 -2
- package/dist/runtime/nuxt.plugin.client.js +329 -14
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +329 -14
- package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
- package/dist/svelte.d.mts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/svelte.js +339 -14
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +339 -14
- package/dist/svelte.mjs.map +1 -1
- package/dist/{types-BwFKGH70.d.mts → types-DoNvKiW_.d.mts} +75 -1
- package/dist/{types-BwFKGH70.d.ts → types-DoNvKiW_.d.ts} +75 -1
- package/dist/vite.js +8 -1
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +8 -1
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.d.mts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +339 -14
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +339 -14
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -211,6 +211,20 @@ var REMOTE_STORAGE_COMMANDS = {
|
|
|
211
211
|
list: "extension_remote_storage_list"
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
+
// src/commands/encryptedFolders.ts
|
|
215
|
+
var ENCRYPTED_FOLDER_COMMANDS = {
|
|
216
|
+
/** Let the user pick an encrypted folder of a storage and grant access to it */
|
|
217
|
+
choose: "extension_encrypted_folder_choose",
|
|
218
|
+
/** List the entries of a folder inside an encrypted folder */
|
|
219
|
+
list: "extension_encrypted_folder_list",
|
|
220
|
+
/** Download and decrypt a file */
|
|
221
|
+
download: "extension_encrypted_folder_download",
|
|
222
|
+
/** Encrypt and upload a file */
|
|
223
|
+
upload: "extension_encrypted_folder_upload",
|
|
224
|
+
/** Delete a file or folder */
|
|
225
|
+
delete: "extension_encrypted_folder_delete"
|
|
226
|
+
};
|
|
227
|
+
|
|
214
228
|
// src/commands/localsend.ts
|
|
215
229
|
var LOCALSEND_COMMANDS = {
|
|
216
230
|
// Initialization
|
|
@@ -950,26 +964,32 @@ var BackendManagement = class {
|
|
|
950
964
|
);
|
|
951
965
|
}
|
|
952
966
|
/**
|
|
953
|
-
*
|
|
954
|
-
*
|
|
967
|
+
* Propose a new storage. The host asks the user; credentials are entered
|
|
968
|
+
* only there. Resolves with the new storage, which the extension may then
|
|
969
|
+
* read and write.
|
|
970
|
+
* @param request - The proposal, without credentials
|
|
955
971
|
* @returns Created backend info
|
|
956
972
|
*/
|
|
957
973
|
async add(request) {
|
|
958
974
|
return this.client.request(
|
|
959
975
|
REMOTE_STORAGE_COMMANDS.addBackend,
|
|
960
|
-
{ request }
|
|
976
|
+
{ request },
|
|
977
|
+
// No deadline: the host waits for the user's answer in its dialog.
|
|
978
|
+
{ timeout: null }
|
|
961
979
|
);
|
|
962
980
|
}
|
|
963
981
|
/**
|
|
964
|
-
*
|
|
965
|
-
* Only provided fields are updated
|
|
982
|
+
* Change a storage after the user confirms it in the host.
|
|
983
|
+
* Only provided fields are updated; new credentials are entered in the host.
|
|
966
984
|
* @param request - Update request with backendId and fields to update
|
|
967
985
|
* @returns Updated backend info
|
|
968
986
|
*/
|
|
969
987
|
async update(request) {
|
|
970
988
|
return this.client.request(
|
|
971
989
|
REMOTE_STORAGE_COMMANDS.updateBackend,
|
|
972
|
-
{ request }
|
|
990
|
+
{ request },
|
|
991
|
+
// No deadline: the host waits for the user's answer in its dialog.
|
|
992
|
+
{ timeout: null }
|
|
973
993
|
);
|
|
974
994
|
}
|
|
975
995
|
/**
|
|
@@ -977,17 +997,98 @@ var BackendManagement = class {
|
|
|
977
997
|
* @param backendId - Backend ID to remove
|
|
978
998
|
*/
|
|
979
999
|
async remove(backendId) {
|
|
980
|
-
await this.client.request(
|
|
981
|
-
|
|
982
|
-
|
|
1000
|
+
await this.client.request(
|
|
1001
|
+
REMOTE_STORAGE_COMMANDS.removeBackend,
|
|
1002
|
+
{ backendId },
|
|
1003
|
+
{ timeout: null }
|
|
1004
|
+
);
|
|
983
1005
|
}
|
|
984
1006
|
/**
|
|
985
1007
|
* Test connection to a storage backend
|
|
986
1008
|
* @param backendId - Backend ID to test
|
|
987
1009
|
*/
|
|
988
1010
|
async test(backendId) {
|
|
989
|
-
await this.client.request(
|
|
990
|
-
|
|
1011
|
+
await this.client.request(
|
|
1012
|
+
REMOTE_STORAGE_COMMANDS.testBackend,
|
|
1013
|
+
{ backendId },
|
|
1014
|
+
{ timeout: null }
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
// src/api/encryptedFolders.ts
|
|
1020
|
+
var EncryptedFoldersAPI = class {
|
|
1021
|
+
constructor(client) {
|
|
1022
|
+
this.client = client;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Let the user choose one of the storage's encrypted folders and grant
|
|
1026
|
+
* access to it. The host shows its own window and waits for the answer.
|
|
1027
|
+
* Needs the `remoteStorage` permission for the storage (else 1002 without
|
|
1028
|
+
* asking); 1002 as well when the user refuses.
|
|
1029
|
+
* @param storageId - Storage the folder lies in
|
|
1030
|
+
* @param access - Access the extension asks for
|
|
1031
|
+
* @returns The chosen folder, or `null` when the user closed the chooser without choosing
|
|
1032
|
+
*/
|
|
1033
|
+
async choose(storageId, access) {
|
|
1034
|
+
const choice = await this.client.request(
|
|
1035
|
+
ENCRYPTED_FOLDER_COMMANDS.choose,
|
|
1036
|
+
{ request: { storageId, access } },
|
|
1037
|
+
// No deadline: the host waits for the user's answer in its window.
|
|
1038
|
+
{ timeout: null }
|
|
1039
|
+
);
|
|
1040
|
+
return choice ?? null;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* List a folder inside an encrypted folder (permission `read`).
|
|
1044
|
+
* @param storageId - Storage the folder lies in
|
|
1045
|
+
* @param folderId - Folder from {@link EncryptedFoldersAPI.choose}
|
|
1046
|
+
* @param path - Path relative to the encrypted folder; `''` (default) for its root
|
|
1047
|
+
* @returns The entries with their decrypted names
|
|
1048
|
+
*/
|
|
1049
|
+
async list(storageId, folderId, path = "") {
|
|
1050
|
+
const result = await this.client.request(
|
|
1051
|
+
ENCRYPTED_FOLDER_COMMANDS.list,
|
|
1052
|
+
{ request: { storageId, folderId, path } }
|
|
1053
|
+
);
|
|
1054
|
+
return result.entries;
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Download and decrypt a file (permission `read`).
|
|
1058
|
+
* @param storageId - Storage the folder lies in
|
|
1059
|
+
* @param folderId - Folder from {@link EncryptedFoldersAPI.choose}
|
|
1060
|
+
* @param path - Path of the file, relative to the encrypted folder
|
|
1061
|
+
* @returns The decrypted content
|
|
1062
|
+
*/
|
|
1063
|
+
async download(storageId, folderId, path) {
|
|
1064
|
+
const base64 = await this.client.request(
|
|
1065
|
+
ENCRYPTED_FOLDER_COMMANDS.download,
|
|
1066
|
+
{ request: { storageId, folderId, path } }
|
|
1067
|
+
);
|
|
1068
|
+
return base64ToArrayBuffer(base64);
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Encrypt and upload a file (permission `readWrite`). Missing parent
|
|
1072
|
+
* folders are created.
|
|
1073
|
+
* @param storageId - Storage the folder lies in
|
|
1074
|
+
* @param folderId - Folder from {@link EncryptedFoldersAPI.choose}
|
|
1075
|
+
* @param path - Path of the file, relative to the encrypted folder
|
|
1076
|
+
* @param data - Content of the file
|
|
1077
|
+
*/
|
|
1078
|
+
async upload(storageId, folderId, path, data) {
|
|
1079
|
+
await this.client.request(ENCRYPTED_FOLDER_COMMANDS.upload, {
|
|
1080
|
+
request: { storageId, folderId, path, data: arrayBufferToBase64(data) }
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Delete a file or folder (permission `readWrite`).
|
|
1085
|
+
* @param storageId - Storage the folder lies in
|
|
1086
|
+
* @param folderId - Folder from {@link EncryptedFoldersAPI.choose}
|
|
1087
|
+
* @param path - Path relative to the encrypted folder
|
|
1088
|
+
*/
|
|
1089
|
+
async delete(storageId, folderId, path) {
|
|
1090
|
+
await this.client.request(ENCRYPTED_FOLDER_COMMANDS.delete, {
|
|
1091
|
+
request: { storageId, folderId, path }
|
|
991
1092
|
});
|
|
992
1093
|
}
|
|
993
1094
|
};
|
|
@@ -1590,6 +1691,195 @@ var DialogAPI = class {
|
|
|
1590
1691
|
}
|
|
1591
1692
|
};
|
|
1592
1693
|
|
|
1694
|
+
// src/api/tools/schema.ts
|
|
1695
|
+
function fail(field, message) {
|
|
1696
|
+
return { ok: false, field, message };
|
|
1697
|
+
}
|
|
1698
|
+
function typeMatches(type, value) {
|
|
1699
|
+
switch (type) {
|
|
1700
|
+
case "object":
|
|
1701
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1702
|
+
case "array":
|
|
1703
|
+
return Array.isArray(value);
|
|
1704
|
+
case "integer":
|
|
1705
|
+
return Number.isInteger(value);
|
|
1706
|
+
case "number":
|
|
1707
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
1708
|
+
case "string":
|
|
1709
|
+
return typeof value === "string";
|
|
1710
|
+
case "boolean":
|
|
1711
|
+
return typeof value === "boolean";
|
|
1712
|
+
default:
|
|
1713
|
+
return false;
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
function validateAt(schema, value, field) {
|
|
1717
|
+
if (!typeMatches(schema.type, value)) return fail(field, `expected ${String(schema.type)}`);
|
|
1718
|
+
if (schema.enum && !schema.enum.includes(value)) {
|
|
1719
|
+
return fail(field, `expected one of ${schema.enum.join(", ")}`);
|
|
1720
|
+
}
|
|
1721
|
+
if (schema.type === "array" && schema.items) {
|
|
1722
|
+
const items = value;
|
|
1723
|
+
for (let i = 0; i < items.length; i++) {
|
|
1724
|
+
const result = validateAt(schema.items, items[i], `${field}[${i}]`);
|
|
1725
|
+
if (!result.ok) return result;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
if (schema.type === "object") {
|
|
1729
|
+
const record = value;
|
|
1730
|
+
const properties = schema.properties ?? {};
|
|
1731
|
+
const prefix = field === "" ? "" : `${field}.`;
|
|
1732
|
+
if (schema.properties) {
|
|
1733
|
+
for (const key of Object.keys(record)) {
|
|
1734
|
+
if (!Object.hasOwn(properties, key)) return fail(`${prefix}${key}`, "unknown property");
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
for (const key of schema.required ?? []) {
|
|
1738
|
+
if (record[key] === void 0) return fail(`${prefix}${key}`, "required");
|
|
1739
|
+
}
|
|
1740
|
+
for (const [key, child] of Object.entries(properties)) {
|
|
1741
|
+
if (record[key] === void 0) continue;
|
|
1742
|
+
const result = validateAt(child, record[key], `${prefix}${key}`);
|
|
1743
|
+
if (!result.ok) return result;
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
return { ok: true };
|
|
1747
|
+
}
|
|
1748
|
+
function validateInput(schema, value) {
|
|
1749
|
+
return validateAt(schema, value, "");
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
// src/api/tools/server.ts
|
|
1753
|
+
var PROTOCOL_VERSION = "2025-11-25";
|
|
1754
|
+
var METHOD_NOT_FOUND = -32601;
|
|
1755
|
+
var INVALID_PARAMS = -32602;
|
|
1756
|
+
function textResult(text, isError) {
|
|
1757
|
+
return { content: [{ type: "text", text }], isError };
|
|
1758
|
+
}
|
|
1759
|
+
function asText(value) {
|
|
1760
|
+
if (typeof value === "string") return value;
|
|
1761
|
+
if (value === void 0) return "";
|
|
1762
|
+
return JSON.stringify(value);
|
|
1763
|
+
}
|
|
1764
|
+
function isId(value) {
|
|
1765
|
+
return typeof value === "string" || typeof value === "number";
|
|
1766
|
+
}
|
|
1767
|
+
var ToolsServer = class {
|
|
1768
|
+
constructor(options) {
|
|
1769
|
+
this.options = options;
|
|
1770
|
+
this.running = /* @__PURE__ */ new Map();
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* Handles one JSON-RPC message from the host. A tool call runs on its own and answers when it is
|
|
1774
|
+
* done, so a long call never holds up `ping` or the cancellation of that very call.
|
|
1775
|
+
*/
|
|
1776
|
+
async receive(message) {
|
|
1777
|
+
if (typeof message !== "object" || message === null) return;
|
|
1778
|
+
const { id, method, params } = message;
|
|
1779
|
+
if (typeof method !== "string") return;
|
|
1780
|
+
const args = typeof params === "object" && params !== null ? params : {};
|
|
1781
|
+
if (!isId(id)) {
|
|
1782
|
+
if (method === "notifications/cancelled" && isId(args.requestId)) {
|
|
1783
|
+
this.running.get(args.requestId)?.abort();
|
|
1784
|
+
}
|
|
1785
|
+
return;
|
|
1786
|
+
}
|
|
1787
|
+
switch (method) {
|
|
1788
|
+
case "initialize":
|
|
1789
|
+
return this.reply(id, {
|
|
1790
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
1791
|
+
capabilities: { tools: {} },
|
|
1792
|
+
serverInfo: {
|
|
1793
|
+
name: this.options.manifest?.name ?? "",
|
|
1794
|
+
version: this.options.manifest?.version ?? ""
|
|
1795
|
+
}
|
|
1796
|
+
});
|
|
1797
|
+
case "ping":
|
|
1798
|
+
return this.reply(id, {});
|
|
1799
|
+
case "tools/list": {
|
|
1800
|
+
const tools = this.tools().map(({ name, title, description, inputSchema }) => ({
|
|
1801
|
+
name,
|
|
1802
|
+
title: title.en,
|
|
1803
|
+
description,
|
|
1804
|
+
inputSchema
|
|
1805
|
+
}));
|
|
1806
|
+
return this.reply(id, { tools });
|
|
1807
|
+
}
|
|
1808
|
+
case "tools/call":
|
|
1809
|
+
void this.call(id, args);
|
|
1810
|
+
return;
|
|
1811
|
+
default:
|
|
1812
|
+
return this.error(id, METHOD_NOT_FOUND, method);
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
/** The declared tools that have a handler. */
|
|
1816
|
+
tools() {
|
|
1817
|
+
return (this.options.manifest?.tools ?? []).filter((tool) => this.options.handlers.has(tool.name));
|
|
1818
|
+
}
|
|
1819
|
+
async call(id, params) {
|
|
1820
|
+
const tool = this.tools().find((candidate) => candidate.name === params.name);
|
|
1821
|
+
const handler = tool && this.options.handlers.get(tool.name);
|
|
1822
|
+
if (!tool || !handler) return this.error(id, INVALID_PARAMS, `unknown tool ${String(params.name)}`);
|
|
1823
|
+
const input = params.arguments ?? {};
|
|
1824
|
+
const checked = validateInput(tool.inputSchema, input);
|
|
1825
|
+
if (!checked.ok) {
|
|
1826
|
+
return this.reply(id, textResult(`invalid input: ${checked.field}: ${checked.message}`, true));
|
|
1827
|
+
}
|
|
1828
|
+
const controller = new AbortController();
|
|
1829
|
+
this.running.set(id, controller);
|
|
1830
|
+
let result;
|
|
1831
|
+
try {
|
|
1832
|
+
const output = await handler(input, { signal: controller.signal });
|
|
1833
|
+
result = textResult(asText(output), false);
|
|
1834
|
+
} catch (error) {
|
|
1835
|
+
result = textResult(error instanceof Error ? error.message : String(error), true);
|
|
1836
|
+
} finally {
|
|
1837
|
+
this.running.delete(id);
|
|
1838
|
+
}
|
|
1839
|
+
if (!controller.signal.aborted) this.reply(id, result);
|
|
1840
|
+
}
|
|
1841
|
+
reply(id, result) {
|
|
1842
|
+
this.options.send({ jsonrpc: "2.0", id, result });
|
|
1843
|
+
}
|
|
1844
|
+
error(id, code, message) {
|
|
1845
|
+
this.options.send({ jsonrpc: "2.0", id, error: { code, message } });
|
|
1846
|
+
}
|
|
1847
|
+
};
|
|
1848
|
+
|
|
1849
|
+
// src/api/tools/index.ts
|
|
1850
|
+
var ToolsAPI = class {
|
|
1851
|
+
constructor(options) {
|
|
1852
|
+
this.options = options;
|
|
1853
|
+
this.handlers = /* @__PURE__ */ new Map();
|
|
1854
|
+
const manifest = options.manifest;
|
|
1855
|
+
this.server = new ToolsServer({
|
|
1856
|
+
get manifest() {
|
|
1857
|
+
return manifest();
|
|
1858
|
+
},
|
|
1859
|
+
handlers: this.handlers,
|
|
1860
|
+
send: options.send
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
/**
|
|
1864
|
+
* Runs `handler` when the host calls the tool `name`. The tool must be declared in the manifest.
|
|
1865
|
+
* Returns a function that unregisters the handler; the host then no longer sees the tool.
|
|
1866
|
+
*/
|
|
1867
|
+
register(name, handler) {
|
|
1868
|
+
const declared = this.options.manifest()?.tools?.some((tool) => tool.name === name) ?? false;
|
|
1869
|
+
if (!declared) {
|
|
1870
|
+
throw new Error(`The tool ${name} is not declared in the manifest's tools`);
|
|
1871
|
+
}
|
|
1872
|
+
this.handlers.set(name, handler);
|
|
1873
|
+
return () => {
|
|
1874
|
+
if (this.handlers.get(name) === handler) this.handlers.delete(name);
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
/** Handles one MCP message from the host. Called by the SDK for `haexspace:mcp` port messages. */
|
|
1878
|
+
receive(message) {
|
|
1879
|
+
return this.server.receive(message);
|
|
1880
|
+
}
|
|
1881
|
+
};
|
|
1882
|
+
|
|
1593
1883
|
// src/messages.ts
|
|
1594
1884
|
var HAEXSPACE_MESSAGE_TYPES = {
|
|
1595
1885
|
/** Debug message for development/troubleshooting */
|
|
@@ -1612,7 +1902,14 @@ var HAEXSPACE_MESSAGE_TYPES = {
|
|
|
1612
1902
|
*
|
|
1613
1903
|
* Payload: `{ type: PORT_READY }` — no data.
|
|
1614
1904
|
*/
|
|
1615
|
-
PORT_READY: "haexspace:port:ready"
|
|
1905
|
+
PORT_READY: "haexspace:port:ready",
|
|
1906
|
+
/**
|
|
1907
|
+
* One MCP message of the tool connection (holzi spec 018), in both directions over the
|
|
1908
|
+
* MessagePort: the host calls the extension's tools, `sdk.tools` answers.
|
|
1909
|
+
*
|
|
1910
|
+
* Payload: `{ type: MCP, message }`, where `message` is a JSON-RPC 2.0 object.
|
|
1911
|
+
*/
|
|
1912
|
+
MCP: "haexspace:mcp"
|
|
1616
1913
|
};
|
|
1617
1914
|
|
|
1618
1915
|
// src/polyfills/consoleForwarding.ts
|
|
@@ -2058,7 +2355,11 @@ function createMessageHandler(config, pendingRequests, extensionInfo, onEvent) {
|
|
|
2058
2355
|
}
|
|
2059
2356
|
};
|
|
2060
2357
|
}
|
|
2061
|
-
function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest, onActionRequest) {
|
|
2358
|
+
function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest, onActionRequest, onMcpMessage) {
|
|
2359
|
+
if (event.type === HAEXSPACE_MESSAGE_TYPES.MCP) {
|
|
2360
|
+
onMcpMessage?.(event.message);
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
2062
2363
|
if (event.type === HAEXTENSION_EVENTS.CONTEXT_CHANGED) {
|
|
2063
2364
|
const contextEvent = event;
|
|
2064
2365
|
onContextChanged(contextEvent.data.context);
|
|
@@ -2324,6 +2625,7 @@ var HaexVaultSdk = class {
|
|
|
2324
2625
|
this.web = new WebAPI(this);
|
|
2325
2626
|
this.permissions = new PermissionsAPI(this);
|
|
2326
2627
|
this.remoteStorage = new RemoteStorageAPI(this);
|
|
2628
|
+
this.encryptedFolders = new EncryptedFoldersAPI(this);
|
|
2327
2629
|
this.localsend = new LocalSendAPI(this);
|
|
2328
2630
|
this.spaces = new SpacesAPI(this);
|
|
2329
2631
|
this.shell = new ShellAPI(this);
|
|
@@ -2332,6 +2634,10 @@ var HaexVaultSdk = class {
|
|
|
2332
2634
|
this.notifications = new NotificationsAPI(this);
|
|
2333
2635
|
this.tab = new TabAPI(this);
|
|
2334
2636
|
this.dialog = new DialogAPI(this);
|
|
2637
|
+
this.tools = new ToolsAPI({
|
|
2638
|
+
manifest: () => this.config.manifest,
|
|
2639
|
+
send: (message) => this.sendMcpMessage(message)
|
|
2640
|
+
});
|
|
2335
2641
|
installConsoleForwarding(this.config.debug);
|
|
2336
2642
|
this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
|
|
2337
2643
|
const data = event.data;
|
|
@@ -2639,9 +2945,18 @@ var HaexVaultSdk = class {
|
|
|
2639
2945
|
this.notifySubscribersInternal();
|
|
2640
2946
|
},
|
|
2641
2947
|
(extEvent) => this.handleExternalRequestInternal(extEvent.data),
|
|
2642
|
-
(actionEvent) => this.handleActionRequestInternal(actionEvent.data)
|
|
2948
|
+
(actionEvent) => this.handleActionRequestInternal(actionEvent.data),
|
|
2949
|
+
(message) => void this.tools.receive(message)
|
|
2643
2950
|
);
|
|
2644
2951
|
}
|
|
2952
|
+
/** Sends one MCP message of the tool connection to the host on the port. */
|
|
2953
|
+
sendMcpMessage(message) {
|
|
2954
|
+
if (!this.hostPort) {
|
|
2955
|
+
this.log("Dropped an MCP message: no host port yet");
|
|
2956
|
+
return;
|
|
2957
|
+
}
|
|
2958
|
+
this.hostPort.postMessage({ type: HAEXSPACE_MESSAGE_TYPES.MCP, message });
|
|
2959
|
+
}
|
|
2645
2960
|
async handleExternalRequestInternal(request) {
|
|
2646
2961
|
await handleExternalRequest(request, this.externalRequestHandlers, this.respondToExternalRequest.bind(this), this.log.bind(this));
|
|
2647
2962
|
}
|