@digitalforgestudios/openclaw-sulcus 3.5.1 → 3.5.3

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.
Files changed (2) hide show
  1. package/index.ts +47 -52
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -741,82 +741,77 @@ const sulcusPlugin = {
741
741
 
742
742
  register(api: any) {
743
743
  // ── Configuration ──
744
- const libDir = api.config?.libDir
745
- ? resolve(api.config.libDir)
744
+ const libDir = api.pluginConfig?.libDir
745
+ ? resolve(api.pluginConfig.libDir)
746
746
  : resolve(process.env.HOME || "~", ".sulcus/lib");
747
747
 
748
- const storeLibPath = api.config?.storeLibPath
749
- ? resolve(api.config.storeLibPath)
748
+ const storeLibPath = api.pluginConfig?.storeLibPath
749
+ ? resolve(api.pluginConfig.storeLibPath)
750
750
  : resolve(libDir, process.platform === "darwin" ? "libsulcus_store.dylib" : "libsulcus_store.so");
751
751
 
752
- const vectorsLibPath = api.config?.vectorsLibPath
753
- ? resolve(api.config.vectorsLibPath)
752
+ const vectorsLibPath = api.pluginConfig?.vectorsLibPath
753
+ ? resolve(api.pluginConfig.vectorsLibPath)
754
754
  : resolve(libDir, process.platform === "darwin" ? "libsulcus_vectors.dylib" : "libsulcus_vectors.so");
755
755
 
756
- const wasmDir = api.config?.wasmDir
757
- ? resolve(api.config.wasmDir)
756
+ const wasmDir = api.pluginConfig?.wasmDir
757
+ ? resolve(api.pluginConfig.wasmDir)
758
758
  : resolve(__dirname, "wasm");
759
759
 
760
760
  // Cloud fallback credentials (used when local libs unavailable)
761
- const serverUrl: string | undefined = api.config?.serverUrl;
762
- const apiKey: string | undefined = api.config?.apiKey;
761
+ const serverUrl: string | undefined = api.pluginConfig?.serverUrl;
762
+ const apiKey: string | undefined = api.pluginConfig?.apiKey;
763
763
 
764
764
  // Default namespace = agent name (prevents everything landing in "default")
765
- const agentId = api.config?.agentId || api.pluginConfig?.agentId;
766
- const namespace = api.config?.namespace === "default" && agentId
765
+ const agentId = api.pluginConfig?.agentId;
766
+ const namespace = api.pluginConfig?.namespace === "default" && agentId
767
767
  ? agentId
768
- : (api.config?.namespace || agentId || "default");
768
+ : (api.pluginConfig?.namespace || agentId || "default");
769
769
 
770
770
  // ── Load hooks config (config-driven dispatch) ──
771
- const hooksConfig = loadHooksConfig(api.config);
771
+ const hooksConfig = loadHooksConfig(api.pluginConfig);
772
772
 
773
- // ── Load native dylibs ──
774
- const nativeLoader = new NativeLibLoader(storeLibPath, vectorsLibPath);
775
- nativeLoader.init(api.logger);
776
-
777
- // ── Load WASM module ──
773
+ // ── Backend init: cloud-first, then local ──
778
774
  let sulcusMem: any = null;
779
775
  let backendMode = "unavailable";
776
+ const nativeLoader = new NativeLibLoader(storeLibPath, vectorsLibPath);
780
777
 
781
- if (nativeLoader.loaded) {
782
- const wasmJsPath = resolve(wasmDir, "sulcus_wasm.js");
783
- if (existsSync(wasmJsPath)) {
784
- try {
785
- const { SulcusMem, on_init } = require(wasmJsPath);
786
- // on_init sets up WASM internals (panic hooks etc.)
787
- if (typeof on_init === "function") on_init();
788
-
789
- const queryFn = nativeLoader.makeQueryFn();
790
- const embedFn = nativeLoader.makeEmbedFn();
791
- sulcusMem = SulcusMem.create(queryFn, embedFn);
792
- backendMode = "wasm";
793
- api.logger.info(`sulcus: SulcusMem created via WASM (wasm: ${wasmJsPath})`);
794
- } catch (e: any) {
795
- api.logger.warn(`sulcus: WASM load failed: ${e.message}`);
796
- backendMode = "unavailable";
797
- }
798
- } else {
799
- api.logger.warn(`sulcus: WASM module not found at ${wasmJsPath}`);
778
+ // Priority 1: Cloud mode — if serverUrl + apiKey are configured, use HTTP.
779
+ // No local dylibs needed. This is the path for cloud-only users.
780
+ if (serverUrl && apiKey) {
781
+ try {
782
+ const cloudClient = new SulcusCloudClient(serverUrl, apiKey);
783
+ sulcusMem = cloudClient;
784
+ backendMode = "cloud";
785
+ api.logger.info(`sulcus: using cloud backend (server: ${serverUrl})`);
786
+ } catch (e: any) {
787
+ api.logger.warn(`sulcus: cloud client init failed: ${e.message}`);
800
788
  }
801
- } else {
802
- api.logger.warn(`sulcus: native libs unavailable — ${nativeLoader.error}`);
803
789
  }
804
790
 
805
- // ── Cloud HTTP fallback ──
806
- // Activates only when local WASM/native libs are unavailable AND
807
- // serverUrl + apiKey are configured. Zero external dependencies.
791
+ // Priority 2: Local WASM+native — if cloud isn't configured or failed,
792
+ // try loading native dylibs + WASM module for fully local operation.
808
793
  if (sulcusMem === null) {
809
- if (serverUrl && apiKey) {
810
- try {
811
- const cloudClient = new SulcusCloudClient(serverUrl, apiKey);
812
- sulcusMem = cloudClient;
813
- backendMode = "cloud";
814
- api.logger.info(`sulcus: using cloud backend (server: ${serverUrl})`);
815
- } catch (e: any) {
816
- api.logger.warn(`sulcus: cloud client init failed: ${e.message}`);
794
+ nativeLoader.init(api.logger);
795
+ if (nativeLoader.loaded) {
796
+ const wasmJsPath = resolve(wasmDir, "sulcus_wasm.js");
797
+ if (existsSync(wasmJsPath)) {
798
+ try {
799
+ const { SulcusMem, on_init } = require(wasmJsPath);
800
+ if (typeof on_init === "function") on_init();
801
+
802
+ const queryFn = nativeLoader.makeQueryFn();
803
+ const embedFn = nativeLoader.makeEmbedFn();
804
+ sulcusMem = SulcusMem.create(queryFn, embedFn);
805
+ backendMode = "wasm";
806
+ api.logger.info(`sulcus: SulcusMem created via WASM (wasm: ${wasmJsPath})`);
807
+ } catch (e: any) {
808
+ api.logger.warn(`sulcus: WASM load failed: ${e.message}`);
809
+ }
810
+ } else {
811
+ api.logger.warn(`sulcus: WASM module not found at ${wasmJsPath}`);
817
812
  }
818
813
  } else {
819
- api.logger.info(`sulcus: no cloud fallbackserverUrl: ${serverUrl ? "set" : "missing"}, apiKey: ${apiKey ? "set" : "missing"}`);
814
+ api.logger.info(`sulcus: local mode skipped — ${nativeLoader.error || "dylibs not found"}`);
820
815
  }
821
816
  }
822
817
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalforgestudios/openclaw-sulcus",
3
- "version": "3.5.1",
3
+ "version": "3.5.3",
4
4
  "description": "Sulcus — reactive, thermodynamic memory plugin for OpenClaw. Opt-in persistent memory with heat-based decay, semantic search, and cross-agent sync. Auto-recall and auto-capture disabled by default.",
5
5
  "keywords": [
6
6
  "openclaw",