feat: implement model persistence with per-session overrides

- Add session_config SQLite table for per-session settings
- Update routing to support session override → agent config → global default resolution chain
- Upgrade WebChat SessionBridge from NativeAgent to AgentOrchestrator
- Add /model, /local, /cloud commands to Telegram adapter
- Add /model command to WebChat gateway handlers
- Clear session overrides on /reset command
- Pass memoryStore and config through to SessionBridge
- Add comprehensive tests for all new functionality

Fixes model persistence bug where TUI model changes didn't affect WebChat/Telegram sessions. Now:
- TUI /model sets global default (persists across restarts, affects all new sessions)
- WebChat/Telegram /model sets session override (only that conversation, cleared on /reset)
- WebChat sessions gain AgentOrchestrator features (delegation, compaction, memory)
This commit is contained in:
William Valentin
2026-02-11 21:51:38 -08:00
parent b0092c8284
commit a8a2c59313
12 changed files with 1175 additions and 46 deletions
+33
View File
@@ -8,6 +8,9 @@ export interface Session {
getHistory(): Message[];
clear(): void;
replaceHistory(messages: Message[]): void;
getConfig(key: string): string | undefined;
setConfig(key: string, value: string): void;
deleteConfig(key: string): void;
}
export class ManagedSession implements Session {
@@ -64,6 +67,18 @@ export class ManagedSession implements Session {
setHistory(messages: Message[]): void {
this.history = [...messages];
}
getConfig(key: string): string | undefined {
return this.store.getSessionConfig(this.id, key);
}
setConfig(key: string, value: string): void {
this.store.setSessionConfig(this.id, key, value);
}
deleteConfig(key: string): void {
this.store.deleteSessionConfig(this.id, key);
}
}
export class SessionManager {
@@ -129,4 +144,22 @@ export class SessionManager {
this.sessions.delete(id);
}
}
/** Get a session config value. */
getSessionConfig(frontend: string, userId: string, key: string): string | undefined {
const session = this.getSession(frontend, userId);
return session.getConfig(key);
}
/** Set a session config value. */
setSessionConfig(frontend: string, userId: string, key: string, value: string): void {
const session = this.getSession(frontend, userId);
session.setConfig(key, value);
}
/** Delete a session config value. */
deleteSessionConfig(frontend: string, userId: string, key: string): void {
const session = this.getSession(frontend, userId);
session.deleteConfig(key);
}
}