@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.
@@ -18,6 +18,8 @@ var HAEXTENSION_EVENTS = {
18
18
  var EXTERNAL_EVENTS = {
19
19
  /** External request from authorized client */
20
20
  REQUEST: "haextension:external:request",
21
+ /** AI action request (tool calls from AI assistant) */
22
+ ACTION_REQUEST: "haextension:action:request",
21
23
  /** New external client requesting authorization */
22
24
  AUTHORIZATION_REQUEST: "external:authorization-request"
23
25
  };
@@ -144,6 +146,8 @@ var FILESYSTEM_COMMANDS = {
144
146
  rename: "extension_filesystem_rename",
145
147
  /** Copy file or directory */
146
148
  copy: "extension_filesystem_copy",
149
+ /** Get well-known system directory paths */
150
+ knownPaths: "extension_filesystem_known_paths",
147
151
  // File watcher operations
148
152
  /** Start watching a directory for changes */
149
153
  watch: "extension_filesystem_watch",
@@ -593,6 +597,19 @@ var FilesystemAPI = class {
593
597
  );
594
598
  }
595
599
  // ==========================================================================
600
+ // Known Paths (System Directories)
601
+ // ==========================================================================
602
+ /**
603
+ * Get well-known system directory paths (home, pictures, downloads, etc.)
604
+ * These paths are resolved via Tauri's PathResolver and are platform-aware.
605
+ * @returns Map of known path names to their absolute paths
606
+ */
607
+ async knownPaths() {
608
+ return this.client.request(
609
+ FILESYSTEM_COMMANDS.knownPaths
610
+ );
611
+ }
612
+ // ==========================================================================
596
613
  // File Watcher Operations
597
614
  // ==========================================================================
598
615
  /**
@@ -1457,6 +1474,24 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1457
1474
  } catch (error) {
1458
1475
  log("Failed to setup external request listener:", error);
1459
1476
  }
1477
+ try {
1478
+ await listen(EXTERNAL_EVENTS.ACTION_REQUEST, (event) => {
1479
+ log("====== AI ACTION REQUEST RECEIVED ======");
1480
+ log("Payload:", JSON.stringify(event.payload));
1481
+ if (event.payload) {
1482
+ onEvent({
1483
+ type: EXTERNAL_EVENTS.ACTION_REQUEST,
1484
+ data: event.payload,
1485
+ timestamp: Date.now()
1486
+ });
1487
+ } else {
1488
+ log("AI action request event has no payload!");
1489
+ }
1490
+ });
1491
+ log("AI action request listener registered successfully");
1492
+ } catch (error) {
1493
+ log("Failed to setup AI action request listener:", error);
1494
+ }
1460
1495
  log("Registering file change listener for:", HAEXTENSION_EVENTS.FILE_CHANGED);
1461
1496
  try {
1462
1497
  await listen(HAEXTENSION_EVENTS.FILE_CHANGED, (event) => {
@@ -1776,7 +1811,7 @@ function createMessageHandler(config, pendingRequests, extensionInfo, onEvent) {
1776
1811
  }
1777
1812
  };
1778
1813
  }
1779
- function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest) {
1814
+ function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest, onActionRequest) {
1780
1815
  if (event.type === HAEXTENSION_EVENTS.CONTEXT_CHANGED) {
1781
1816
  const contextEvent = event;
1782
1817
  onContextChanged(contextEvent.data.context);
@@ -1787,6 +1822,13 @@ function processEvent(event, log, eventListeners, onContextChanged, onExternalRe
1787
1822
  onExternalRequest(externalEvent);
1788
1823
  return;
1789
1824
  }
1825
+ if (event.type === EXTERNAL_EVENTS.ACTION_REQUEST) {
1826
+ const actionEvent = event;
1827
+ if (onActionRequest) {
1828
+ onActionRequest(actionEvent);
1829
+ }
1830
+ return;
1831
+ }
1790
1832
  emitEvent(event, log, eventListeners);
1791
1833
  }
1792
1834
  function emitEvent(event, log, eventListeners) {
@@ -1923,6 +1965,12 @@ async function respondToExternalRequest(response, request) {
1923
1965
  await request(EXTERNAL_BRIDGE_COMMANDS.respond, response);
1924
1966
  }
1925
1967
 
1968
+ // src/commands/ai.ts
1969
+ var AI_COMMANDS = {
1970
+ /** Respond to an AI action request */
1971
+ actionRespond: "ai_action_respond"
1972
+ };
1973
+
1926
1974
  // src/client.ts
1927
1975
  var HaexVaultSdk = class {
1928
1976
  constructor(config = {}) {
@@ -1944,6 +1992,12 @@ var HaexVaultSdk = class {
1944
1992
  this.setupHook = null;
1945
1993
  // Public APIs
1946
1994
  this.orm = null;
1995
+ /** Unified action system - register handlers that work for both Bridge and AI requests */
1996
+ this.actions = {
1997
+ register: (action, handler) => {
1998
+ return this.onExternalRequest(action, handler);
1999
+ }
2000
+ };
1947
2001
  this.config = {
1948
2002
  debug: config.debug ?? false,
1949
2003
  timeout: config.timeout ?? DEFAULT_TIMEOUT,
@@ -2233,12 +2287,23 @@ var HaexVaultSdk = class {
2233
2287
  this._context = ctx;
2234
2288
  this.notifySubscribersInternal();
2235
2289
  },
2236
- (extEvent) => this.handleExternalRequestInternal(extEvent.data)
2290
+ (extEvent) => this.handleExternalRequestInternal(extEvent.data),
2291
+ (actionEvent) => this.handleActionRequestInternal(actionEvent.data)
2237
2292
  );
2238
2293
  }
2239
2294
  async handleExternalRequestInternal(request) {
2240
2295
  await handleExternalRequest(request, this.externalRequestHandlers, this.respondToExternalRequest.bind(this), this.log.bind(this));
2241
2296
  }
2297
+ async handleActionRequestInternal(request) {
2298
+ await handleExternalRequest(
2299
+ request,
2300
+ this.externalRequestHandlers,
2301
+ async (response) => {
2302
+ await this.request(AI_COMMANDS.actionRespond, response);
2303
+ },
2304
+ this.log.bind(this)
2305
+ );
2306
+ }
2242
2307
  // ==========================================================================
2243
2308
  // Private: Setup
2244
2309
  // ==========================================================================