memory settings implementation
This commit is contained in:
30
packages/orchestration-service/src/config/settings.js
Normal file
30
packages/orchestration-service/src/config/settings.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { ORCHESTRATION } = require('@nexusai/shared');
|
||||
|
||||
const SETTINGS_PATH = path.join(__dirname, '../../data/settings.json');
|
||||
|
||||
const DEFAULTS = {
|
||||
recentEpisodeLimit: ORCHESTRATION.RECENT_EPISODE_LIMIT,
|
||||
semanticLimit: ORCHESTRATION.SEMANTIC_LIMIT,
|
||||
scoreThreshold: ORCHESTRATION.SCORE_THRESHOLD,
|
||||
};
|
||||
|
||||
function load() {
|
||||
try {
|
||||
const raw = fs.readFileSync(SETTINGS_PATH, 'utf8');
|
||||
return { ...DEFAULTS, ...JSON.parse(raw) };
|
||||
} catch {
|
||||
return { ...DEFAULTS }; // file doesn't exist yet — use defaults
|
||||
}
|
||||
}
|
||||
|
||||
function save(updates) {
|
||||
const current = load();
|
||||
const next = { ...current, ...updates };
|
||||
fs.mkdirSync(path.dirname(SETTINGS_PATH), { recursive: true });
|
||||
fs.writeFileSync(SETTINGS_PATH, JSON.stringify(next, null, 2));
|
||||
return next;
|
||||
}
|
||||
|
||||
module.exports = { load, save, DEFAULTS };
|
||||
Reference in New Issue
Block a user