all node.js classes are managers now for simplicity

This commit is contained in:
Egor 2025-08-30 13:51:51 -07:00
parent 67667f187d
commit 914e974426
4 changed files with 32 additions and 32 deletions

View file

@ -6,8 +6,8 @@ import { ConfigManager } from '@/main/managers/ConfigManager';
import { LogManager } from '@/main/managers/LogManager'; import { LogManager } from '@/main/managers/LogManager';
import { KoboldCppManager } from '@/main/managers/KoboldCppManager'; import { KoboldCppManager } from '@/main/managers/KoboldCppManager';
import { SillyTavernManager } from '@/main/managers/SillyTavernManager'; import { SillyTavernManager } from '@/main/managers/SillyTavernManager';
import { HardwareService } from '@/main/services/HardwareService'; import { HardwareManager } from '@/main/managers/HardwareManager';
import { BinaryService } from '@/main/services/BinaryService'; import { BinaryManager } from '@/main/managers/BinaryManager';
import { IPCHandlers } from '@/main/ipc'; import { IPCHandlers } from '@/main/ipc';
import { PRODUCT_NAME, CONFIG_FILE_NAME } from '@/constants'; import { PRODUCT_NAME, CONFIG_FILE_NAME } from '@/constants';
import { homedir } from 'os'; import { homedir } from 'os';
@ -19,8 +19,8 @@ export class GerbilApp {
private configManager: ConfigManager; private configManager: ConfigManager;
private logManager: LogManager; private logManager: LogManager;
private sillyTavernManager: SillyTavernManager; private sillyTavernManager: SillyTavernManager;
private hardwareService: HardwareService; private hardwareManager: HardwareManager;
private binaryService: BinaryService; private binaryManager: BinaryManager;
private ipcHandlers: IPCHandlers; private ipcHandlers: IPCHandlers;
constructor() { constructor() {
@ -32,7 +32,7 @@ export class GerbilApp {
this.logManager this.logManager
); );
this.windowManager = new WindowManager(); this.windowManager = new WindowManager();
this.hardwareService = new HardwareService(this.logManager); this.hardwareManager = new HardwareManager(this.logManager);
this.koboldManager = new KoboldCppManager( this.koboldManager = new KoboldCppManager(
this.configManager, this.configManager,
@ -40,10 +40,10 @@ export class GerbilApp {
this.logManager this.logManager
); );
this.binaryService = new BinaryService( this.binaryManager = new BinaryManager(
this.logManager, this.logManager,
this.koboldManager, this.koboldManager,
this.hardwareService this.hardwareManager
); );
this.sillyTavernManager = new SillyTavernManager( this.sillyTavernManager = new SillyTavernManager(
@ -54,8 +54,8 @@ export class GerbilApp {
this.ipcHandlers = new IPCHandlers( this.ipcHandlers = new IPCHandlers(
this.koboldManager, this.koboldManager,
this.configManager, this.configManager,
this.hardwareService, this.hardwareManager,
this.binaryService, this.binaryManager,
this.logManager, this.logManager,
this.sillyTavernManager this.sillyTavernManager
); );

View file

@ -3,22 +3,22 @@ import type { KoboldCppManager } from '@/main/managers/KoboldCppManager';
import type { ConfigManager } from '@/main/managers/ConfigManager'; import type { ConfigManager } from '@/main/managers/ConfigManager';
import type { LogManager } from '@/main/managers/LogManager'; import type { LogManager } from '@/main/managers/LogManager';
import type { SillyTavernManager } from '@/main/managers/SillyTavernManager'; import type { SillyTavernManager } from '@/main/managers/SillyTavernManager';
import { HardwareService } from '@/main/services/HardwareService'; import { HardwareManager } from '@/main/managers/HardwareManager';
import { BinaryService } from '@/main/services/BinaryService'; import { BinaryManager } from '@/main/managers/BinaryManager';
export class IPCHandlers { export class IPCHandlers {
private koboldManager: KoboldCppManager; private koboldManager: KoboldCppManager;
private configManager: ConfigManager; private configManager: ConfigManager;
private logManager: LogManager; private logManager: LogManager;
private sillyTavernManager: SillyTavernManager; private sillyTavernManager: SillyTavernManager;
private hardwareService: HardwareService; private hardwareManager: HardwareManager;
private binaryService: BinaryService; private binaryManager: BinaryManager;
constructor( constructor(
koboldManager: KoboldCppManager, koboldManager: KoboldCppManager,
configManager: ConfigManager, configManager: ConfigManager,
hardwareService: HardwareService, hardwareManager: HardwareManager,
binaryService: BinaryService, binaryManager: BinaryManager,
logManager: LogManager, logManager: LogManager,
sillyTavernManager: SillyTavernManager sillyTavernManager: SillyTavernManager
) { ) {
@ -26,8 +26,8 @@ export class IPCHandlers {
this.configManager = configManager; this.configManager = configManager;
this.logManager = logManager; this.logManager = logManager;
this.sillyTavernManager = sillyTavernManager; this.sillyTavernManager = sillyTavernManager;
this.hardwareService = hardwareService; this.hardwareManager = hardwareManager;
this.binaryService = binaryService; this.binaryManager = binaryManager;
} }
private async launchKoboldCppWithCustomFrontends(args: string[] = []) { private async launchKoboldCppWithCustomFrontends(args: string[] = []) {
@ -93,30 +93,30 @@ export class IPCHandlers {
this.koboldManager.selectInstallDirectory() this.koboldManager.selectInstallDirectory()
); );
ipcMain.handle('kobold:detectGPU', () => this.hardwareService.detectGPU()); ipcMain.handle('kobold:detectGPU', () => this.hardwareManager.detectGPU());
ipcMain.handle('kobold:detectCPU', () => this.hardwareService.detectCPU()); ipcMain.handle('kobold:detectCPU', () => this.hardwareManager.detectCPU());
ipcMain.handle('kobold:detectGPUCapabilities', () => ipcMain.handle('kobold:detectGPUCapabilities', () =>
this.hardwareService.detectGPUCapabilities() this.hardwareManager.detectGPUCapabilities()
); );
ipcMain.handle('kobold:detectGPUMemory', () => ipcMain.handle('kobold:detectGPUMemory', () =>
this.hardwareService.detectGPUMemory() this.hardwareManager.detectGPUMemory()
); );
ipcMain.handle('kobold:detectROCm', () => ipcMain.handle('kobold:detectROCm', () =>
this.hardwareService.detectROCm() this.hardwareManager.detectROCm()
); );
ipcMain.handle('kobold:detectBackendSupport', () => ipcMain.handle('kobold:detectBackendSupport', () =>
this.binaryService.detectBackendSupport() this.binaryManager.detectBackendSupport()
); );
ipcMain.handle( ipcMain.handle(
'kobold:getAvailableBackends', 'kobold:getAvailableBackends',
(_, includeDisabled = false) => (_, includeDisabled = false) =>
this.binaryService.getAvailableBackends(includeDisabled) this.binaryManager.getAvailableBackends(includeDisabled)
); );
ipcMain.handle('kobold:getPlatform', () => process.platform); ipcMain.handle('kobold:getPlatform', () => process.platform);

View file

@ -1,7 +1,7 @@
import { join, dirname } from 'path'; import { join, dirname } from 'path';
import { LogManager } from '@/main/managers/LogManager'; import { LogManager } from '@/main/managers/LogManager';
import type { KoboldCppManager } from '@/main/managers/KoboldCppManager'; import type { KoboldCppManager } from '@/main/managers/KoboldCppManager';
import type { HardwareService } from '@/main/services/HardwareService'; import type { HardwareManager } from '@/main/managers/HardwareManager';
import type { BackendOption } from '@/types'; import type { BackendOption } from '@/types';
import { pathExists } from '@/utils/fs'; import { pathExists } from '@/utils/fs';
@ -14,21 +14,21 @@ export interface BackendSupport {
cuda: boolean; cuda: boolean;
} }
export class BinaryService { export class BinaryManager {
private backendSupportCache = new Map<string, BackendSupport>(); private backendSupportCache = new Map<string, BackendSupport>();
private availableBackendsCache = new Map<string, BackendOption[]>(); private availableBackendsCache = new Map<string, BackendOption[]>();
private logManager: LogManager; private logManager: LogManager;
private koboldManager: KoboldCppManager; private koboldManager: KoboldCppManager;
private hardwareService: HardwareService; private hardwareManager: HardwareManager;
constructor( constructor(
logManager: LogManager, logManager: LogManager,
koboldManager: KoboldCppManager, koboldManager: KoboldCppManager,
hardwareService: HardwareService hardwareManager: HardwareManager
) { ) {
this.logManager = logManager; this.logManager = logManager;
this.koboldManager = koboldManager; this.koboldManager = koboldManager;
this.hardwareService = hardwareService; this.hardwareManager = hardwareManager;
} }
private async detectBackendSupportFromPath( private async detectBackendSupportFromPath(
@ -113,9 +113,9 @@ export class BinaryService {
const [currentBinaryInfo, hardwareCapabilities, cpuCapabilities] = const [currentBinaryInfo, hardwareCapabilities, cpuCapabilities] =
await Promise.all([ await Promise.all([
this.koboldManager.getCurrentBinaryInfo(), this.koboldManager.getCurrentBinaryInfo(),
this.hardwareService.detectGPUCapabilities(), this.hardwareManager.detectGPUCapabilities(),
includeDisabled includeDisabled
? this.hardwareService.detectCPU() ? this.hardwareManager.detectCPU()
: Promise.resolve(null), : Promise.resolve(null),
]); ]);

View file

@ -12,7 +12,7 @@ import type {
} from '@/types/hardware'; } from '@/types/hardware';
import { spawn } from 'child_process'; import { spawn } from 'child_process';
export class HardwareService { export class HardwareManager {
private cpuCapabilitiesCache: CPUCapabilities | null = null; private cpuCapabilitiesCache: CPUCapabilities | null = null;
private basicGPUInfoCache: BasicGPUInfo | null = null; private basicGPUInfoCache: BasicGPUInfo | null = null;
private gpuCapabilitiesCache: GPUCapabilities | null = null; private gpuCapabilitiesCache: GPUCapabilities | null = null;