fss-link 1.0.66 → 1.0.67

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 +95 -87
  2. package/package.json +1 -1
@@ -22379,7 +22379,7 @@ function createContentGeneratorConfig(config, authType) {
22379
22379
  return contentGeneratorConfig;
22380
22380
  }
22381
22381
  async function createContentGenerator(config, gcConfig, sessionId2) {
22382
- const version = "1.0.66";
22382
+ const version = "1.0.67";
22383
22383
  const userAgent = `FSS-Link/${version} (${process.platform}; ${process.arch})`;
22384
22384
  const baseHeaders = {
22385
22385
  "User-Agent": userAgent
@@ -371372,7 +371372,6 @@ var FSSLinkDatabase = class {
371372
371372
  await this.pool.initialize();
371373
371373
  debugLog("Database connection pool initialized successfully");
371374
371374
  await this.pool.withConnection(async (db) => {
371375
- this.db = db;
371376
371375
  debugLog("Database connection acquired, checking migration status...");
371377
371376
  const needsMigration = this.migrationManager.needsMigration(db);
371378
371377
  debugLog(`Migration needed: ${needsMigration}`);
@@ -371398,7 +371397,7 @@ var FSSLinkDatabase = class {
371398
371397
  }
371399
371398
  debugLog("Database schema validation passed");
371400
371399
  debugLog("Running legacy schema initialization...");
371401
- await this.initializeSchema();
371400
+ await this.initializeSchema(db);
371402
371401
  debugLog("Legacy schema initialization completed");
371403
371402
  debugLog("Performing final table existence check...");
371404
371403
  const criticalTables = ["model_configs", "provider_usage_stats", "user_preferences"];
@@ -371480,9 +371479,10 @@ var FSSLinkDatabase = class {
371480
371479
  /**
371481
371480
  * Initialize database schema
371482
371481
  */
371483
- async initializeSchema() {
371484
- if (!this.db) return;
371485
- this.db.exec(`
371482
+ async initializeSchema(db) {
371483
+ const database = db || this.db;
371484
+ if (!database) return;
371485
+ database.exec(`
371486
371486
  CREATE TABLE IF NOT EXISTS model_configs (
371487
371487
  id INTEGER PRIMARY KEY AUTOINCREMENT,
371488
371488
  auth_type TEXT NOT NULL,
@@ -371498,19 +371498,19 @@ var FSSLinkDatabase = class {
371498
371498
  UNIQUE(auth_type, model_name, endpoint_url)
371499
371499
  )
371500
371500
  `);
371501
- this.db.exec(`
371501
+ database.exec(`
371502
371502
  CREATE UNIQUE INDEX IF NOT EXISTS idx_model_configs_active_unique
371503
371503
  ON model_configs(auth_type)
371504
371504
  WHERE is_active = 1
371505
371505
  `);
371506
- this.db.exec(`
371506
+ database.exec(`
371507
371507
  CREATE TABLE IF NOT EXISTS user_preferences (
371508
371508
  key TEXT PRIMARY KEY,
371509
371509
  value TEXT NOT NULL,
371510
371510
  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
371511
371511
  )
371512
371512
  `);
371513
- this.db.exec(`
371513
+ database.exec(`
371514
371514
  CREATE TABLE IF NOT EXISTS custom_endpoints (
371515
371515
  id INTEGER PRIMARY KEY AUTOINCREMENT,
371516
371516
  provider_id INTEGER NOT NULL,
@@ -371522,7 +371522,7 @@ var FSSLinkDatabase = class {
371522
371522
  FOREIGN KEY (provider_id) REFERENCES model_configs (id)
371523
371523
  )
371524
371524
  `);
371525
- this.db.exec(`
371525
+ database.exec(`
371526
371526
  CREATE TABLE IF NOT EXISTS provider_usage (
371527
371527
  id INTEGER PRIMARY KEY AUTOINCREMENT,
371528
371528
  provider_id INTEGER NOT NULL,
@@ -371534,7 +371534,7 @@ var FSSLinkDatabase = class {
371534
371534
  UNIQUE(provider_id, session_date)
371535
371535
  )
371536
371536
  `);
371537
- this.db.exec(`
371537
+ database.exec(`
371538
371538
  CREATE TABLE IF NOT EXISTS provider_settings (
371539
371539
  id INTEGER PRIMARY KEY AUTOINCREMENT,
371540
371540
  provider_id INTEGER NOT NULL,
@@ -371546,7 +371546,7 @@ var FSSLinkDatabase = class {
371546
371546
  )
371547
371547
  `);
371548
371548
  debugLog("Creating provider_usage_stats table (legacy schema fallback)...");
371549
- this.db.exec(`
371549
+ database.exec(`
371550
371550
  CREATE TABLE IF NOT EXISTS provider_usage_stats (
371551
371551
  id INTEGER PRIMARY KEY AUTOINCREMENT,
371552
371552
  provider_id INTEGER NOT NULL,
@@ -371556,7 +371556,7 @@ var FSSLinkDatabase = class {
371556
371556
  )
371557
371557
  `);
371558
371558
  debugLog("provider_usage_stats table exists (legacy schema)");
371559
- this.db.exec(`
371559
+ database.exec(`
371560
371560
  CREATE INDEX IF NOT EXISTS idx_model_configs_active ON model_configs(is_active);
371561
371561
  CREATE INDEX IF NOT EXISTS idx_model_configs_favorite ON model_configs(is_favorite);
371562
371562
  CREATE INDEX IF NOT EXISTS idx_model_configs_last_used ON model_configs(last_used DESC);
@@ -371565,16 +371565,17 @@ var FSSLinkDatabase = class {
371565
371565
  CREATE INDEX IF NOT EXISTS idx_provider_usage_stats_aggregation ON provider_usage_stats(provider_id, created_at DESC);
371566
371566
  CREATE INDEX IF NOT EXISTS idx_provider_settings_key ON provider_settings(provider_id, setting_key);
371567
371567
  `);
371568
- await this.ensureDefaultConfigurations();
371568
+ await this.ensureDefaultConfigurations(database);
371569
371569
  this.save();
371570
371570
  }
371571
371571
  /**
371572
371572
  * Ensure default model configurations exist for new installations
371573
371573
  */
371574
- async ensureDefaultConfigurations() {
371575
- if (!this.db) return;
371574
+ async ensureDefaultConfigurations(db) {
371575
+ const database = db || this.db;
371576
+ if (!database) return;
371576
371577
  const countResult = safeQueryFirst(
371577
- this.db,
371578
+ database,
371578
371579
  "SELECT COUNT(*) as count FROM model_configs"
371579
371580
  );
371580
371581
  if ((countResult?.count || 0) === 0) {
@@ -371591,7 +371592,7 @@ var FSSLinkDatabase = class {
371591
371592
  last_used: null,
371592
371593
  created_at: (/* @__PURE__ */ new Date()).toISOString()
371593
371594
  };
371594
- safeExec(this.db, `
371595
+ safeExec(database, `
371595
371596
  INSERT INTO model_configs (
371596
371597
  auth_type, model_name, endpoint_url, api_key, display_name,
371597
371598
  is_favorite, is_active, last_used, created_at
@@ -371607,7 +371608,7 @@ var FSSLinkDatabase = class {
371607
371608
  defaultOllamaConfig.last_used,
371608
371609
  defaultOllamaConfig.created_at
371609
371610
  ]);
371610
- const ollamaId = getLastInsertId(this.db);
371611
+ const ollamaId = getLastInsertId(database);
371611
371612
  const defaultGeminiConfig = {
371612
371613
  auth_type: "gemini-api-key",
371613
371614
  model_name: "gemini-2.5-flash-thinking",
@@ -371620,7 +371621,7 @@ var FSSLinkDatabase = class {
371620
371621
  last_used: null,
371621
371622
  created_at: (/* @__PURE__ */ new Date()).toISOString()
371622
371623
  };
371623
- safeExec(this.db, `
371624
+ safeExec(database, `
371624
371625
  INSERT INTO model_configs (
371625
371626
  auth_type, model_name, endpoint_url, api_key, display_name,
371626
371627
  is_favorite, is_active, last_used, created_at
@@ -371649,7 +371650,7 @@ var FSSLinkDatabase = class {
371649
371650
  last_used: null,
371650
371651
  created_at: (/* @__PURE__ */ new Date()).toISOString()
371651
371652
  };
371652
- safeExec(this.db, `
371653
+ safeExec(database, `
371653
371654
  INSERT INTO model_configs (
371654
371655
  auth_type, model_name, endpoint_url, api_key, display_name,
371655
371656
  is_favorite, is_active, last_used, created_at
@@ -371678,7 +371679,7 @@ var FSSLinkDatabase = class {
371678
371679
  last_used: null,
371679
371680
  created_at: (/* @__PURE__ */ new Date()).toISOString()
371680
371681
  };
371681
- safeExec(this.db, `
371682
+ safeExec(database, `
371682
371683
  INSERT INTO model_configs (
371683
371684
  auth_type, model_name, endpoint_url, api_key, display_name,
371684
371685
  is_favorite, is_active, last_used, created_at
@@ -371694,31 +371695,31 @@ var FSSLinkDatabase = class {
371694
371695
  defaultOpenAIConfig.last_used,
371695
371696
  defaultOpenAIConfig.created_at
371696
371697
  ]);
371697
- const lmStudioId = getLastInsertId(this.db);
371698
+ const lmStudioId = getLastInsertId(database);
371698
371699
  const now = (/* @__PURE__ */ new Date()).toISOString();
371699
- safeExec(this.db, `
371700
+ safeExec(database, `
371700
371701
  INSERT INTO provider_settings (provider_id, setting_key, setting_value, updated_at)
371701
371702
  VALUES (?, ?, ?, ?)
371702
371703
  `, [ollamaId, "num_ctx", "32768", now]);
371703
- safeExec(this.db, `
371704
+ safeExec(database, `
371704
371705
  INSERT INTO provider_settings (provider_id, setting_key, setting_value, updated_at)
371705
371706
  VALUES (?, ?, ?, ?)
371706
371707
  `, [ollamaId, "temperature", "0.0", now]);
371707
- safeExec(this.db, `
371708
+ safeExec(database, `
371708
371709
  INSERT INTO provider_settings (provider_id, setting_key, setting_value, updated_at)
371709
371710
  VALUES (?, ?, ?, ?)
371710
371711
  `, [lmStudioId, "num_ctx", "32768", now]);
371711
- safeExec(this.db, `
371712
+ safeExec(database, `
371712
371713
  INSERT INTO provider_settings (provider_id, setting_key, setting_value, updated_at)
371713
371714
  VALUES (?, ?, ?, ?)
371714
371715
  `, [lmStudioId, "temperature", "0.0", now]);
371715
371716
  }
371716
371717
  const activeResult = safeQueryFirst(
371717
- this.db,
371718
+ database,
371718
371719
  "SELECT COUNT(*) as count FROM model_configs WHERE is_active = 1"
371719
371720
  );
371720
371721
  if ((activeResult?.count || 0) === 0) {
371721
- const bestModel = safeQueryFirst(this.db, `
371722
+ const bestModel = safeQueryFirst(database, `
371722
371723
  SELECT id FROM model_configs
371723
371724
  WHERE auth_type IN ('ollama', 'lm-studio', 'gemini-api-key', 'openai-api-key')
371724
371725
  ORDER BY
@@ -371733,21 +371734,21 @@ var FSSLinkDatabase = class {
371733
371734
  LIMIT 1
371734
371735
  `);
371735
371736
  if (bestModel) {
371736
- safeExec(this.db, "UPDATE model_configs SET is_active = 1 WHERE id = ?", [bestModel.id]);
371737
+ safeExec(database, "UPDATE model_configs SET is_active = 1 WHERE id = ?", [bestModel.id]);
371737
371738
  const settingsCheck = safeQueryFirst(
371738
- this.db,
371739
+ database,
371739
371740
  "SELECT COUNT(*) as count FROM provider_settings WHERE provider_id = ?",
371740
371741
  [bestModel.id]
371741
371742
  );
371742
371743
  if ((settingsCheck?.count || 0) === 0) {
371743
371744
  const now = (/* @__PURE__ */ new Date()).toISOString();
371744
371745
  safeExec(
371745
- this.db,
371746
+ database,
371746
371747
  "INSERT INTO provider_settings (provider_id, setting_key, setting_value, updated_at) VALUES (?, ?, ?, ?)",
371747
371748
  [bestModel.id, "num_ctx", "32768", now]
371748
371749
  );
371749
371750
  safeExec(
371750
- this.db,
371751
+ database,
371751
371752
  "INSERT INTO provider_settings (provider_id, setting_key, setting_value, updated_at) VALUES (?, ?, ?, ?)",
371752
371753
  [bestModel.id, "temperature", "0.0", now]
371753
371754
  );
@@ -371807,13 +371808,16 @@ var FSSLinkDatabase = class {
371807
371808
  */
371808
371809
  async setActiveModel(id) {
371809
371810
  await this.ensureInitialized();
371810
- if (!this.db) return;
371811
- this.db.run("UPDATE model_configs SET is_active = 0");
371812
- this.db.run(`
371813
- UPDATE model_configs
371814
- SET is_active = 1, last_used = CURRENT_TIMESTAMP
371815
- WHERE id = ?
371816
- `, [id]);
371811
+ await this.pool.withConnection(async (db) => {
371812
+ safeTransaction(db, () => {
371813
+ safeExec(db, "UPDATE model_configs SET is_active = 0");
371814
+ safeExec(db, `
371815
+ UPDATE model_configs
371816
+ SET is_active = 1, last_used = CURRENT_TIMESTAMP
371817
+ WHERE id = ?
371818
+ `, [id]);
371819
+ });
371820
+ });
371817
371821
  this.save();
371818
371822
  }
371819
371823
  /**
@@ -371822,24 +371826,25 @@ var FSSLinkDatabase = class {
371822
371826
  */
371823
371827
  async upsertModelConfig(config) {
371824
371828
  await this.ensureInitialized();
371825
- if (!this.db) return -1;
371826
371829
  const encryptedApiKey = config.apiKey ? this.encryptApiKey(config.apiKey) : null;
371827
- safeExec(this.db, `
371828
- INSERT OR REPLACE INTO model_configs
371829
- (auth_type, model_name, endpoint_url, api_key, display_name, is_favorite, is_active, last_used, source)
371830
- VALUES (?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, ?)
371831
- `, [
371832
- config.authType,
371833
- config.modelName,
371834
- config.endpointUrl || null,
371835
- encryptedApiKey,
371836
- config.displayName || null,
371837
- config.isFavorite ? 1 : 0,
371838
- config.isActive ? 1 : 0,
371839
- config.source || "db"
371840
- ]);
371841
- this.save();
371842
- return getLastInsertId(this.db);
371830
+ return await this.pool.withConnection(async (db) => {
371831
+ safeExec(db, `
371832
+ INSERT OR REPLACE INTO model_configs
371833
+ (auth_type, model_name, endpoint_url, api_key, display_name, is_favorite, is_active, last_used, source)
371834
+ VALUES (?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, ?)
371835
+ `, [
371836
+ config.authType,
371837
+ config.modelName,
371838
+ config.endpointUrl || null,
371839
+ encryptedApiKey,
371840
+ config.displayName || null,
371841
+ config.isFavorite ? 1 : 0,
371842
+ config.isActive ? 1 : 0,
371843
+ config.source || "db"
371844
+ ]);
371845
+ this.save();
371846
+ return getLastInsertId(db);
371847
+ });
371843
371848
  }
371844
371849
  /**
371845
371850
  * Get all model configurations
@@ -371896,12 +371901,13 @@ var FSSLinkDatabase = class {
371896
371901
  */
371897
371902
  async toggleModelFavorite(id) {
371898
371903
  await this.ensureInitialized();
371899
- if (!this.db) return;
371900
- this.db.run(`
371901
- UPDATE model_configs
371902
- SET is_favorite = CASE WHEN is_favorite = 1 THEN 0 ELSE 1 END
371903
- WHERE id = ?
371904
- `, [id]);
371904
+ await this.pool.withConnection(async (db) => {
371905
+ safeExec(db, `
371906
+ UPDATE model_configs
371907
+ SET is_favorite = CASE WHEN is_favorite = 1 THEN 0 ELSE 1 END
371908
+ WHERE id = ?
371909
+ `, [id]);
371910
+ });
371905
371911
  this.save();
371906
371912
  }
371907
371913
  /**
@@ -371909,8 +371915,9 @@ var FSSLinkDatabase = class {
371909
371915
  */
371910
371916
  async deleteModel(id) {
371911
371917
  await this.ensureInitialized();
371912
- if (!this.db) return;
371913
- this.db.run("DELETE FROM model_configs WHERE id = ?", [id]);
371918
+ await this.pool.withConnection(async (db) => {
371919
+ safeExec(db, "DELETE FROM model_configs WHERE id = ?", [id]);
371920
+ });
371914
371921
  this.save();
371915
371922
  }
371916
371923
  /**
@@ -371918,11 +371925,12 @@ var FSSLinkDatabase = class {
371918
371925
  */
371919
371926
  async setUserPreference(key, value) {
371920
371927
  await this.ensureInitialized();
371921
- if (!this.db) return;
371922
- this.db.run(`
371923
- INSERT OR REPLACE INTO user_preferences (key, value, updated_at)
371924
- VALUES (?, ?, CURRENT_TIMESTAMP)
371925
- `, [key, value]);
371928
+ await this.pool.withConnection(async (db) => {
371929
+ safeExec(db, `
371930
+ INSERT OR REPLACE INTO user_preferences (key, value, updated_at)
371931
+ VALUES (?, ?, CURRENT_TIMESTAMP)
371932
+ `, [key, value]);
371933
+ });
371926
371934
  this.save();
371927
371935
  }
371928
371936
  /**
@@ -372153,21 +372161,21 @@ var FSSLinkDatabase = class {
372153
372161
  */
372154
372162
  async saveCustomEndpoint(providerId, name2, url2, description, isDefault = false) {
372155
372163
  await this.ensureInitialized();
372156
- if (!this.db) return -1;
372157
- if (isDefault) {
372158
- this.db.exec(`
372159
- UPDATE custom_endpoints
372160
- SET is_default = 0
372161
- WHERE provider_id = ?
372162
- `, [providerId]);
372163
- }
372164
- this.db.exec(`
372165
- INSERT OR REPLACE INTO custom_endpoints (provider_id, name, url, description, is_default)
372166
- VALUES (?, ?, ?, ?, ?)
372167
- `, [providerId, name2, url2, description || null, isDefault ? 1 : 0]);
372168
- this.save();
372169
- const result = this.db.exec("SELECT last_insert_rowid() as id");
372170
- return result[0]?.values[0]?.[0] || -1;
372164
+ return await this.pool.withConnection(async (db) => {
372165
+ if (isDefault) {
372166
+ safeExec(db, `
372167
+ UPDATE custom_endpoints
372168
+ SET is_default = 0
372169
+ WHERE provider_id = ?
372170
+ `, [providerId]);
372171
+ }
372172
+ safeExec(db, `
372173
+ INSERT OR REPLACE INTO custom_endpoints (provider_id, name, url, description, is_default)
372174
+ VALUES (?, ?, ?, ?, ?)
372175
+ `, [providerId, name2, url2, description || null, isDefault ? 1 : 0]);
372176
+ this.save();
372177
+ return getLastInsertId(db);
372178
+ });
372171
372179
  }
372172
372180
  /**
372173
372181
  * Get custom endpoints for a provider
@@ -373517,7 +373525,7 @@ async function getPackageJson() {
373517
373525
  // packages/cli/src/utils/version.ts
373518
373526
  async function getCliVersion() {
373519
373527
  const pkgJson = await getPackageJson();
373520
- return "1.0.66";
373528
+ return "1.0.67";
373521
373529
  }
373522
373530
 
373523
373531
  // packages/cli/src/ui/commands/aboutCommand.ts
@@ -373569,7 +373577,7 @@ import open4 from "open";
373569
373577
  import process11 from "node:process";
373570
373578
 
373571
373579
  // packages/cli/src/generated/git-commit.ts
373572
- var GIT_COMMIT_INFO = "7803e002";
373580
+ var GIT_COMMIT_INFO = "1379e712";
373573
373581
 
373574
373582
  // packages/cli/src/ui/commands/bugCommand.ts
373575
373583
  init_dist2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fss-link",
3
- "version": "1.0.66",
3
+ "version": "1.0.67",
4
4
  "engines": {
5
5
  "node": ">=20.0.0"
6
6
  },