fss-link 1.1.0 → 1.1.2
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.
- package/bundle/fss-link.js +114 -13
- package/package.json +1 -1
package/bundle/fss-link.js
CHANGED
|
@@ -22084,7 +22084,7 @@ async function createContentGeneratorConfig(config, authType) {
|
|
|
22084
22084
|
async function createContentGenerator(config, gcConfig, sessionId2) {
|
|
22085
22085
|
if (DEBUG_CONTENT)
|
|
22086
22086
|
console.log(`\u{1F41B} DEBUG createContentGenerator: authType=${config.authType}, apiKey=${config.apiKey}, baseUrl=${config.baseUrl}`);
|
|
22087
|
-
const version = "1.1.
|
|
22087
|
+
const version = "1.1.2";
|
|
22088
22088
|
const userAgent = `FSS-Link/${version} (${process.platform}; ${process.arch})`;
|
|
22089
22089
|
const baseHeaders = {
|
|
22090
22090
|
"User-Agent": userAgent
|
|
@@ -71176,7 +71176,18 @@ var init_config = __esm({
|
|
|
71176
71176
|
console.warn("Database configuration invalid - may need manual setup");
|
|
71177
71177
|
}
|
|
71178
71178
|
} else {
|
|
71179
|
-
|
|
71179
|
+
const currentAuthType = await this.modelStateProvider.getCurrentAuthType();
|
|
71180
|
+
if (currentAuthType && currentAuthType !== authMethod) {
|
|
71181
|
+
console.log(`Auth type changed: ${currentAuthType} \u2192 ${authMethod}`);
|
|
71182
|
+
const switched = await this.modelStateProvider.switchToAuthType(authMethod);
|
|
71183
|
+
if (switched) {
|
|
71184
|
+
console.log(`\u2705 Switched to ${authMethod} model from database`);
|
|
71185
|
+
} else {
|
|
71186
|
+
console.warn(`\u26A0\uFE0F No ${authMethod} model in database, using defaults`);
|
|
71187
|
+
}
|
|
71188
|
+
} else {
|
|
71189
|
+
console.log("Using existing database configuration");
|
|
71190
|
+
}
|
|
71180
71191
|
}
|
|
71181
71192
|
} else {
|
|
71182
71193
|
console.warn("No model state provider available - database-first authentication unavailable");
|
|
@@ -82943,6 +82954,7 @@ var ModelDatabase;
|
|
|
82943
82954
|
var init_model_database = __esm({
|
|
82944
82955
|
"packages/cli/src/config/model-database.ts"() {
|
|
82945
82956
|
init_database_utils();
|
|
82957
|
+
init_database();
|
|
82946
82958
|
ModelDatabase = class {
|
|
82947
82959
|
constructor(db) {
|
|
82948
82960
|
this.db = db;
|
|
@@ -83004,7 +83016,7 @@ var init_model_database = __esm({
|
|
|
83004
83016
|
if (!this.db) {
|
|
83005
83017
|
throw new Error("Database not initialized");
|
|
83006
83018
|
}
|
|
83007
|
-
const encryptedApiKey = config.apiKey
|
|
83019
|
+
const encryptedApiKey = config.apiKey ? FSSLinkDatabase.encryptApiKey(config.apiKey) : null;
|
|
83008
83020
|
const normalizedEndpointUrl = config.endpointUrl || "";
|
|
83009
83021
|
const existingRecord = await safeQueryFirstWithLocking(
|
|
83010
83022
|
this.db,
|
|
@@ -83244,7 +83256,7 @@ var init_model_database = __esm({
|
|
|
83244
83256
|
authType: record.auth_type,
|
|
83245
83257
|
modelName: record.model_name,
|
|
83246
83258
|
endpointUrl: record.endpoint_url || void 0,
|
|
83247
|
-
apiKey: record.api_key
|
|
83259
|
+
apiKey: record.api_key ? FSSLinkDatabase.decryptApiKey(record.api_key) : void 0,
|
|
83248
83260
|
displayName: record.display_name || void 0,
|
|
83249
83261
|
isFavorite: record.is_favorite === 1,
|
|
83250
83262
|
isActive: record.is_active === 1,
|
|
@@ -84545,15 +84557,63 @@ var init_database = __esm({
|
|
|
84545
84557
|
* Legacy encryption methods (maintained for compatibility)
|
|
84546
84558
|
*/
|
|
84547
84559
|
encrypt(value) {
|
|
84548
|
-
|
|
84549
|
-
|
|
84560
|
+
if (!value) return value;
|
|
84561
|
+
const iv = crypto13.randomBytes(16);
|
|
84562
|
+
const cipher = crypto13.createCipheriv("aes-256-cbc", this.encryptionKey, iv);
|
|
84563
|
+
let encrypted = iv.toString("hex") + ":";
|
|
84564
|
+
encrypted += cipher.update(value, "utf8", "hex");
|
|
84550
84565
|
encrypted += cipher.final("hex");
|
|
84551
84566
|
return encrypted;
|
|
84552
84567
|
}
|
|
84553
84568
|
decrypt(value) {
|
|
84569
|
+
if (!value) return value;
|
|
84554
84570
|
try {
|
|
84555
|
-
const
|
|
84556
|
-
|
|
84571
|
+
const parts = value.split(":");
|
|
84572
|
+
const iv = Buffer.from(parts[0], "hex");
|
|
84573
|
+
const encrypted = parts[1];
|
|
84574
|
+
const decipher = crypto13.createDecipheriv("aes-256-cbc", this.encryptionKey, iv);
|
|
84575
|
+
let decrypted = decipher.update(encrypted, "hex", "utf8");
|
|
84576
|
+
decrypted += decipher.final("utf8");
|
|
84577
|
+
return decrypted;
|
|
84578
|
+
} catch (error) {
|
|
84579
|
+
return value;
|
|
84580
|
+
}
|
|
84581
|
+
}
|
|
84582
|
+
/**
|
|
84583
|
+
* Static encryption methods for use across database classes
|
|
84584
|
+
*/
|
|
84585
|
+
static getEncryptionKey() {
|
|
84586
|
+
const keyPath = path57.join(USER_SETTINGS_DIR, "db.key");
|
|
84587
|
+
if (fs51.existsSync(keyPath)) {
|
|
84588
|
+
return fs51.readFileSync(keyPath);
|
|
84589
|
+
} else {
|
|
84590
|
+
const key = crypto13.randomBytes(32);
|
|
84591
|
+
if (!fs51.existsSync(USER_SETTINGS_DIR)) {
|
|
84592
|
+
fs51.mkdirSync(USER_SETTINGS_DIR, { recursive: true });
|
|
84593
|
+
}
|
|
84594
|
+
fs51.writeFileSync(keyPath, key);
|
|
84595
|
+
return key;
|
|
84596
|
+
}
|
|
84597
|
+
}
|
|
84598
|
+
static encryptApiKey(value) {
|
|
84599
|
+
if (!value) return value;
|
|
84600
|
+
const key = this.getEncryptionKey();
|
|
84601
|
+
const iv = crypto13.randomBytes(16);
|
|
84602
|
+
const cipher = crypto13.createCipheriv("aes-256-cbc", key, iv);
|
|
84603
|
+
let encrypted = iv.toString("hex") + ":";
|
|
84604
|
+
encrypted += cipher.update(value, "utf8", "hex");
|
|
84605
|
+
encrypted += cipher.final("hex");
|
|
84606
|
+
return encrypted;
|
|
84607
|
+
}
|
|
84608
|
+
static decryptApiKey(value) {
|
|
84609
|
+
if (!value) return value;
|
|
84610
|
+
try {
|
|
84611
|
+
const key = this.getEncryptionKey();
|
|
84612
|
+
const parts = value.split(":");
|
|
84613
|
+
const iv = Buffer.from(parts[0], "hex");
|
|
84614
|
+
const encrypted = parts[1];
|
|
84615
|
+
const decipher = crypto13.createDecipheriv("aes-256-cbc", key, iv);
|
|
84616
|
+
let decrypted = decipher.update(encrypted, "hex", "utf8");
|
|
84557
84617
|
decrypted += decipher.final("utf8");
|
|
84558
84618
|
return decrypted;
|
|
84559
84619
|
} catch (error) {
|
|
@@ -84673,6 +84733,48 @@ var init_modelManager = __esm({
|
|
|
84673
84733
|
return false;
|
|
84674
84734
|
}
|
|
84675
84735
|
}
|
|
84736
|
+
/**
|
|
84737
|
+
* Switch to a model with the specified auth type
|
|
84738
|
+
* Finds the most recently used model with matching auth_type and activates it
|
|
84739
|
+
*
|
|
84740
|
+
* @param authType - The auth type to switch to
|
|
84741
|
+
* @returns true if a matching model was found and activated, false otherwise
|
|
84742
|
+
*
|
|
84743
|
+
* 🔒 MIGRATED: Uses UnifiedDatabase for thread-safe operations
|
|
84744
|
+
*/
|
|
84745
|
+
async switchToAuthType(authType) {
|
|
84746
|
+
try {
|
|
84747
|
+
if (DEBUG_MODEL) console.log(`\u{1F512} [MODEL-MANAGER] Switching to auth type: ${authType}`);
|
|
84748
|
+
const db = await this.getDb();
|
|
84749
|
+
const models = await db.getModelsByAuthType(authType);
|
|
84750
|
+
if (models.length === 0) {
|
|
84751
|
+
if (DEBUG_MODEL) console.log(`\u274C [MODEL-MANAGER] No models found with auth_type: ${authType}`);
|
|
84752
|
+
return false;
|
|
84753
|
+
}
|
|
84754
|
+
models.sort((a, b) => {
|
|
84755
|
+
const aTime = a.lastUsed?.getTime() || 0;
|
|
84756
|
+
const bTime = b.lastUsed?.getTime() || 0;
|
|
84757
|
+
return bTime - aTime;
|
|
84758
|
+
});
|
|
84759
|
+
const modelToActivate = models[0];
|
|
84760
|
+
if (!modelToActivate.id) {
|
|
84761
|
+
console.error(`\u274C [MODEL-MANAGER] Model missing ID, cannot activate`);
|
|
84762
|
+
return false;
|
|
84763
|
+
}
|
|
84764
|
+
if (DEBUG_MODEL) {
|
|
84765
|
+
console.log(`\u2705 [MODEL-MANAGER] Found model: ${modelToActivate.displayName} (id=${modelToActivate.id})`);
|
|
84766
|
+
}
|
|
84767
|
+
await db.setActiveModel(modelToActivate.id);
|
|
84768
|
+
await this.updateEnvironmentFromModel(modelToActivate);
|
|
84769
|
+
if (DEBUG_MODEL) {
|
|
84770
|
+
console.log(`\u2705 [MODEL-MANAGER] Successfully switched to ${authType}/${modelToActivate.modelName}`);
|
|
84771
|
+
}
|
|
84772
|
+
return true;
|
|
84773
|
+
} catch (error) {
|
|
84774
|
+
console.error(`\u274C [MODEL-MANAGER] Failed to switch to auth type ${authType}:`, error);
|
|
84775
|
+
return false;
|
|
84776
|
+
}
|
|
84777
|
+
}
|
|
84676
84778
|
/**
|
|
84677
84779
|
* Get the currently active model
|
|
84678
84780
|
*
|
|
@@ -84834,9 +84936,8 @@ var init_modelManager = __esm({
|
|
|
84834
84936
|
let settings = {};
|
|
84835
84937
|
try {
|
|
84836
84938
|
const db = await this.getDb();
|
|
84837
|
-
|
|
84838
|
-
|
|
84839
|
-
settings = await db.getProviderSettings(providerModel["id"]);
|
|
84939
|
+
if (model.id) {
|
|
84940
|
+
settings = await db.getProviderSettings(model.id);
|
|
84840
84941
|
}
|
|
84841
84942
|
} catch (error) {
|
|
84842
84943
|
console.warn("Failed to load provider settings:", error);
|
|
@@ -93827,7 +93928,7 @@ async function getPackageJson() {
|
|
|
93827
93928
|
// packages/cli/src/utils/version.ts
|
|
93828
93929
|
async function getCliVersion() {
|
|
93829
93930
|
const pkgJson = await getPackageJson();
|
|
93830
|
-
return "1.1.
|
|
93931
|
+
return "1.1.2";
|
|
93831
93932
|
}
|
|
93832
93933
|
|
|
93833
93934
|
// packages/cli/src/ui/commands/aboutCommand.ts
|
|
@@ -93879,7 +93980,7 @@ import open4 from "open";
|
|
|
93879
93980
|
import process11 from "node:process";
|
|
93880
93981
|
|
|
93881
93982
|
// packages/cli/src/generated/git-commit.ts
|
|
93882
|
-
var GIT_COMMIT_INFO = "
|
|
93983
|
+
var GIT_COMMIT_INFO = "5495c6a2";
|
|
93883
93984
|
|
|
93884
93985
|
// packages/cli/src/ui/commands/bugCommand.ts
|
|
93885
93986
|
init_dist2();
|