@avalw/search-worker 2.1.1 → 2.2.0

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 (3) hide show
  1. package/bin/cli.js +7 -7
  2. package/index.js +13 -5
  3. package/package.json +2 -2
package/bin/cli.js CHANGED
@@ -54,7 +54,7 @@ for (let i = 0; i < args.length; i++) {
54
54
 
55
55
  function showHelp() {
56
56
  console.log(`
57
- AVALW Search Worker v2.1.0 - Intelligent Distributed Cache
57
+ AVALW Search Worker v2.2.0 - Intelligent Distributed Cache
58
58
 
59
59
  USAGE:
60
60
  npx @avalw/search-worker [options]
@@ -184,14 +184,14 @@ const worker = new SearchWorker({
184
184
  console.log(' [DISCONNECTED] Lost connection to coordinator');
185
185
  },
186
186
 
187
- onCacheHit: (key) => {
188
- const query = key.split(':')[0];
189
- console.log(` [CACHE HIT] Served: "${query.substring(0, 30)}..."`);
187
+ onCacheHit: () => {
188
+ // Privacy: Don't show search queries to workers
189
+ console.log(` [CACHE HIT] Served a cached result`);
190
190
  },
191
191
 
192
- onCacheStore: (key) => {
193
- const query = key.split(':')[0];
194
- console.log(` [CACHED] Stored: "${query.substring(0, 30)}..."`);
192
+ onCacheStore: () => {
193
+ // Privacy: Don't show search queries to workers
194
+ console.log(` [CACHED] Stored a new result`);
195
195
  },
196
196
 
197
197
  onError: (err) => {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @avalw/search-worker v2.1.0
2
+ * @avalw/search-worker v2.2.0
3
3
  * Distributed Cache Worker for AVALW Search Network
4
4
  *
5
5
  * Workers connect to the coordinator via WebSocket and serve as
@@ -596,7 +596,8 @@ class SearchWorker {
596
596
  // Invalidate a cache key
597
597
  if (message.key) {
598
598
  this.cache._evict(message.key, 'invalidate');
599
- this.onLog(`Cache invalidated: ${message.key.substring(0, 30)}...`);
599
+ // Privacy: Don't log the key
600
+ this.onLog(`Cache entry invalidated`);
600
601
  }
601
602
  break;
602
603
 
@@ -637,7 +638,8 @@ class SearchWorker {
637
638
  value
638
639
  });
639
640
 
640
- this.onLog(`Cache HIT: ${key.substring(0, 30)}...`);
641
+ // Privacy: Don't log the search query
642
+ this.onLog(`Cache HIT - served result #${this.stats.cacheHits}`);
641
643
  } else {
642
644
  this.stats.cacheMisses++;
643
645
 
@@ -667,7 +669,8 @@ class SearchWorker {
667
669
  this.onCacheStore(key);
668
670
 
669
671
  const cacheStats = this.cache.getStats();
670
- this.onLog(`Cached: ${key.substring(0, 30)}... (${cacheStats.entries} entries, ${cacheStats.sizeFormatted})`);
672
+ // Privacy: Don't log the search query, only show stats
673
+ this.onLog(`Cached result #${this.stats.cacheStored} (${cacheStats.entries} entries, ${cacheStats.sizeFormatted})`);
671
674
  }
672
675
 
673
676
  // Send cache registry to coordinator
@@ -727,13 +730,18 @@ class SearchWorker {
727
730
 
728
731
  // Send heartbeat to HTTP dashboard
729
732
  _sendHttpHeartbeat(cpuUsage, systemInfo) {
733
+ const cacheStats = this.cache.getStats();
730
734
  const data = JSON.stringify({
731
735
  worker_token: this.workerToken,
732
736
  system_info: {
733
737
  ...systemInfo,
734
738
  cpu_usage: cpuUsage,
735
739
  memory_usage: Math.round((1 - os.freemem() / os.totalmem()) * 100 * 10) / 10,
736
- session_core_hours: this._calculateCoreHours()
740
+ session_core_hours: this._calculateCoreHours(),
741
+ // Cache stats for dashboard
742
+ cache_entries: cacheStats.entries,
743
+ cache_bytes: cacheStats.sizeBytes,
744
+ cache_served: this.stats.requestsServed
737
745
  }
738
746
  });
739
747
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@avalw/search-worker",
3
- "version": "2.1.1",
4
- "description": "AVALW Distributed Cache Worker - Intelligent caching with size limits and auto-cleanup",
3
+ "version": "2.2.0",
4
+ "description": "AVALW Distributed Cache Worker - Privacy-focused intelligent caching",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "avalw-worker": "./bin/cli.js"