@haex-space/vault-sdk 4.2.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-BPwsH1so.d.ts → client-CDox5_KH.d.mts} +166 -2
- package/dist/{client-7bZyiRwE.d.mts → client-pppDo5Q3.d.ts} +166 -2
- 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.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,
|
|
@@ -1845,6 +1887,85 @@ var BackendManagement = class {
|
|
|
1845
1887
|
}
|
|
1846
1888
|
};
|
|
1847
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 }
|
|
1965
|
+
});
|
|
1966
|
+
}
|
|
1967
|
+
};
|
|
1968
|
+
|
|
1848
1969
|
// src/api/localsend.ts
|
|
1849
1970
|
init_cjs_shims();
|
|
1850
1971
|
var LOCALSEND_EVENTS = {
|
|
@@ -2451,6 +2572,202 @@ var DialogAPI = class {
|
|
|
2451
2572
|
}
|
|
2452
2573
|
};
|
|
2453
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
|
+
|
|
2454
2771
|
// src/client/tableName.ts
|
|
2455
2772
|
init_cjs_shims();
|
|
2456
2773
|
function validatePublicKey(publicKey) {
|
|
@@ -2832,7 +3149,11 @@ function createMessageHandler(config, pendingRequests, extensionInfo, onEvent) {
|
|
|
2832
3149
|
}
|
|
2833
3150
|
};
|
|
2834
3151
|
}
|
|
2835
|
-
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
|
+
}
|
|
2836
3157
|
if (event.type === HAEXTENSION_EVENTS.CONTEXT_CHANGED) {
|
|
2837
3158
|
const contextEvent = event;
|
|
2838
3159
|
onContextChanged(contextEvent.data.context);
|
|
@@ -3104,6 +3425,7 @@ var HaexVaultSdk = class {
|
|
|
3104
3425
|
this.web = new WebAPI(this);
|
|
3105
3426
|
this.permissions = new PermissionsAPI(this);
|
|
3106
3427
|
this.remoteStorage = new RemoteStorageAPI(this);
|
|
3428
|
+
this.encryptedFolders = new EncryptedFoldersAPI(this);
|
|
3107
3429
|
this.localsend = new LocalSendAPI(this);
|
|
3108
3430
|
this.spaces = new SpacesAPI(this);
|
|
3109
3431
|
this.shell = new ShellAPI(this);
|
|
@@ -3112,6 +3434,10 @@ var HaexVaultSdk = class {
|
|
|
3112
3434
|
this.notifications = new NotificationsAPI(this);
|
|
3113
3435
|
this.tab = new TabAPI(this);
|
|
3114
3436
|
this.dialog = new DialogAPI(this);
|
|
3437
|
+
this.tools = new ToolsAPI({
|
|
3438
|
+
manifest: () => this.config.manifest,
|
|
3439
|
+
send: (message) => this.sendMcpMessage(message)
|
|
3440
|
+
});
|
|
3115
3441
|
installConsoleForwarding(this.config.debug);
|
|
3116
3442
|
this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
|
|
3117
3443
|
const data = event.data;
|
|
@@ -3419,9 +3745,18 @@ var HaexVaultSdk = class {
|
|
|
3419
3745
|
this.notifySubscribersInternal();
|
|
3420
3746
|
},
|
|
3421
3747
|
(extEvent) => this.handleExternalRequestInternal(extEvent.data),
|
|
3422
|
-
(actionEvent) => this.handleActionRequestInternal(actionEvent.data)
|
|
3748
|
+
(actionEvent) => this.handleActionRequestInternal(actionEvent.data),
|
|
3749
|
+
(message) => void this.tools.receive(message)
|
|
3423
3750
|
);
|
|
3424
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
|
+
}
|
|
3425
3760
|
async handleExternalRequestInternal(request) {
|
|
3426
3761
|
await handleExternalRequest(request, this.externalRequestHandlers, this.respondToExternalRequest.bind(this), this.log.bind(this));
|
|
3427
3762
|
}
|
|
@@ -3968,7 +4303,9 @@ exports.COSE_ALGORITHM = COSE_ALGORITHM;
|
|
|
3968
4303
|
exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
|
|
3969
4304
|
exports.DatabaseAPI = DatabaseAPI;
|
|
3970
4305
|
exports.DialogAPI = DialogAPI;
|
|
4306
|
+
exports.ENCRYPTED_FOLDER_COMMANDS = ENCRYPTED_FOLDER_COMMANDS;
|
|
3971
4307
|
exports.EXTERNAL_EVENTS = EXTERNAL_EVENTS;
|
|
4308
|
+
exports.EncryptedFoldersAPI = EncryptedFoldersAPI;
|
|
3972
4309
|
exports.ErrorCode = ErrorCode;
|
|
3973
4310
|
exports.ExternalConnectionErrorCode = ExternalConnectionErrorCode;
|
|
3974
4311
|
exports.ExternalConnectionState = ExternalConnectionState;
|
|
@@ -3977,6 +4314,7 @@ exports.HAEXSPACE_MESSAGE_TYPES = HAEXSPACE_MESSAGE_TYPES;
|
|
|
3977
4314
|
exports.HAEXTENSION_EVENTS = HAEXTENSION_EVENTS;
|
|
3978
4315
|
exports.HaexVaultSdk = HaexVaultSdk;
|
|
3979
4316
|
exports.HaexVaultSdkError = HaexVaultSdkError;
|
|
4317
|
+
exports.HostErrorCode = HostErrorCode;
|
|
3980
4318
|
exports.KnownPath = KnownPath;
|
|
3981
4319
|
exports.LOCALSEND_EVENTS = LOCALSEND_EVENTS;
|
|
3982
4320
|
exports.LocalSendAPI = LocalSendAPI;
|
|
@@ -3999,6 +4337,7 @@ exports.SpacesAPI = SpacesAPI;
|
|
|
3999
4337
|
exports.TABLE_SEPARATOR = TABLE_SEPARATOR;
|
|
4000
4338
|
exports.TAURI_COMMANDS = TAURI_COMMANDS;
|
|
4001
4339
|
exports.TabAPI = TabAPI;
|
|
4340
|
+
exports.ToolsAPI = ToolsAPI;
|
|
4002
4341
|
exports.WebAPI = WebAPI;
|
|
4003
4342
|
exports.arrayBufferToBase64 = arrayBufferToBase64;
|
|
4004
4343
|
exports.base58btcDecode = base58btcDecode;
|