Added complete source code and pre-compiled application: Source Code: - app.asar (compiled Electron app) - app-extracted/ (all extracted source files) - dist/services/aiProviderService.js - dist/services/settingsService.js - dist/ipcHandlers.js - dist/aiProviderAPI.ts - dist/ai-provider-settings.html - And all other application files Build Tools: - scripts/extract-app.sh - scripts/repack-app.sh - scripts/build-deb.sh - scripts/install-deb.sh Documentation: - SOURCE_CODE.md (repository structure) - BUILD.md (build instructions) - README.md (overview) - docs/ (complete API docs) - AI_PROVIDER_SPECIFICATION.md - AI_PROVIDER_README.md - IMPLEMENTATION_SUMMARY.md Features included: - 17+ AI provider presets - One-click provider setup - Model auto-fetching - Connection testing - Modern GUI interface - Complete IPC handlers (14 new) - TypeScript API wrapper - Persistent settings Ready to build and customize!
63 lines
2.4 KiB
JavaScript
63 lines
2.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.SettingsService = exports.DEFAULTS = exports.SettingKey = void 0;
|
|
const utils_1 = require("../utils");
|
|
// Setting keys
|
|
var SettingKey;
|
|
(function (SettingKey) {
|
|
SettingKey["RUN_IN_BACKGROUND"] = "runInBackground";
|
|
SettingKey["KEEP_COMPUTER_AWAKE"] = "keepComputerAwake";
|
|
SettingKey["AI_PROVIDER"] = "aiProvider";
|
|
SettingKey["AI_MODEL"] = "aiModel";
|
|
SettingKey["AI_PROVIDERS_CONFIG"] = "aiProviders";
|
|
SettingKey["AI_TEMPERATURE"] = "aiTemperature";
|
|
SettingKey["AI_MAX_TOKENS"] = "aiMaxTokens";
|
|
SettingKey["AI_STREAMING"] = "aiStreaming";
|
|
SettingKey["AI_EMBEDDING_PROVIDER"] = "aiEmbeddingProvider";
|
|
})(SettingKey || (exports.SettingKey = SettingKey = {}));
|
|
// Default values
|
|
exports.DEFAULTS = new Map([
|
|
// The following setting is off by default for windows because the app
|
|
// icon is not as discoverable in the bottom right corner menu bar as
|
|
// it is on macOS and linux.
|
|
[SettingKey.RUN_IN_BACKGROUND, process.platform !== 'win32'],
|
|
[SettingKey.KEEP_COMPUTER_AWAKE, false],
|
|
[SettingKey.AI_PROVIDER, 'openai-default'],
|
|
[SettingKey.AI_MODEL, 'gpt-4o'],
|
|
[SettingKey.AI_TEMPERATURE, '0.7'],
|
|
[SettingKey.AI_MAX_TOKENS, '4096'],
|
|
[SettingKey.AI_STREAMING, 'true'],
|
|
[SettingKey.AI_EMBEDDING_PROVIDER, 'openai-default'],
|
|
]);
|
|
/**
|
|
* A thin wrapper around StorageManager to listen for changes
|
|
* in settings and apply their side effects.
|
|
*/
|
|
class SettingsService {
|
|
constructor(storageManager) {
|
|
this.storageManager = storageManager;
|
|
this.storageManager.onDidChange((changes) => {
|
|
this.applySideEffects(changes);
|
|
});
|
|
void this.initialize();
|
|
}
|
|
async initialize() {
|
|
const items = await this.storageManager.getItems();
|
|
this.applySideEffects(items);
|
|
}
|
|
applySideEffects(settings) {
|
|
const val = settings[SettingKey.KEEP_COMPUTER_AWAKE];
|
|
if (val !== undefined) {
|
|
const preventSleep = val === null
|
|
? exports.DEFAULTS.get(SettingKey.KEEP_COMPUTER_AWAKE)
|
|
: val === 'true';
|
|
utils_1.SleepBlocker.getInstance().shouldKeepComputerAwake(preventSleep);
|
|
}
|
|
}
|
|
async getSetting(key) {
|
|
const items = await this.storageManager.getItems();
|
|
return items[key] === 'true';
|
|
}
|
|
}
|
|
exports.SettingsService = SettingsService;
|