fss-link 1.0.6 → 1.0.9

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/bundle/fss-link.js +207 -106
  2. package/package.json +3 -3
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- #!/usr/bin/env node
3
2
 
4
3
  // packages/cli/src/gemini.tsx
5
4
  import React28 from "react";
@@ -6099,7 +6098,7 @@ async function cleanupCheckpoints() {
6099
6098
  import { AuthType } from "@fsscoding/fss-link-core";
6100
6099
 
6101
6100
  // packages/cli/src/config/database.ts
6102
- import Database from "better-sqlite3";
6101
+ import initSqlJs from "sql.js";
6103
6102
  import * as path5 from "path";
6104
6103
  import * as fs6 from "fs";
6105
6104
 
@@ -6468,21 +6467,52 @@ function saveSettings(settingsFile) {
6468
6467
 
6469
6468
  // packages/cli/src/config/database.ts
6470
6469
  var FSSLinkDatabase = class {
6471
- db;
6470
+ db = null;
6472
6471
  dbPath;
6472
+ SQL;
6473
+ initialized = false;
6473
6474
  constructor() {
6474
6475
  if (!fs6.existsSync(USER_SETTINGS_DIR)) {
6475
6476
  fs6.mkdirSync(USER_SETTINGS_DIR, { recursive: true });
6476
6477
  }
6477
6478
  this.dbPath = path5.join(USER_SETTINGS_DIR, "fss-link.db");
6478
- this.db = new Database(this.dbPath);
6479
- this.db.pragma("journal_mode = WAL");
6479
+ }
6480
+ /**
6481
+ * Initialize the database - must be called before any operations
6482
+ */
6483
+ async initialize() {
6484
+ if (this.initialized) return;
6485
+ this.SQL = await initSqlJs();
6486
+ if (fs6.existsSync(this.dbPath)) {
6487
+ const data = fs6.readFileSync(this.dbPath);
6488
+ this.db = new this.SQL.Database(data);
6489
+ } else {
6490
+ this.db = new this.SQL.Database();
6491
+ }
6480
6492
  this.initializeSchema();
6493
+ this.initialized = true;
6494
+ }
6495
+ /**
6496
+ * Ensure database is initialized
6497
+ */
6498
+ async ensureInitialized() {
6499
+ if (!this.initialized) {
6500
+ await this.initialize();
6501
+ }
6502
+ }
6503
+ /**
6504
+ * Save database to disk
6505
+ */
6506
+ save() {
6507
+ if (!this.db) return;
6508
+ const data = this.db.export();
6509
+ fs6.writeFileSync(this.dbPath, Buffer.from(data));
6481
6510
  }
6482
6511
  /**
6483
6512
  * Initialize database schema
6484
6513
  */
6485
6514
  initializeSchema() {
6515
+ if (!this.db) return;
6486
6516
  this.db.exec(`
6487
6517
  CREATE TABLE IF NOT EXISTS model_configs (
6488
6518
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -6511,11 +6541,14 @@ var FSSLinkDatabase = class {
6511
6541
  CREATE INDEX IF NOT EXISTS idx_model_configs_last_used ON model_configs(last_used DESC);
6512
6542
  CREATE INDEX IF NOT EXISTS idx_model_configs_auth_type ON model_configs(auth_type);
6513
6543
  `);
6544
+ this.save();
6514
6545
  }
6515
6546
  /**
6516
6547
  * Get the currently active model configuration
6517
6548
  */
6518
- getActiveModel() {
6549
+ async getActiveModel() {
6550
+ await this.ensureInitialized();
6551
+ if (!this.db) return null;
6519
6552
  const stmt = this.db.prepare(`
6520
6553
  SELECT id, auth_type, model_name, endpoint_url, api_key, display_name,
6521
6554
  is_favorite, is_active, last_used, created_at
@@ -6523,32 +6556,35 @@ var FSSLinkDatabase = class {
6523
6556
  WHERE is_active = 1
6524
6557
  LIMIT 1
6525
6558
  `);
6526
- const result = stmt.get();
6527
- return result ? this.mapRowToModelConfig(result) : null;
6559
+ const result = stmt.getAsObject({});
6560
+ return result && Object.keys(result).length > 0 ? this.mapRowToModelConfig(result) : null;
6528
6561
  }
6529
6562
  /**
6530
6563
  * Set a model as active (and deactivate all others)
6531
6564
  */
6532
- setActiveModel(id) {
6533
- this.db.transaction(() => {
6534
- this.db.prepare("UPDATE model_configs SET is_active = 0").run();
6535
- this.db.prepare(`
6536
- UPDATE model_configs
6537
- SET is_active = 1, last_used = CURRENT_TIMESTAMP
6538
- WHERE id = ?
6539
- `).run(id);
6540
- })();
6565
+ async setActiveModel(id) {
6566
+ await this.ensureInitialized();
6567
+ if (!this.db) return;
6568
+ this.db.run("UPDATE model_configs SET is_active = 0");
6569
+ this.db.run(`
6570
+ UPDATE model_configs
6571
+ SET is_active = 1, last_used = CURRENT_TIMESTAMP
6572
+ WHERE id = ?
6573
+ `, [id]);
6574
+ this.save();
6541
6575
  }
6542
6576
  /**
6543
6577
  * Add or update a model configuration
6544
6578
  */
6545
- upsertModelConfig(config) {
6579
+ async upsertModelConfig(config) {
6580
+ await this.ensureInitialized();
6581
+ if (!this.db) return -1;
6546
6582
  const stmt = this.db.prepare(`
6547
6583
  INSERT OR REPLACE INTO model_configs
6548
6584
  (auth_type, model_name, endpoint_url, api_key, display_name, is_favorite, is_active, last_used)
6549
6585
  VALUES (?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
6550
6586
  `);
6551
- const result = stmt.run(
6587
+ stmt.run([
6552
6588
  config.authType,
6553
6589
  config.modelName,
6554
6590
  config.endpointUrl || null,
@@ -6556,25 +6592,35 @@ var FSSLinkDatabase = class {
6556
6592
  config.displayName || null,
6557
6593
  config.isFavorite ? 1 : 0,
6558
6594
  config.isActive ? 1 : 0
6559
- );
6560
- return result.lastInsertRowid;
6595
+ ]);
6596
+ this.save();
6597
+ const result = this.db.exec("SELECT last_insert_rowid() as id");
6598
+ return result[0]?.values[0]?.[0] || -1;
6561
6599
  }
6562
6600
  /**
6563
6601
  * Get all model configurations
6564
6602
  */
6565
- getAllModels() {
6603
+ async getAllModels() {
6604
+ await this.ensureInitialized();
6605
+ if (!this.db) return [];
6566
6606
  const stmt = this.db.prepare(`
6567
6607
  SELECT id, auth_type, model_name, endpoint_url, api_key, display_name,
6568
6608
  is_favorite, is_active, last_used, created_at
6569
6609
  FROM model_configs
6570
6610
  ORDER BY is_favorite DESC, last_used DESC, created_at DESC
6571
6611
  `);
6572
- return stmt.all().map((row) => this.mapRowToModelConfig(row));
6612
+ const results = [];
6613
+ while (stmt.step()) {
6614
+ results.push(this.mapRowToModelConfig(stmt.getAsObject()));
6615
+ }
6616
+ return results;
6573
6617
  }
6574
6618
  /**
6575
6619
  * Get favorite models
6576
6620
  */
6577
- getFavoriteModels() {
6621
+ async getFavoriteModels() {
6622
+ await this.ensureInitialized();
6623
+ if (!this.db) return [];
6578
6624
  const stmt = this.db.prepare(`
6579
6625
  SELECT id, auth_type, model_name, endpoint_url, api_key, display_name,
6580
6626
  is_favorite, is_active, last_used, created_at
@@ -6582,12 +6628,18 @@ var FSSLinkDatabase = class {
6582
6628
  WHERE is_favorite = 1
6583
6629
  ORDER BY last_used DESC, created_at DESC
6584
6630
  `);
6585
- return stmt.all().map((row) => this.mapRowToModelConfig(row));
6631
+ const results = [];
6632
+ while (stmt.step()) {
6633
+ results.push(this.mapRowToModelConfig(stmt.getAsObject()));
6634
+ }
6635
+ return results;
6586
6636
  }
6587
6637
  /**
6588
6638
  * Get recently used models
6589
6639
  */
6590
- getRecentModels(limit = 10) {
6640
+ async getRecentModels(limit = 10) {
6641
+ await this.ensureInitialized();
6642
+ if (!this.db) return [];
6591
6643
  const stmt = this.db.prepare(`
6592
6644
  SELECT id, auth_type, model_name, endpoint_url, api_key, display_name,
6593
6645
  is_favorite, is_active, last_used, created_at
@@ -6595,48 +6647,70 @@ var FSSLinkDatabase = class {
6595
6647
  WHERE last_used IS NOT NULL
6596
6648
  ORDER BY last_used DESC
6597
6649
  LIMIT ?
6598
- `);
6599
- return stmt.all(limit).map((row) => this.mapRowToModelConfig(row));
6650
+ `, [limit]);
6651
+ const results = [];
6652
+ while (stmt.step()) {
6653
+ results.push(this.mapRowToModelConfig(stmt.getAsObject()));
6654
+ }
6655
+ return results;
6600
6656
  }
6601
6657
  /**
6602
6658
  * Toggle favorite status for a model
6603
6659
  */
6604
- toggleModelFavorite(id) {
6605
- this.db.prepare(`
6660
+ async toggleModelFavorite(id) {
6661
+ await this.ensureInitialized();
6662
+ if (!this.db) return;
6663
+ this.db.run(`
6606
6664
  UPDATE model_configs
6607
6665
  SET is_favorite = CASE WHEN is_favorite = 1 THEN 0 ELSE 1 END
6608
6666
  WHERE id = ?
6609
- `).run(id);
6667
+ `, [id]);
6668
+ this.save();
6610
6669
  }
6611
6670
  /**
6612
6671
  * Delete a model configuration
6613
6672
  */
6614
- deleteModel(id) {
6615
- this.db.prepare("DELETE FROM model_configs WHERE id = ?").run(id);
6673
+ async deleteModel(id) {
6674
+ await this.ensureInitialized();
6675
+ if (!this.db) return;
6676
+ this.db.run("DELETE FROM model_configs WHERE id = ?", [id]);
6677
+ this.save();
6616
6678
  }
6617
6679
  /**
6618
6680
  * Set user preference
6619
6681
  */
6620
- setUserPreference(key, value) {
6621
- this.db.prepare(`
6682
+ async setUserPreference(key, value) {
6683
+ await this.ensureInitialized();
6684
+ if (!this.db) return;
6685
+ this.db.run(`
6622
6686
  INSERT OR REPLACE INTO user_preferences (key, value, updated_at)
6623
6687
  VALUES (?, ?, CURRENT_TIMESTAMP)
6624
- `).run(key, value);
6688
+ `, [key, value]);
6689
+ this.save();
6625
6690
  }
6626
6691
  /**
6627
6692
  * Get user preference
6628
6693
  */
6629
- getUserPreference(key) {
6630
- const result = this.db.prepare("SELECT value FROM user_preferences WHERE key = ?").get(key);
6631
- return result ? result.value : null;
6694
+ async getUserPreference(key) {
6695
+ await this.ensureInitialized();
6696
+ if (!this.db) return null;
6697
+ const stmt = this.db.prepare("SELECT value FROM user_preferences WHERE key = ?", [key]);
6698
+ if (stmt.step()) {
6699
+ const result = stmt.getAsObject();
6700
+ return result.value || null;
6701
+ }
6702
+ return null;
6632
6703
  }
6633
6704
  /**
6634
6705
  * Get all user preferences
6635
6706
  */
6636
- getAllUserPreferences() {
6637
- const rows = this.db.prepare("SELECT key, value FROM user_preferences").all();
6707
+ async getAllUserPreferences() {
6708
+ await this.ensureInitialized();
6709
+ if (!this.db) return {};
6710
+ const stmt = this.db.prepare("SELECT key, value FROM user_preferences");
6638
6711
  const prefs = {};
6639
- for (const row of rows) {
6712
+ while (stmt.step()) {
6713
+ const row = stmt.getAsObject();
6640
6714
  prefs[row.key] = row.value;
6641
6715
  }
6642
6716
  return prefs;
@@ -6645,7 +6719,12 @@ var FSSLinkDatabase = class {
6645
6719
  * Close database connection
6646
6720
  */
6647
6721
  close() {
6648
- this.db.close();
6722
+ if (this.db) {
6723
+ this.save();
6724
+ this.db.close();
6725
+ this.db = null;
6726
+ this.initialized = false;
6727
+ }
6649
6728
  }
6650
6729
  /**
6651
6730
  * Get database file path (for debugging)
@@ -6672,23 +6751,27 @@ var FSSLinkDatabase = class {
6672
6751
  }
6673
6752
  };
6674
6753
  var databaseInstance = null;
6675
- function getFSSLinkDatabase() {
6754
+ async function getFSSLinkDatabase() {
6676
6755
  if (!databaseInstance) {
6677
6756
  databaseInstance = new FSSLinkDatabase();
6757
+ await databaseInstance.initialize();
6678
6758
  }
6679
6759
  return databaseInstance;
6680
6760
  }
6681
6761
 
6682
6762
  // packages/cli/src/config/modelManager.ts
6683
6763
  var ModelManager = class {
6684
- db = getFSSLinkDatabase();
6764
+ async getDb() {
6765
+ return await getFSSLinkDatabase();
6766
+ }
6685
6767
  /**
6686
6768
  * Set up a new model configuration and make it active
6687
6769
  * Implements ModelStateProvider.setActiveModel
6688
6770
  */
6689
6771
  async setActiveModel(config) {
6690
- const modelId = this.db.upsertModelConfig(config);
6691
- this.db.setActiveModel(modelId);
6772
+ const db = await this.getDb();
6773
+ const modelId = await db.upsertModelConfig(config);
6774
+ await db.setActiveModel(modelId);
6692
6775
  this.updateEnvironmentFromModel(config);
6693
6776
  return modelId;
6694
6777
  }
@@ -6696,6 +6779,7 @@ var ModelManager = class {
6696
6779
  * Set up a new model configuration and make it active (legacy method)
6697
6780
  */
6698
6781
  async configureModel(authType, modelName, endpointUrl, apiKey, displayName) {
6782
+ const db = await this.getDb();
6699
6783
  const config = {
6700
6784
  authType: this.mapAuthType(authType),
6701
6785
  modelName,
@@ -6706,8 +6790,8 @@ var ModelManager = class {
6706
6790
  isActive: true
6707
6791
  // Make this the active model
6708
6792
  };
6709
- const modelId = this.db.upsertModelConfig(config);
6710
- this.db.setActiveModel(modelId);
6793
+ const modelId = await db.upsertModelConfig(config);
6794
+ await db.setActiveModel(modelId);
6711
6795
  this.updateEnvironmentFromModel(config);
6712
6796
  return modelId;
6713
6797
  }
@@ -6716,8 +6800,9 @@ var ModelManager = class {
6716
6800
  */
6717
6801
  async switchToModel(modelId) {
6718
6802
  try {
6719
- this.db.setActiveModel(modelId);
6720
- const activeModel = this.db.getActiveModel();
6803
+ const db = await this.getDb();
6804
+ await db.setActiveModel(modelId);
6805
+ const activeModel = await db.getActiveModel();
6721
6806
  if (activeModel) {
6722
6807
  this.updateEnvironmentFromModel(activeModel);
6723
6808
  return true;
@@ -6731,45 +6816,52 @@ var ModelManager = class {
6731
6816
  /**
6732
6817
  * Get the currently active model
6733
6818
  */
6734
- getActiveModel() {
6735
- return this.db.getActiveModel();
6819
+ async getActiveModel() {
6820
+ const db = await this.getDb();
6821
+ return await db.getActiveModel();
6736
6822
  }
6737
6823
  /**
6738
6824
  * Get all configured models
6739
6825
  */
6740
- getAllModels() {
6741
- return this.db.getAllModels();
6826
+ async getAllModels() {
6827
+ const db = await this.getDb();
6828
+ return await db.getAllModels();
6742
6829
  }
6743
6830
  /**
6744
6831
  * Get favorite models
6745
6832
  */
6746
- getFavoriteModels() {
6747
- return this.db.getFavoriteModels();
6833
+ async getFavoriteModels() {
6834
+ const db = await this.getDb();
6835
+ return await db.getFavoriteModels();
6748
6836
  }
6749
6837
  /**
6750
6838
  * Get recently used models
6751
6839
  */
6752
- getRecentModels(limit = 5) {
6753
- return this.db.getRecentModels(limit);
6840
+ async getRecentModels(limit = 5) {
6841
+ const db = await this.getDb();
6842
+ return await db.getRecentModels(limit);
6754
6843
  }
6755
6844
  /**
6756
6845
  * Toggle favorite status for a model
6757
6846
  */
6758
- toggleFavorite(modelId) {
6759
- this.db.toggleModelFavorite(modelId);
6847
+ async toggleFavorite(modelId) {
6848
+ const db = await this.getDb();
6849
+ await db.toggleModelFavorite(modelId);
6760
6850
  }
6761
6851
  /**
6762
6852
  * Delete a model configuration
6763
6853
  */
6764
- deleteModel(modelId) {
6765
- this.db.deleteModel(modelId);
6854
+ async deleteModel(modelId) {
6855
+ const db = await this.getDb();
6856
+ await db.deleteModel(modelId);
6766
6857
  }
6767
6858
  /**
6768
6859
  * Initialize environment variables from active model on startup
6769
6860
  * Implements ModelStateProvider.initializeFromStore
6770
6861
  */
6771
- initializeFromStore() {
6772
- const activeModel = this.db.getActiveModel();
6862
+ async initializeFromStore() {
6863
+ const db = await this.getDb();
6864
+ const activeModel = await db.getActiveModel();
6773
6865
  if (activeModel) {
6774
6866
  this.updateEnvironmentFromModel(activeModel);
6775
6867
  return true;
@@ -6779,16 +6871,18 @@ var ModelManager = class {
6779
6871
  /**
6780
6872
  * Check if we have a valid active model configuration
6781
6873
  */
6782
- hasValidConfiguration() {
6783
- const activeModel = this.db.getActiveModel();
6874
+ async hasValidConfiguration() {
6875
+ const db = await this.getDb();
6876
+ const activeModel = await db.getActiveModel();
6784
6877
  return activeModel !== null;
6785
6878
  }
6786
6879
  /**
6787
6880
  * Get current auth type from active model
6788
6881
  * Implements ModelStateProvider.getCurrentAuthType
6789
6882
  */
6790
- getCurrentAuthType() {
6791
- const activeModel = this.db.getActiveModel();
6883
+ async getCurrentAuthType() {
6884
+ const db = await this.getDb();
6885
+ const activeModel = await db.getActiveModel();
6792
6886
  if (!activeModel) return void 0;
6793
6887
  const authType = this.mapToFSSLinkAuthType(activeModel.authType);
6794
6888
  return authType;
@@ -6796,8 +6890,9 @@ var ModelManager = class {
6796
6890
  /**
6797
6891
  * Get current auth type as FSS Link AuthType enum (legacy method)
6798
6892
  */
6799
- getCurrentFSSAuthType() {
6800
- const activeModel = this.db.getActiveModel();
6893
+ async getCurrentFSSAuthType() {
6894
+ const db = await this.getDb();
6895
+ const activeModel = await db.getActiveModel();
6801
6896
  if (!activeModel) return void 0;
6802
6897
  return this.mapToFSSLinkAuthType(activeModel.authType);
6803
6898
  }
@@ -7584,7 +7679,7 @@ async function getPackageJson() {
7584
7679
  // packages/cli/src/utils/version.ts
7585
7680
  async function getCliVersion() {
7586
7681
  const pkgJson = await getPackageJson();
7587
- return "1.0.6";
7682
+ return "1.0.9";
7588
7683
  }
7589
7684
 
7590
7685
  // packages/cli/src/ui/commands/aboutCommand.ts
@@ -7636,7 +7731,7 @@ import open from "open";
7636
7731
  import process6 from "node:process";
7637
7732
 
7638
7733
  // packages/cli/src/generated/git-commit.ts
7639
- var GIT_COMMIT_INFO = "1134d1d";
7734
+ var GIT_COMMIT_INFO = "0373c69";
7640
7735
 
7641
7736
  // packages/cli/src/ui/commands/bugCommand.ts
7642
7737
  import { sessionId as sessionId3 } from "@fsscoding/fss-link-core";
@@ -18355,16 +18450,19 @@ function SearchEngineConfigDialog({
18355
18450
  const [currentField, setCurrentField] = useState33("braveApiKey");
18356
18451
  const [isLoading, setIsLoading] = useState33(true);
18357
18452
  useEffect32(() => {
18358
- const db = getFSSLinkDatabase();
18359
- const existingBrave = db.getUserPreference("webscraper.brave_api_key");
18360
- const existingTavily = db.getUserPreference("webscraper.tavily_api_key");
18361
- if (existingBrave) {
18362
- setBraveApiKey(existingBrave);
18363
- }
18364
- if (existingTavily) {
18365
- setTavilyApiKey(existingTavily);
18366
- }
18367
- setIsLoading(false);
18453
+ const loadConfig = async () => {
18454
+ const db = await getFSSLinkDatabase();
18455
+ const existingBrave = await db.getUserPreference("webscraper.brave_api_key");
18456
+ const existingTavily = await db.getUserPreference("webscraper.tavily_api_key");
18457
+ if (existingBrave) {
18458
+ setBraveApiKey(existingBrave);
18459
+ }
18460
+ if (existingTavily) {
18461
+ setTavilyApiKey(existingTavily);
18462
+ }
18463
+ setIsLoading(false);
18464
+ };
18465
+ loadConfig().catch(console.error);
18368
18466
  }, []);
18369
18467
  useInput4((input, key) => {
18370
18468
  if (isLoading) return;
@@ -18391,15 +18489,18 @@ function SearchEngineConfigDialog({
18391
18489
  setCurrentField("braveApiKey");
18392
18490
  return;
18393
18491
  }
18394
- const db = getFSSLinkDatabase();
18395
- if (braveApiKey.trim()) {
18396
- db.setUserPreference("webscraper.brave_api_key", braveApiKey.trim());
18397
- process.env["BRAVE_SEARCH_API_KEY"] = braveApiKey.trim();
18398
- }
18399
- if (tavilyApiKey.trim()) {
18400
- db.setUserPreference("webscraper.tavily_api_key", tavilyApiKey.trim());
18401
- process.env["TAVILY_API_KEY"] = tavilyApiKey.trim();
18402
- }
18492
+ const saveConfig = async () => {
18493
+ const db = await getFSSLinkDatabase();
18494
+ if (braveApiKey.trim()) {
18495
+ await db.setUserPreference("webscraper.brave_api_key", braveApiKey.trim());
18496
+ process.env["BRAVE_SEARCH_API_KEY"] = braveApiKey.trim();
18497
+ }
18498
+ if (tavilyApiKey.trim()) {
18499
+ await db.setUserPreference("webscraper.tavily_api_key", tavilyApiKey.trim());
18500
+ process.env["TAVILY_API_KEY"] = tavilyApiKey.trim();
18501
+ }
18502
+ };
18503
+ saveConfig().catch(console.error);
18403
18504
  onSubmit({
18404
18505
  braveApiKey: braveApiKey.trim() || void 0,
18405
18506
  braveEnabled: !!braveApiKey.trim(),
@@ -23025,10 +23126,10 @@ var SearchEngineConfigProvider = class _SearchEngineConfigProvider {
23025
23126
  /**
23026
23127
  * Load search engine configuration from database and set environment variables
23027
23128
  */
23028
- loadConfiguration() {
23029
- const db = getFSSLinkDatabase();
23030
- const braveApiKey = db.getUserPreference("webscraper.brave_api_key");
23031
- const tavilyApiKey = db.getUserPreference("webscraper.tavily_api_key");
23129
+ async loadConfiguration() {
23130
+ const db = await getFSSLinkDatabase();
23131
+ const braveApiKey = await db.getUserPreference("webscraper.brave_api_key");
23132
+ const tavilyApiKey = await db.getUserPreference("webscraper.tavily_api_key");
23032
23133
  if (braveApiKey) {
23033
23134
  process.env["BRAVE_SEARCH_API_KEY"] = braveApiKey;
23034
23135
  }
@@ -23043,31 +23144,31 @@ var SearchEngineConfigProvider = class _SearchEngineConfigProvider {
23043
23144
  /**
23044
23145
  * Save search engine configuration to database
23045
23146
  */
23046
- saveConfiguration(config) {
23047
- const db = getFSSLinkDatabase();
23147
+ async saveConfiguration(config) {
23148
+ const db = await getFSSLinkDatabase();
23048
23149
  if (config.braveApiKey) {
23049
- db.setUserPreference("webscraper.brave_api_key", config.braveApiKey);
23050
- db.setUserPreference("webscraper.brave_enabled", "true");
23150
+ await db.setUserPreference("webscraper.brave_api_key", config.braveApiKey);
23151
+ await db.setUserPreference("webscraper.brave_enabled", "true");
23051
23152
  process.env["BRAVE_SEARCH_API_KEY"] = config.braveApiKey;
23052
23153
  }
23053
23154
  if (config.tavilyApiKey) {
23054
- db.setUserPreference("webscraper.tavily_api_key", config.tavilyApiKey);
23055
- db.setUserPreference("webscraper.tavily_enabled", "true");
23155
+ await db.setUserPreference("webscraper.tavily_api_key", config.tavilyApiKey);
23156
+ await db.setUserPreference("webscraper.tavily_enabled", "true");
23056
23157
  process.env["TAVILY_API_KEY"] = config.tavilyApiKey;
23057
23158
  }
23058
23159
  }
23059
23160
  /**
23060
23161
  * Check if search engines are configured
23061
23162
  */
23062
- hasConfiguration() {
23063
- const config = this.loadConfiguration();
23163
+ async hasConfiguration() {
23164
+ const config = await this.loadConfiguration();
23064
23165
  return !!(config.braveApiKey || config.tavilyApiKey);
23065
23166
  }
23066
23167
  /**
23067
23168
  * Get configuration status for display
23068
23169
  */
23069
- getConfigurationStatus() {
23070
- const config = this.loadConfiguration();
23170
+ async getConfigurationStatus() {
23171
+ const config = await this.loadConfiguration();
23071
23172
  let status = "\u{1F50D} Search Engine Configuration:\n";
23072
23173
  if (config.braveApiKey) {
23073
23174
  status += `\u2705 Brave Search: Configured
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fss-link",
3
- "version": "1.0.6",
3
+ "version": "1.0.9",
4
4
  "engines": {
5
5
  "node": ">=20.0.0"
6
6
  },
@@ -96,11 +96,11 @@
96
96
  "@google/genai": "1.9.0",
97
97
  "@iarna/toml": "^2.2.5",
98
98
  "@modelcontextprotocol/sdk": "^1.15.1",
99
- "@types/better-sqlite3": "^7.6.13",
99
+ "@types/sql.js": "^1.4.9",
100
100
  "@types/fs-extra": "^11.0.4",
101
101
  "@types/update-notifier": "^6.0.8",
102
102
  "axios": "^1.11.0",
103
- "better-sqlite3": "^12.2.0",
103
+ "sql.js": "^1.11.0",
104
104
  "cheerio": "^1.1.2",
105
105
  "command-exists": "^1.2.9",
106
106
  "diff": "^7.0.0",