/**
 * AgentSession - Core abstraction for agent lifecycle and session management.
 *
 * The historical import path is preserved here as a facade. Responsibilities are
 * implemented in sibling modules by lifecycle area so each authored source file
 * stays below the repository file-length gate.
 */
import { createSessionAsyncJobManager } from "./async/session-manager.js";
import { installAgentSessionAccessors } from "./agent-session-accessors.js";
import { agentSessionAutoCompactionMethods } from "./agent-session-auto-compaction.js";
import { agentSessionBashMethods } from "./agent-session-bash.js";
import { agentSessionCompactionMethods } from "./agent-session-compaction.js";
import { agentSessionEventsMethods } from "./agent-session-events.js";
import { agentSessionExportMethods } from "./agent-session-export.js";
import { agentSessionExtensionBindingsMethods } from "./agent-session-extension-bindings.js";
import { agentSessionMessageQueueMethods } from "./agent-session-message-queue.js";
import { agentSessionModelsMethods } from "./agent-session-models.js";
import { agentSessionPromptMethods } from "./agent-session-prompt.js";
import { agentSessionRetryMethods } from "./agent-session-retry.js";
import { agentSessionStateMethods } from "./agent-session-state.js";
import { agentSessionToolHooksMethods } from "./agent-session-tool-hooks.js";
import { agentSessionToolRegistryMethods } from "./agent-session-tool-registry.js";
import { agentSessionTreeMethods } from "./agent-session-tree.js";
export { parseSkillBlock } from "./agent-session-skill-block.js";
export class AgentSession {
    constructor(config) {
        this._fallbackAttemptedKeys = new Set();
        this._eventListeners = [];
        this._agentEventQueue = Promise.resolve();
        this._steeringMessages = [];
        this._followUpMessages = [];
        this._interruptDeliveryQueue = Promise.resolve();
        this._pendingInterruptDeliveries = 0;
        this._activeInterruptQueueHold = undefined;
        this._activeInterruptAbortMessage = undefined;
        this._pendingNextTurnMessages = [];
        this._compactionAbortController = undefined;
        this._autoCompactionAbortController = undefined;
        this._overflowRecoveryAttempted = false;
        this._pendingPostCompactionContinuation = undefined;
        this._postCompactionContinuationToken = 0;
        this._lengthContinuationAttempts = 0;
        this._outputBudgetErrorContinuationAttempts = 0;
        this._branchSummaryAbortController = undefined;
        this._retryAbortController = undefined;
        this._retryAttempt = 0;
        this._retryPromise = undefined;
        this._retryResolve = undefined;
        this._bashAbortController = undefined;
        this._pendingBashMessages = [];
        this._turnIndex = 0;
        this._baseToolDefinitions = new Map();
        this._extensionMode = "print";
        this._toolRegistry = new Map();
        this._toolDefinitions = new Map();
        this._toolPromptSnippets = new Map();
        this._toolPromptGuidelines = new Map();
        this._baseSystemPrompt = "";
        this._lastAssistantMessage = undefined;
        this.agent = config.agent;
        this.sessionManager = config.sessionManager;
        this.settingsManager = config.settingsManager;
        this._scopedModels = config.scopedModels ?? [];
        this._fallbackModels = config.fallbackModels ?? [];
        this._resourceLoader = config.resourceLoader;
        this._customTools = config.customTools ?? [];
        this._cwd = config.cwd;
        this._modelRegistry = config.modelRegistry;
        this._extensionRunnerRef = config.extensionRunnerRef;
        this._initialActiveToolNames = config.initialActiveToolNames;
        this._allowedToolNames = config.allowedToolNames ? new Set(config.allowedToolNames) : undefined;
        this._excludedToolNames = config.excludedToolNames ? new Set(config.excludedToolNames) : undefined;
        this._baseToolsOverride = config.baseToolsOverride;
        this._sessionStartEvent = config.sessionStartEvent ?? { type: "session_start", reason: "startup" };
        this._orchestrationContext = config.orchestrationContext;
        const internals = this;
        const asyncJobManagerHandle = createSessionAsyncJobManager(internals);
        this._asyncJobManager = asyncJobManagerHandle.manager;
        this._asyncJobManagerSessionId = asyncJobManagerHandle.sessionId;
        internals._handleAgentEvent = internals._handleAgentEvent.bind(this);
        this._unsubscribeAgent = this.agent.subscribe(internals._handleAgentEvent);
        internals._installAgentToolHooks();
        internals._installAgentNextTurnRefresh();
        internals._buildRuntime({
            activeToolNames: this._initialActiveToolNames,
            includeAllExtensionTools: true,
        });
    }
}
installAgentSessionAccessors(AgentSession.prototype);
Object.assign(AgentSession.prototype, agentSessionToolHooksMethods, agentSessionEventsMethods, agentSessionStateMethods, agentSessionPromptMethods, agentSessionMessageQueueMethods, agentSessionModelsMethods, agentSessionCompactionMethods, agentSessionAutoCompactionMethods, agentSessionExtensionBindingsMethods, agentSessionToolRegistryMethods, agentSessionRetryMethods, agentSessionBashMethods, agentSessionTreeMethods, agentSessionExportMethods);
//# sourceMappingURL=agent-session.js.map