import { Disposable } from "../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../base/common/observable.js"; import { IConfigurationService } from "../../../../platform/configuration/common/configuration.service.js"; import { ILogService } from "../../../../platform/log/common/log.service.js"; import { IStorageService } from "../../../../platform/storage/common/storage.service.js"; import { ILanguageModelChatMetadataAndIdentifier, type IModelConfigurationAccess } from "../../../../workbench/contrib/chat/common/languageModels.js"; import { IModelPickerComparison } from "../../../../workbench/contrib/chat/browser/widget/input/modelPicker/modelPickerComparison.js"; import { RestoredModelReason } from "../../../../workbench/contrib/chat/common/modelSelection.js"; import { ISessionsProvidersService } from "../../../services/sessions/browser/sessionsProvidersService.service.js"; import { ChatModelSource, ISessionType } from "../../../services/sessions/common/session.js"; import { IActiveSession } from "../../../services/sessions/common/sessionsManagement.js"; import { ISessionModelSelectionState } from "./sessionModelPickerState.js"; import { ISessionModelSelection } from "./sessionModelSelection.service.js"; /** How the controller records a model the chat already has. */ export declare function restoreReasonForSource(source: ChatModelSource | undefined): RestoredModelReason; export interface IResolvedSessionComparisonModel { readonly sessionType: ISessionType; readonly model: ILanguageModelChatMetadataAndIdentifier; } /** * Model selection for the Agents Window, on top of the shared * {@link ChatInputModelSelectionController}. Turns the active session and its provider into the * runtime the controller expects, and its decisions back into a provider write and picker state. * Precedence lives in the controller, so the two windows cannot drift on it. * * Mostly translation. What is left here is when a conversation counts as seeded, and when to wait * for an unpublished model rather than write a stand-in through to a backend. */ export declare class SessionModelSelection extends Disposable implements ISessionModelSelection { private readonly _session; private readonly _sessionsProvidersService; private readonly _storageService; private readonly _configurationService; readonly _serviceBrand: undefined; private readonly _state; readonly state: IObservable; readonly modelConfiguration: IModelConfigurationAccess | undefined; readonly comparison: IModelPickerComparison | undefined; readonly comparisonBusy: IObservable | undefined; private readonly _providerListener; private readonly _modelConfigurationListener; private readonly _onDidChangeModelConfiguration; private _modelConfigurationAccess; private readonly _diagnostics; private readonly _controller; /** * What this input knows about each conversation it has bound. The controller only ever reaches * the bound conversation's record, so one chat's model selection cannot be applied to another. */ private readonly _conversations; private readonly _unboundConversation; private _activeSession; private _activeProvider; private _listenedProvider; private _models; private _modelTarget; private _boundSessionKey; private _boundConversationKey; /** Read from the chat, not the session: session status aggregates across peer chats. */ private _chatIsEmpty; /** The conversation's own model is unknown but presumed to exist: show a selection, never write it. */ private _displayOnly; constructor(_session: IObservable, options: { readonly modelConfiguration?: boolean; readonly fallbackModelConfiguration?: IModelConfigurationAccess; readonly comparison?: IModelPickerComparison; readonly comparisonBusy?: IObservable; }, _sessionsProvidersService: ISessionsProvidersService, _storageService: IStorageService, _configurationService: IConfigurationService, logService: ILogService); selectModel(modelIdentifier: string, isUserAction?: boolean): boolean; getComparisonModels(): readonly ILanguageModelChatMetadataAndIdentifier[]; resolveComparisonModel(modelIdentifier: string): IResolvedSessionComparisonModel | undefined; private _getComparisonModels; private _createRuntime; /** Unreachable while another chat is bound, so one chat's selection cannot reach another. */ private _conversation; private _refresh; /** * Hands the session's state to the controller through the same entry points Workbench chat * uses: seed a newly bound conversation, follow the conversation's own model when it changes * underneath us, and reconcile against the pool that was just published. */ private _drive; /** Whether the controller is on a model this session's pool actually offers. */ private _isShowingSelectableModel; /** * Whether the chat's model, or whether it counts as the chat's own, differs from what we hold. * Our own echo matches on both, since the source came from the reason we still hold. */ private _conversationSelectionChanged; /** Adopts the model the chat is on, telling the controller whether it counts as a choice. */ private _claimChatModel; private _pushModelToProvider; private _publish; /** The remembered preference, migrating the legacy key forward the first time it is seen. */ private _getRememberedModel; private _setProvider; }