/** * The settings-driven live-driver switch: owns the active driver generation * and retires old ones on a settings change, without a plugin reload. * * Toggle OFF (or unload): the retiring generation is DRAINED, not killed — * new rounds are refused (the provider's catch falls back to exec), in-flight * rounds finish on their runtime, idle runtimes are reclaimed at once. * Toggling ON builds the next generation lazily (no process until the first * round). Legacy granularity settings are ignored. * * @module @khorsheed/dsh-local-agent-claude-code — internal, unit-tested directly. */ import type { Context } from '@deepseek-ai/cordis'; import type { SettingsFace } from '@khorsheed/dsh-local-agent'; import type { Config } from './index.ts'; import type { ClaudeEndpointAuth } from './endpoint-auth.ts'; import { ClaudeLiveDriver } from './live-driver.ts'; import type { ClaudeLiveMirrorGranularity } from './live-driver.ts'; /** The resolved live settings (rc.1: volatile row config; 0.1.5: schema defaults ← YAML base ← user layer). */ export interface ClaudeLiveSettings { live: boolean; liveMirrorGranularity: ClaudeLiveMirrorGranularity; /** The configured model, when the card or the YAML base names one. */ model?: string; /** Model identifiers the card has saved before (its input's suggestions). */ recentModels?: readonly string[]; } /** The Cordis-config inputs every driver generation shares. */ type DriverBase = Pick & { liveIdleMs?: number; /** Per-spawn endpoint credential resolver, handed to every driver generation. */ endpoint?: (homeDir: string) => Promise; /** * Per-spawn member model resolver, handed to every driver generation: * answers the member's effective model from its session-level override, the * round's delegation model, and the settings key, in that order. */ model?: (childSessionId: string, delegationModel?: string) => string | undefined; /** Pre-spawn scoped-settings.json model scratch (the shared memory). */ provisionModel?: (homeDir: string, model: string | undefined) => Promise; }; export declare class LiveDriverSwitch { private readonly ctx; private readonly driverBase; private liveOn; private active; /** Retiring generations still draining their in-flight rounds. */ private readonly draining; private readonly unwatch; constructor(ctx: Context, face: SettingsFace, driverBase: DriverBase); /** * Resolve the live driver for one round's member (the provider's call * site). A retiring generation still hosting the member gates the new one — * the round falls back to exec rather than double-loading the same claude * session into two processes. */ readonly resolve: (childSessionId: string) => ClaudeLiveDriver | undefined; /** * The generation currently hosting the member's runtime — the active one, * or a retiring generation still draining it (the model broker retires the * member's runtime through whichever generation owns it on a model switch). */ hostingDriver(childSessionId: string): ClaudeLiveDriver | undefined; /** Mirror the resolved settings into the driver generation. */ private apply; /** Plugin unload: interrupt whatever survives (disposeAll, not drain). */ dispose(): void; } export {}; //# sourceMappingURL=live-switch.d.ts.map