/** * SessionConfigService — owns the "write side" of per-session agent settings * (model override, thinking level, reasoning level, working directory). * * Previously these lived as four sibling methods on `AgentService`: * - `patchSessionAgentConfig` (96 lines of validation + persistence) * - `applyAutomationWorkingDirectory` (automation working dir update) * - `applyAutomationModelOverride` (automation model update before session creation) * - `clearAutomationWorkingDirectoryOverride` (private helper) * - `clearSessionModelOverride` (private helper) * * Extracted so `AgentService` no longer mixes "session bag" concerns with * "session config write" concerns, and so future additions to the patch API * (e.g. new per-session overrides) only touch this file. */ import type { Config } from '../../config/schema.js'; import type { SessionConfigStore, SessionStore } from '../../session/index.js'; import type { AgentInstanceGateway } from '../agent-instance-gateway.js'; import type { ModelManager } from '../models/index.js'; export interface SessionConfigServiceOptions { sessionStore: SessionStore; sessionConfigStore: SessionConfigStore; modelManager: ModelManager; agentManager: AgentInstanceGateway; /** Effective config snapshot accessor. */ getConfig: () => Config | undefined; } export interface PatchSessionAgentConfigInput { thinkingLevel?: string; model?: string | null; /** Preferred activity-detail field. `null` clears the session override. */ activityDetailLevel?: string | null; /** @deprecated Use activityDetailLevel. */ reasoningLevel?: string | null; verboseLevel?: string; workingDirectory?: string; responseLanguage?: string | null; } export interface PatchSessionAgentConfigResult { ok: boolean; error?: string; } export declare class SessionConfigService { private readonly opts; constructor(opts: SessionConfigServiceOptions); /** * Apply a partial patch (model / thinking / reasoning / working directory) to * a session's persisted config. Returns `{ ok: false, error }` on the first * invalid field — earlier fields that succeeded are NOT rolled back, matching * the previous behaviour. */ patch(sessionKey: string, partial: PatchSessionAgentConfigInput): Promise; /** * Sync persisted session working directory for an automation run. Runs may * change when the automation is edited; an empty/missing input clears the * override so the session uses the effective agent default. */ applyAutomationWorkingDirectory(sessionKey: string, workingDirectory: string | undefined): Promise; /** * Persist an automation model override before the direct turn creates/hydrates * the AgentSession. Unlike the user-facing patch path, this must not call * `agentManager.setModelForSession`, because the automation session usually * does not exist yet. */ applyAutomationModelOverride(sessionKey: string, model: string | undefined): Promise; /** * Clear the session's model override (back to agent default). Used both by * {@link patch} and by `AgentService.resetSessionModelToAgentDefault`. */ clearModelOverride(sessionKey: string): Promise; private clearAutomationWorkingDirectoryOverride; /** * Apply the workingDirectory branch of `patch`. Returns the next-step result * (`ok: true` to keep going, `ok: false, error` to short-circuit the patch). * * Working directory has the strictest semantics: once a session has any * messages, it cannot move to a different directory — only re-setting the * same path is idempotent. */ private patchWorkingDirectory; }