@haex-space/vault-sdk 2.6.7 → 2.7.1

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/dist/index.mjs CHANGED
@@ -682,6 +682,8 @@ var HAEXTENSION_EVENTS = {
682
682
  var EXTERNAL_EVENTS = {
683
683
  /** External request from authorized client */
684
684
  REQUEST: "haextension:external:request",
685
+ /** AI action request (tool calls from AI assistant) */
686
+ ACTION_REQUEST: "haextension:action:request",
685
687
  /** New external client requesting authorization */
686
688
  AUTHORIZATION_REQUEST: "external:authorization-request"
687
689
  };
@@ -845,6 +847,8 @@ var FILESYSTEM_COMMANDS = {
845
847
  rename: "extension_filesystem_rename",
846
848
  /** Copy file or directory */
847
849
  copy: "extension_filesystem_copy",
850
+ /** Get well-known system directory paths */
851
+ knownPaths: "extension_filesystem_known_paths",
848
852
  // File watcher operations
849
853
  /** Start watching a directory for changes */
850
854
  watch: "extension_filesystem_watch",
@@ -1144,6 +1148,15 @@ var DatabaseAPI = class {
1144
1148
 
1145
1149
  // src/api/filesystem.ts
1146
1150
  init_vaultKey();
1151
+ var KnownPath = /* @__PURE__ */ ((KnownPath2) => {
1152
+ KnownPath2["Home"] = "home";
1153
+ KnownPath2["Pictures"] = "pictures";
1154
+ KnownPath2["Downloads"] = "downloads";
1155
+ KnownPath2["Documents"] = "documents";
1156
+ KnownPath2["Desktop"] = "desktop";
1157
+ KnownPath2["Videos"] = "videos";
1158
+ return KnownPath2;
1159
+ })(KnownPath || {});
1147
1160
  var FilesystemAPI = class {
1148
1161
  constructor(client) {
1149
1162
  this.client = client;
@@ -1327,6 +1340,19 @@ var FilesystemAPI = class {
1327
1340
  );
1328
1341
  }
1329
1342
  // ==========================================================================
1343
+ // Known Paths (System Directories)
1344
+ // ==========================================================================
1345
+ /**
1346
+ * Get well-known system directory paths (home, pictures, downloads, etc.)
1347
+ * These paths are resolved via Tauri's PathResolver and are platform-aware.
1348
+ * @returns Map of known path names to their absolute paths
1349
+ */
1350
+ async knownPaths() {
1351
+ return this.client.request(
1352
+ FILESYSTEM_COMMANDS.knownPaths
1353
+ );
1354
+ }
1355
+ // ==========================================================================
1330
1356
  // File Watcher Operations
1331
1357
  // ==========================================================================
1332
1358
  /**
@@ -2118,6 +2144,24 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
2118
2144
  } catch (error) {
2119
2145
  log("Failed to setup external request listener:", error);
2120
2146
  }
2147
+ try {
2148
+ await listen(EXTERNAL_EVENTS.ACTION_REQUEST, (event) => {
2149
+ log("====== AI ACTION REQUEST RECEIVED ======");
2150
+ log("Payload:", JSON.stringify(event.payload));
2151
+ if (event.payload) {
2152
+ onEvent({
2153
+ type: EXTERNAL_EVENTS.ACTION_REQUEST,
2154
+ data: event.payload,
2155
+ timestamp: Date.now()
2156
+ });
2157
+ } else {
2158
+ log("AI action request event has no payload!");
2159
+ }
2160
+ });
2161
+ log("AI action request listener registered successfully");
2162
+ } catch (error) {
2163
+ log("Failed to setup AI action request listener:", error);
2164
+ }
2121
2165
  log("Registering file change listener for:", HAEXTENSION_EVENTS.FILE_CHANGED);
2122
2166
  try {
2123
2167
  await listen(HAEXTENSION_EVENTS.FILE_CHANGED, (event) => {
@@ -2437,7 +2481,7 @@ function createMessageHandler(config, pendingRequests, extensionInfo, onEvent) {
2437
2481
  }
2438
2482
  };
2439
2483
  }
2440
- function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest) {
2484
+ function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest, onActionRequest) {
2441
2485
  if (event.type === HAEXTENSION_EVENTS.CONTEXT_CHANGED) {
2442
2486
  const contextEvent = event;
2443
2487
  onContextChanged(contextEvent.data.context);
@@ -2448,6 +2492,13 @@ function processEvent(event, log, eventListeners, onContextChanged, onExternalRe
2448
2492
  onExternalRequest(externalEvent);
2449
2493
  return;
2450
2494
  }
2495
+ if (event.type === EXTERNAL_EVENTS.ACTION_REQUEST) {
2496
+ const actionEvent = event;
2497
+ if (onActionRequest) {
2498
+ onActionRequest(actionEvent);
2499
+ }
2500
+ return;
2501
+ }
2451
2502
  emitEvent(event, log, eventListeners);
2452
2503
  }
2453
2504
  function emitEvent(event, log, eventListeners) {
@@ -2584,6 +2635,12 @@ async function respondToExternalRequest(response, request) {
2584
2635
  await request(EXTERNAL_BRIDGE_COMMANDS.respond, response);
2585
2636
  }
2586
2637
 
2638
+ // src/commands/ai.ts
2639
+ var AI_COMMANDS = {
2640
+ /** Respond to an AI action request */
2641
+ actionRespond: "ai_action_respond"
2642
+ };
2643
+
2587
2644
  // src/client.ts
2588
2645
  var HaexVaultSdk = class {
2589
2646
  constructor(config = {}) {
@@ -2605,6 +2662,12 @@ var HaexVaultSdk = class {
2605
2662
  this.setupHook = null;
2606
2663
  // Public APIs
2607
2664
  this.orm = null;
2665
+ /** Unified action system - register handlers that work for both Bridge and AI requests */
2666
+ this.actions = {
2667
+ register: (action, handler) => {
2668
+ return this.onExternalRequest(action, handler);
2669
+ }
2670
+ };
2608
2671
  this.config = {
2609
2672
  debug: config.debug ?? false,
2610
2673
  timeout: config.timeout ?? DEFAULT_TIMEOUT,
@@ -2894,12 +2957,23 @@ var HaexVaultSdk = class {
2894
2957
  this._context = ctx;
2895
2958
  this.notifySubscribersInternal();
2896
2959
  },
2897
- (extEvent) => this.handleExternalRequestInternal(extEvent.data)
2960
+ (extEvent) => this.handleExternalRequestInternal(extEvent.data),
2961
+ (actionEvent) => this.handleActionRequestInternal(actionEvent.data)
2898
2962
  );
2899
2963
  }
2900
2964
  async handleExternalRequestInternal(request) {
2901
2965
  await handleExternalRequest(request, this.externalRequestHandlers, this.respondToExternalRequest.bind(this), this.log.bind(this));
2902
2966
  }
2967
+ async handleActionRequestInternal(request) {
2968
+ await handleExternalRequest(
2969
+ request,
2970
+ this.externalRequestHandlers,
2971
+ async (response) => {
2972
+ await this.request(AI_COMMANDS.actionRespond, response);
2973
+ },
2974
+ this.log.bind(this)
2975
+ );
2976
+ }
2903
2977
  // ==========================================================================
2904
2978
  // Private: Setup
2905
2979
  // ==========================================================================
@@ -3582,6 +3656,6 @@ function createHaexVaultSdk(config = {}) {
3582
3656
  return new HaexVaultSdk(config);
3583
3657
  }
3584
3658
 
3585
- export { COSE_ALGORITHM, DEFAULT_TIMEOUT, DatabaseAPI, EXTERNAL_EVENTS, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, KEY_AGREEMENT_ALGO, LOCALSEND_EVENTS, LocalSendAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SHELL_EVENTS, SIGNING_ALGO, SPACE_COMMANDS, ShellAPI, SpaceRoles, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, 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, hexToBytes, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, publicKeyToDidKeyAsync, signClaimPresentationAsync, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, sortObjectKeysRecursively, unwrapKey, verifyClaimPresentationAsync, verifyExtensionSignature, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
3659
+ export { COSE_ALGORITHM, DEFAULT_TIMEOUT, DatabaseAPI, EXTERNAL_EVENTS, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, KEY_AGREEMENT_ALGO, KnownPath, LOCALSEND_EVENTS, LocalSendAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SHELL_EVENTS, SIGNING_ALGO, SPACE_COMMANDS, ShellAPI, SpaceRoles, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, 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, hexToBytes, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, publicKeyToDidKeyAsync, signClaimPresentationAsync, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, sortObjectKeysRecursively, unwrapKey, verifyClaimPresentationAsync, verifyExtensionSignature, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
3586
3660
  //# sourceMappingURL=index.mjs.map
3587
3661
  //# sourceMappingURL=index.mjs.map