latinfo 0.17.0 → 0.18.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 (2) hide show
  1. package/dist/index.js +53 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ const local_search_1 = require("./local-search");
47
47
  const client_search_1 = require("./client-search");
48
48
  const odis_search_1 = require("./odis-search");
49
49
  const mphf_search_1 = require("./mphf-search");
50
- const VERSION = '0.17.0';
50
+ const VERSION = '0.18.0';
51
51
  const API_URL = process.env.LATINFO_API_URL || 'https://api.latinfo.dev';
52
52
  const GITHUB_CLIENT_ID = process.env.GITHUB_CLIENT_ID || 'Ov23li5fcQaiCsVtaMKK';
53
53
  const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.latinfo');
@@ -748,6 +748,55 @@ function costsSimulate(usersStr, rpmStr, proPctStr) {
748
748
  printCosts({ users, pro_users: proUsers, requests, cf_tier: cfTier, cf_cost: cfCost, revenue, margin, safe: margin >= 0 });
749
749
  }
750
750
  // --- Bench ---
751
+ // --- Search server status ---
752
+ async function searchServerStatus() {
753
+ const { execSync } = await Promise.resolve().then(() => __importStar(require('child_process')));
754
+ const RUNNER = 'f3mt0@100.109.82.87';
755
+ // Test SSH
756
+ try {
757
+ execSync(`ssh -o ConnectTimeout=5 ${RUNNER} "echo OK"`, { stdio: 'pipe' });
758
+ }
759
+ catch {
760
+ console.error(' Linux Mint not reachable. Is it on?');
761
+ process.exit(1);
762
+ }
763
+ // Check health
764
+ try {
765
+ const health = execSync(`ssh ${RUNNER} "curl -s http://localhost:3001/health"`, { encoding: 'utf-8', stdio: 'pipe' }).trim();
766
+ const data = JSON.parse(health);
767
+ if (data.status === 'ok') {
768
+ console.log(`\n Search server: READY`);
769
+ console.log(` Mode: ${data.mode || 'ram'}`);
770
+ console.log(` Sources: ${data.sources.join(', ')}`);
771
+ console.log(` Disk shards: ${data.diskShards || 0}`);
772
+ console.log(` RAM shards: ${data.ramShards || 0}`);
773
+ console.log(` RAM: ${data.ramMB || '?'} MB`);
774
+ // Quick search test
775
+ const t0 = Date.now();
776
+ const testResult = execSync(`ssh ${RUNNER} "curl -s 'http://localhost:3001/search?source=${data.sources[0]}&q=banco'"`, { encoding: 'utf-8', stdio: 'pipe' }).trim();
777
+ const testData = JSON.parse(testResult);
778
+ console.log(`\n Search test (${data.sources[0]}): ${testData.results?.length || 0} results in ${testData.ms}ms`);
779
+ return;
780
+ }
781
+ }
782
+ catch { }
783
+ // Not ready — show download progress
784
+ console.log(`\n Search server: LOADING\n`);
785
+ const diskUsage = execSync(`ssh ${RUNNER} "du -sm /tmp/latinfo-search-data/ 2>/dev/null | awk '{print \\$1}'"`, { encoding: 'utf-8', stdio: 'pipe' }).trim();
786
+ const currentMB = parseInt(diskUsage) || 0;
787
+ const totalExpected = 6400;
788
+ const pct = Math.min(Math.floor(currentMB / totalExpected * 100), 99);
789
+ const filled = Math.floor(pct * 30 / 100);
790
+ const bar = '█'.repeat(filled) + '░'.repeat(30 - filled);
791
+ console.log(` [${bar}] ${currentMB}/${totalExpected} MB (${pct}%)`);
792
+ // Show last shard activity
793
+ const lastLog = execSync(`ssh ${RUNNER} "sudo journalctl -u latinfo-search --no-pager -n 5 2>/dev/null | grep -oE '(Shard [0-9]+|Loading [^ ]+)' | tail -1"`, { encoding: 'utf-8', stdio: 'pipe' }).trim();
794
+ if (lastLog)
795
+ console.log(` Last: ${lastLog}`);
796
+ // Show RAM
797
+ const ram = execSync(`ssh ${RUNNER} "free -h | awk '/Mem:/{print \\$3\"/\"\\$2}'"`, { encoding: 'utf-8', stdio: 'pipe' }).trim();
798
+ console.log(` RAM: ${ram}`);
799
+ }
751
800
  // Seed queries used to discover real data from the API
752
801
  const SEED_QUERIES = ['banco', 'empresa', 'servicios', 'comercial', 'grupo'];
753
802
  function discoverBenchSources(filterSource) {
@@ -3168,6 +3217,9 @@ else {
3168
3217
  case 'bench':
3169
3218
  bench(args).catch(e => { console.error(e); process.exit(1); });
3170
3219
  break;
3220
+ case 'search-server':
3221
+ searchServerStatus().catch(e => { console.error(e); process.exit(1); });
3222
+ break;
3171
3223
  case 'pipe':
3172
3224
  pipe(args).catch(e => { console.error(e); process.exit(1); });
3173
3225
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latinfo",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Tax registry & procurement API for Latin America. Query RUC, DNI, NIT, licitaciones from Peru & Colombia. Offline MPHF search, full OCDS data, updated daily.",
5
5
  "homepage": "https://latinfo.dev",
6
6
  "repository": {