@haex-space/vault-sdk 4.2.0 → 4.4.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-7bZyiRwE.d.mts → client-BCUfRZvU.d.mts} +261 -13
- package/dist/{client-BPwsH1so.d.ts → client-C44dqakd.d.ts} +261 -13
- 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 +342 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +339 -4
- 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 +318 -3
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +318 -3
- 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 +308 -3
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +308 -3
- 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 +318 -3
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +318 -3
- 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 +318 -3
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +318 -3
- package/dist/vue.mjs.map +1 -1
- 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,
|
|
@@ -1843,6 +1885,85 @@ var BackendManagement = class {
|
|
|
1843
1885
|
}
|
|
1844
1886
|
};
|
|
1845
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 }
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
};
|
|
1966
|
+
|
|
1846
1967
|
// src/api/localsend.ts
|
|
1847
1968
|
init_esm_shims();
|
|
1848
1969
|
var LOCALSEND_EVENTS = {
|
|
@@ -2449,6 +2570,202 @@ var DialogAPI = class {
|
|
|
2449
2570
|
}
|
|
2450
2571
|
};
|
|
2451
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
|
+
|
|
2452
2769
|
// src/client/tableName.ts
|
|
2453
2770
|
init_esm_shims();
|
|
2454
2771
|
function validatePublicKey(publicKey) {
|
|
@@ -2830,7 +3147,11 @@ function createMessageHandler(config, pendingRequests, extensionInfo, onEvent) {
|
|
|
2830
3147
|
}
|
|
2831
3148
|
};
|
|
2832
3149
|
}
|
|
2833
|
-
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
|
+
}
|
|
2834
3155
|
if (event.type === HAEXTENSION_EVENTS.CONTEXT_CHANGED) {
|
|
2835
3156
|
const contextEvent = event;
|
|
2836
3157
|
onContextChanged(contextEvent.data.context);
|
|
@@ -3102,6 +3423,7 @@ var HaexVaultSdk = class {
|
|
|
3102
3423
|
this.web = new WebAPI(this);
|
|
3103
3424
|
this.permissions = new PermissionsAPI(this);
|
|
3104
3425
|
this.remoteStorage = new RemoteStorageAPI(this);
|
|
3426
|
+
this.encryptedFolders = new EncryptedFoldersAPI(this);
|
|
3105
3427
|
this.localsend = new LocalSendAPI(this);
|
|
3106
3428
|
this.spaces = new SpacesAPI(this);
|
|
3107
3429
|
this.shell = new ShellAPI(this);
|
|
@@ -3110,6 +3432,10 @@ var HaexVaultSdk = class {
|
|
|
3110
3432
|
this.notifications = new NotificationsAPI(this);
|
|
3111
3433
|
this.tab = new TabAPI(this);
|
|
3112
3434
|
this.dialog = new DialogAPI(this);
|
|
3435
|
+
this.tools = new ToolsAPI({
|
|
3436
|
+
manifest: () => this.config.manifest,
|
|
3437
|
+
send: (message) => this.sendMcpMessage(message)
|
|
3438
|
+
});
|
|
3113
3439
|
installConsoleForwarding(this.config.debug);
|
|
3114
3440
|
this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
|
|
3115
3441
|
const data = event.data;
|
|
@@ -3417,9 +3743,18 @@ var HaexVaultSdk = class {
|
|
|
3417
3743
|
this.notifySubscribersInternal();
|
|
3418
3744
|
},
|
|
3419
3745
|
(extEvent) => this.handleExternalRequestInternal(extEvent.data),
|
|
3420
|
-
(actionEvent) => this.handleActionRequestInternal(actionEvent.data)
|
|
3746
|
+
(actionEvent) => this.handleActionRequestInternal(actionEvent.data),
|
|
3747
|
+
(message) => void this.tools.receive(message)
|
|
3421
3748
|
);
|
|
3422
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
|
+
}
|
|
3423
3758
|
async handleExternalRequestInternal(request) {
|
|
3424
3759
|
await handleExternalRequest(request, this.externalRequestHandlers, this.respondToExternalRequest.bind(this), this.log.bind(this));
|
|
3425
3760
|
}
|
|
@@ -3962,6 +4297,6 @@ function createHaexVaultSdk(config = {}) {
|
|
|
3962
4297
|
return new HaexVaultSdk(config);
|
|
3963
4298
|
}
|
|
3964
4299
|
|
|
3965
|
-
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 };
|
|
3966
4301
|
//# sourceMappingURL=index.mjs.map
|
|
3967
4302
|
//# sourceMappingURL=index.mjs.map
|