@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.
@@ -1,7 +1,7 @@
1
1
  import * as nuxt_app from 'nuxt/app';
2
2
  import { ShallowRef } from 'vue';
3
- import { H as HaexVaultSdk } from '../client-DvH4bGGw.mjs';
4
- import { A as ApplicationContext } from '../types-B1O6KckK.mjs';
3
+ import { H as HaexVaultSdk } from '../client-BUsw25aA.mjs';
4
+ import { A as ApplicationContext } from '../types-DmCSegdY.mjs';
5
5
  import 'drizzle-orm/sqlite-proxy';
6
6
 
7
7
  declare const _default: nuxt_app.Plugin<{
@@ -1,7 +1,7 @@
1
1
  import * as nuxt_app from 'nuxt/app';
2
2
  import { ShallowRef } from 'vue';
3
- import { H as HaexVaultSdk } from '../client-CScVlK1m.js';
4
- import { A as ApplicationContext } from '../types-B1O6KckK.js';
3
+ import { H as HaexVaultSdk } from '../client-3B1iWut9.js';
4
+ import { A as ApplicationContext } from '../types-DmCSegdY.js';
5
5
  import 'drizzle-orm/sqlite-proxy';
6
6
 
7
7
  declare const _default: nuxt_app.Plugin<{
@@ -20,6 +20,8 @@ var HAEXTENSION_EVENTS = {
20
20
  var EXTERNAL_EVENTS = {
21
21
  /** External request from authorized client */
22
22
  REQUEST: "haextension:external:request",
23
+ /** AI action request (tool calls from AI assistant) */
24
+ ACTION_REQUEST: "haextension:action:request",
23
25
  /** New external client requesting authorization */
24
26
  AUTHORIZATION_REQUEST: "external:authorization-request"
25
27
  };
@@ -146,6 +148,8 @@ var FILESYSTEM_COMMANDS = {
146
148
  rename: "extension_filesystem_rename",
147
149
  /** Copy file or directory */
148
150
  copy: "extension_filesystem_copy",
151
+ /** Get well-known system directory paths */
152
+ knownPaths: "extension_filesystem_known_paths",
149
153
  // File watcher operations
150
154
  /** Start watching a directory for changes */
151
155
  watch: "extension_filesystem_watch",
@@ -595,6 +599,19 @@ var FilesystemAPI = class {
595
599
  );
596
600
  }
597
601
  // ==========================================================================
602
+ // Known Paths (System Directories)
603
+ // ==========================================================================
604
+ /**
605
+ * Get well-known system directory paths (home, pictures, downloads, etc.)
606
+ * These paths are resolved via Tauri's PathResolver and are platform-aware.
607
+ * @returns Map of known path names to their absolute paths
608
+ */
609
+ async knownPaths() {
610
+ return this.client.request(
611
+ FILESYSTEM_COMMANDS.knownPaths
612
+ );
613
+ }
614
+ // ==========================================================================
598
615
  // File Watcher Operations
599
616
  // ==========================================================================
600
617
  /**
@@ -1459,6 +1476,24 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1459
1476
  } catch (error) {
1460
1477
  log("Failed to setup external request listener:", error);
1461
1478
  }
1479
+ try {
1480
+ await listen(EXTERNAL_EVENTS.ACTION_REQUEST, (event) => {
1481
+ log("====== AI ACTION REQUEST RECEIVED ======");
1482
+ log("Payload:", JSON.stringify(event.payload));
1483
+ if (event.payload) {
1484
+ onEvent({
1485
+ type: EXTERNAL_EVENTS.ACTION_REQUEST,
1486
+ data: event.payload,
1487
+ timestamp: Date.now()
1488
+ });
1489
+ } else {
1490
+ log("AI action request event has no payload!");
1491
+ }
1492
+ });
1493
+ log("AI action request listener registered successfully");
1494
+ } catch (error) {
1495
+ log("Failed to setup AI action request listener:", error);
1496
+ }
1462
1497
  log("Registering file change listener for:", HAEXTENSION_EVENTS.FILE_CHANGED);
1463
1498
  try {
1464
1499
  await listen(HAEXTENSION_EVENTS.FILE_CHANGED, (event) => {
@@ -1778,7 +1813,7 @@ function createMessageHandler(config, pendingRequests, extensionInfo, onEvent) {
1778
1813
  }
1779
1814
  };
1780
1815
  }
1781
- function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest) {
1816
+ function processEvent(event, log, eventListeners, onContextChanged, onExternalRequest, onActionRequest) {
1782
1817
  if (event.type === HAEXTENSION_EVENTS.CONTEXT_CHANGED) {
1783
1818
  const contextEvent = event;
1784
1819
  onContextChanged(contextEvent.data.context);
@@ -1789,6 +1824,13 @@ function processEvent(event, log, eventListeners, onContextChanged, onExternalRe
1789
1824
  onExternalRequest(externalEvent);
1790
1825
  return;
1791
1826
  }
1827
+ if (event.type === EXTERNAL_EVENTS.ACTION_REQUEST) {
1828
+ const actionEvent = event;
1829
+ if (onActionRequest) {
1830
+ onActionRequest(actionEvent);
1831
+ }
1832
+ return;
1833
+ }
1792
1834
  emitEvent(event, log, eventListeners);
1793
1835
  }
1794
1836
  function emitEvent(event, log, eventListeners) {
@@ -1925,6 +1967,12 @@ async function respondToExternalRequest(response, request) {
1925
1967
  await request(EXTERNAL_BRIDGE_COMMANDS.respond, response);
1926
1968
  }
1927
1969
 
1970
+ // src/commands/ai.ts
1971
+ var AI_COMMANDS = {
1972
+ /** Respond to an AI action request */
1973
+ actionRespond: "ai_action_respond"
1974
+ };
1975
+
1928
1976
  // src/client.ts
1929
1977
  var HaexVaultSdk = class {
1930
1978
  constructor(config = {}) {
@@ -1946,6 +1994,12 @@ var HaexVaultSdk = class {
1946
1994
  this.setupHook = null;
1947
1995
  // Public APIs
1948
1996
  this.orm = null;
1997
+ /** Unified action system - register handlers that work for both Bridge and AI requests */
1998
+ this.actions = {
1999
+ register: (action, handler) => {
2000
+ return this.onExternalRequest(action, handler);
2001
+ }
2002
+ };
1949
2003
  this.config = {
1950
2004
  debug: config.debug ?? false,
1951
2005
  timeout: config.timeout ?? DEFAULT_TIMEOUT,
@@ -2235,12 +2289,23 @@ var HaexVaultSdk = class {
2235
2289
  this._context = ctx;
2236
2290
  this.notifySubscribersInternal();
2237
2291
  },
2238
- (extEvent) => this.handleExternalRequestInternal(extEvent.data)
2292
+ (extEvent) => this.handleExternalRequestInternal(extEvent.data),
2293
+ (actionEvent) => this.handleActionRequestInternal(actionEvent.data)
2239
2294
  );
2240
2295
  }
2241
2296
  async handleExternalRequestInternal(request) {
2242
2297
  await handleExternalRequest(request, this.externalRequestHandlers, this.respondToExternalRequest.bind(this), this.log.bind(this));
2243
2298
  }
2299
+ async handleActionRequestInternal(request) {
2300
+ await handleExternalRequest(
2301
+ request,
2302
+ this.externalRequestHandlers,
2303
+ async (response) => {
2304
+ await this.request(AI_COMMANDS.actionRespond, response);
2305
+ },
2306
+ this.log.bind(this)
2307
+ );
2308
+ }
2244
2309
  // ==========================================================================
2245
2310
  // Private: Setup
2246
2311
  // ==========================================================================