/** * @license * Copyright 2025 Qwen * SPDX-License-Identifier: Apache-2.0 */ import type { ChatRecord, Config, GeminiChat } from '@aetherai/aether-core'; import type { AgentSideConnection, PromptRequest, PromptResponse, RequestPermissionRequest, RequestPermissionResponse, SessionUpdate, SetSessionModelRequest, SetSessionModelResponse, SetSessionModeRequest, SetSessionModeResponse } from '@agentclientprotocol/sdk'; import type { LoadedSettings } from '../../config/settings.js'; import type { SessionContext } from './types.js'; /** * Session represents an active conversation session with the AI model. * It uses modular components for consistent event emission: * - HistoryReplayer for replaying past conversations * - ToolCallEmitter for tool-related session updates * - PlanEmitter for todo/plan updates * - SubAgentTracker for tracking sub-agent tool calls */ export declare class Session implements SessionContext { #private; private readonly chat; readonly config: Config; private readonly client; private readonly settings; private pendingPrompt; /** * Tracks the completion of the current prompt so that the next prompt * can await it. This prevents a new prompt from reading chat history * before the previous prompt's tool results have been added — * a race condition that causes malformed history on Windows where * process termination is slow. */ private pendingPromptCompletion; private turn; private readonly runtimeBaseDir; private cronQueue; private cronProcessing; private cronAbortController; private cronCompletion; private readonly historyReplayer; private readonly toolCallEmitter; private readonly planEmitter; private readonly messageEmitter; readonly sessionId: string; constructor(id: string, chat: GeminiChat, config: Config, client: AgentSideConnection, settings: LoadedSettings); getId(): string; getConfig(): Config; /** * Replays conversation history to the client using modular components. * Delegates to HistoryReplayer for consistent event emission. */ replayHistory(records: ChatRecord[]): Promise; cancelPendingPrompt(): Promise; prompt(params: PromptRequest): Promise; sendUpdate(update: SessionUpdate): Promise; sendAvailableCommandsUpdate(): Promise; /** * Requests permission from the client for a tool call. * Used by SubAgentTracker for sub-agent approval requests. */ requestPermission(params: RequestPermissionRequest): Promise; /** * Sets the approval mode for the current session. * Maps ACP approval mode values to core ApprovalMode enum. */ setMode(params: SetSessionModeRequest): Promise; /** * Sets the model for the current session. * Validates the model ID and switches the model via Config. */ setModel(params: SetSessionModelRequest): Promise; /** * Sends a current_mode_update notification to the client. * Called after the agent switches modes (e.g., from exit_plan_mode tool). */ private sendCurrentModeUpdateNotification; private resolveIdeDiffForOutcome; private runTool; debug(msg: string): void; }