feat(config): persist config.patch updates atomically

This commit is contained in:
William Valentin
2026-02-15 22:03:21 -08:00
parent c314e0f067
commit 0220ec10dd
13 changed files with 205 additions and 11 deletions
+8 -1
View File
@@ -1,4 +1,5 @@
import type { Config } from '../config/index.js';
import { persistConfig } from '../config/index.js';
import type { Lifecycle } from './lifecycle.js';
import type { ToolRegistry, ToolExecutor } from '../tools/index.js';
import type { AgentOrchestrator } from '../backends/index.js';
@@ -279,6 +280,7 @@ export function initPairingManager(config: Config, store?: PairingStore): Pairin
export interface GatewayDeps {
config: Config;
configPath?: string;
sessionManager: SessionManager;
modelRouter: ModelRouter;
systemPrompt: string;
@@ -295,7 +297,7 @@ export interface GatewayDeps {
}
export function createGateway(deps: GatewayDeps): GatewayServer {
const { config, sessionManager, modelRouter, systemPrompt, toolRegistry, toolExecutor, channelRegistry, pairingManager, lifecycle, getChannelAgents } = deps;
const { config, configPath, sessionManager, modelRouter, systemPrompt, toolRegistry, toolExecutor, channelRegistry, pairingManager, lifecycle, getChannelAgents } = deps;
const gateway = new GatewayServer({
port: config.server.port,
@@ -324,6 +326,11 @@ export function createGateway(deps: GatewayDeps): GatewayServer {
routingPolicy: deps.routingPolicy,
uiDir: resolve(import.meta.dirname, '../gateway/ui'),
config,
persistConfig: configPath
? async (nextConfig) => {
persistConfig(configPath, nextConfig);
}
: undefined,
channelRegistry,
pairingManager,
memoryStore: deps.memoryStore,