@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/react.mjs CHANGED
@@ -384,6 +384,8 @@ var HAEXTENSION_EVENTS = {
384
384
  var EXTERNAL_EVENTS = {
385
385
  /** External request from authorized client */
386
386
  REQUEST: "haextension:external:request",
387
+ /** AI action request (tool calls from AI assistant) */
388
+ ACTION_REQUEST: "haextension:action:request",
387
389
  /** New external client requesting authorization */
388
390
  AUTHORIZATION_REQUEST: "external:authorization-request"
389
391
  };
@@ -510,6 +512,8 @@ var FILESYSTEM_COMMANDS = {
510
512
  rename: "extension_filesystem_rename",
511
513
  /** Copy file or directory */
512
514
  copy: "extension_filesystem_copy",
515
+ /** Get well-known system directory paths */
516
+ knownPaths: "extension_filesystem_known_paths",
513
517
  // File watcher operations
514
518
  /** Start watching a directory for changes */
515
519
  watch: "extension_filesystem_watch",
@@ -933,6 +937,19 @@ var FilesystemAPI = class {
933
937
  );
934
938
  }
935
939
  // ==========================================================================
940
+ // Known Paths (System Directories)
941
+ // ==========================================================================
942
+ /**
943
+ * Get well-known system directory paths (home, pictures, downloads, etc.)
944
+ * These paths are resolved via Tauri's PathResolver and are platform-aware.
945
+ * @returns Map of known path names to their absolute paths
946
+ */
947
+ async knownPaths() {
948
+ return this.client.request(
949
+ FILESYSTEM_COMMANDS.knownPaths
950
+ );
951
+ }
952
+ // ==========================================================================
936
953
  // File Watcher Operations
937
954
  // ==========================================================================
938
955
  /**
@@ -1724,6 +1741,24 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1724
1741
  } catch (error) {
1725
1742
  log("Failed to setup external request listener:", error);
1726
1743
  }
1744
+ try {
1745
+ await listen(EXTERNAL_EVENTS.ACTION_REQUEST, (event) => {
1746
+ log("====== AI ACTION REQUEST RECEIVED ======");
1747
+ log("Payload:", JSON.stringify(event.payload));
1748
+ if (event.payload) {
1749
+ onEvent({
1750
+ type: EXTERNAL_EVENTS.ACTION_REQUEST,
1751
+ data: event.payload,
1752
+ timestamp: Date.now()
1753
+ });
1754
+ } else {
1755
+ log("AI action request event has no payload!");
1756
+ }
1757
+ });
1758
+ log("AI action request listener registered successfully");
1759
+ } catch (error) {
1760
+ log("Failed to setup AI action request listener:", error);
1761
+ }
1727
1762
  log("Registering file change listener for:", HAEXTENSION_EVENTS.FILE_CHANGED);
1728
1763
  try {
1729
1764
  await listen(HAEXTENSION_EVENTS.FILE_CHANGED, (event) => {
@@ -2043,7 +2078,7 @@ function createMessageHandler(config, pendingRequests, extensionInfo, onEvent) {
2043
2078
  }
2044
2079
  };
2045
2080
  }
2046
- function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest) {
2081
+ function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest, onActionRequest) {
2047
2082
  if (event.type === HAEXTENSION_EVENTS.CONTEXT_CHANGED) {
2048
2083
  const contextEvent = event;
2049
2084
  onContextChanged(contextEvent.data.context);
@@ -2054,6 +2089,13 @@ function processEvent(event, log, eventListeners, onContextChanged, onExternalRe
2054
2089
  onExternalRequest(externalEvent);
2055
2090
  return;
2056
2091
  }
2092
+ if (event.type === EXTERNAL_EVENTS.ACTION_REQUEST) {
2093
+ const actionEvent = event;
2094
+ if (onActionRequest) {
2095
+ onActionRequest(actionEvent);
2096
+ }
2097
+ return;
2098
+ }
2057
2099
  emitEvent(event, log, eventListeners);
2058
2100
  }
2059
2101
  function emitEvent(event, log, eventListeners) {
@@ -2190,6 +2232,12 @@ async function respondToExternalRequest(response, request) {
2190
2232
  await request(EXTERNAL_BRIDGE_COMMANDS.respond, response);
2191
2233
  }
2192
2234
 
2235
+ // src/commands/ai.ts
2236
+ var AI_COMMANDS = {
2237
+ /** Respond to an AI action request */
2238
+ actionRespond: "ai_action_respond"
2239
+ };
2240
+
2193
2241
  // src/client.ts
2194
2242
  var HaexVaultSdk = class {
2195
2243
  constructor(config = {}) {
@@ -2211,6 +2259,12 @@ var HaexVaultSdk = class {
2211
2259
  this.setupHook = null;
2212
2260
  // Public APIs
2213
2261
  this.orm = null;
2262
+ /** Unified action system - register handlers that work for both Bridge and AI requests */
2263
+ this.actions = {
2264
+ register: (action, handler) => {
2265
+ return this.onExternalRequest(action, handler);
2266
+ }
2267
+ };
2214
2268
  this.config = {
2215
2269
  debug: config.debug ?? false,
2216
2270
  timeout: config.timeout ?? DEFAULT_TIMEOUT,
@@ -2500,12 +2554,23 @@ var HaexVaultSdk = class {
2500
2554
  this._context = ctx;
2501
2555
  this.notifySubscribersInternal();
2502
2556
  },
2503
- (extEvent) => this.handleExternalRequestInternal(extEvent.data)
2557
+ (extEvent) => this.handleExternalRequestInternal(extEvent.data),
2558
+ (actionEvent) => this.handleActionRequestInternal(actionEvent.data)
2504
2559
  );
2505
2560
  }
2506
2561
  async handleExternalRequestInternal(request) {
2507
2562
  await handleExternalRequest(request, this.externalRequestHandlers, this.respondToExternalRequest.bind(this), this.log.bind(this));
2508
2563
  }
2564
+ async handleActionRequestInternal(request) {
2565
+ await handleExternalRequest(
2566
+ request,
2567
+ this.externalRequestHandlers,
2568
+ async (response) => {
2569
+ await this.request(AI_COMMANDS.actionRespond, response);
2570
+ },
2571
+ this.log.bind(this)
2572
+ );
2573
+ }
2509
2574
  // ==========================================================================
2510
2575
  // Private: Setup
2511
2576
  // ==========================================================================