import { mkdir, readFile, writeFile } from 'node:fs/promises';
import { dirname, join } from 'node:path';
export class GlobalRemoteControlSettingsStore {
    filePath;
    constructor(agentDir) {
        this.filePath = join(agentDir, 'settings.json');
    }
    async load() {
        try {
            const raw = JSON.parse(await readFile(this.filePath, 'utf-8'));
            return raw.remoteControl ?? {};
        }
        catch {
            return {};
        }
    }
    async save(remoteControl) {
        let raw = {};
        try {
            raw = JSON.parse(await readFile(this.filePath, 'utf-8'));
        }
        catch {
            raw = {};
        }
        raw.remoteControl = {
            enabled: remoteControl.enabled ?? false,
            provider: remoteControl.provider
        };
        await mkdir(dirname(this.filePath), { recursive: true });
        await writeFile(this.filePath, JSON.stringify(raw, null, 2) + '\n', 'utf-8');
    }
}
//# sourceMappingURL=global-settings.js.map