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
+6 -2
View File
@@ -54,7 +54,11 @@ export interface DaemonContext {
browserManager?: BrowserManager;
}
export async function startDaemon(config: Config): Promise<DaemonContext> {
export interface StartDaemonOptions {
configPath?: string;
}
export async function startDaemon(config: Config, options?: StartDaemonOptions): Promise<DaemonContext> {
// ── Log level ──
setLogLevel(config.log_level);
@@ -144,7 +148,7 @@ export async function startDaemon(config: Config): Promise<DaemonContext> {
let channelAgents: ReturnType<typeof createMessageRouter>['agents'] | null = null;
const gateway = createGateway({
config, sessionManager, modelRouter, systemPrompt, toolRegistry, toolExecutor,
config, configPath: options?.configPath, sessionManager, modelRouter, systemPrompt, toolRegistry, toolExecutor,
channelRegistry, pairingManager, lifecycle, memoryStore,
getChannelAgents: () => channelAgents, commandRegistry, intentRegistry, routingPolicy,
});
+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,