import { ChatAgentLocation, ChatModeKind } from "../../../common/constants.js"; import { ILanguageModelChatMetadata, ILanguageModelChatMetadataAndIdentifier } from "../../../common/languageModels.js"; import { URI } from "../../../../../../base/common/uri.js"; /** * Whether the surface can run this model at all, given the mode it is in and where it is shown. * Supplied by the surface so these rules do not have to be restated in terms of its inputs. */ export type IsModelSupportedHere = (model: ILanguageModelChatMetadataAndIdentifier) => boolean; /** * Filter models based on session type. * When a session has a specific type (and it's not 'local'), only models targeting that * session type are returned. Otherwise, general-purpose models are returned. * * `isUserSelectable` defaults to `true` when omitted: only an explicit `false` hides * the model from the picker and this model-selection flow. */ export declare function filterModelsForSession(models: ILanguageModelChatMetadataAndIdentifier[], sessionType: string | undefined, currentModeKind: ChatModeKind, location: ChatAgentLocation): ILanguageModelChatMetadataAndIdentifier[]; /** * Check if a model is suitable for the current chat mode (e.g., agent mode requires tool calling). */ export declare function isModelSupportedForMode(model: ILanguageModelChatMetadataAndIdentifier, currentModeKind: ChatModeKind): boolean; /** * Check if a model is suitable for inline chat (editor inline) usage. */ export declare function isModelSupportedForInlineChat(model: ILanguageModelChatMetadataAndIdentifier, location: ChatAgentLocation): boolean; /** * Check if any models in the pool target a specific session type. */ export declare function hasModelsTargetingSession(allModels: ILanguageModelChatMetadataAndIdentifier[], sessionType: string | undefined): boolean; /** * Check if a model is valid for the current session's model pool. * If the session has targeted models, the model must target that session type. * If no models target this session, the model must not be session-specific. */ export declare function isModelValidForSession(model: ILanguageModelChatMetadataAndIdentifier, allModels: ILanguageModelChatMetadataAndIdentifier[], sessionType: string | undefined): boolean; /** * Reconstructs the "Manage Models" identifier that an agent-host copy of an * extension-provided BYOK model is toggled under, or `undefined` when the model * is not such a copy. Re-exported from the shared `ILanguageModelChatMetadata` * namespace (which also backs the `common` model-visibility layer) so picker and * management code reconstruct the identifier the same way. */ export declare const getAgentHostByokManageModelsIdentifier: typeof ILanguageModelChatMetadata.getAgentHostByokManageModelsIdentifier; /** * Whether a model should be hidden from the picker given the user's Manage Models * visibility toggles. Matches the model by its own identifier and, for agent-host * copies of extension BYOK models, additionally by the reconstructed original * identifier (see {@link getAgentHostByokManageModelsIdentifier}) — which includes * any user-configured provider group carried across the bridge — so a BYOK model * hidden in Manage Models is also hidden in the agent-host picker. */ export declare function isModelHiddenInPicker(model: ILanguageModelChatMetadataAndIdentifier, isModelHidden: (identifier: string) => boolean): boolean; /** * The model the Switch to Next Model commands move to: the one after * `currentIdentifier` in `models`, wrapping around, or the first when the * current model is not in the list. When `pinnedModelIds` is given, only the * pinned models are cycled, in pin order. */ export declare function getNextModelInCycle(models: readonly ILanguageModelChatMetadataAndIdentifier[], currentIdentifier: string | undefined, pinnedModelIds?: readonly string[]): ILanguageModelChatMetadataAndIdentifier | undefined; /** * Whether the selected model carried by the shared, session-type-agnostic untitled draft * (`chat.untitledInputState`) must be dropped before the draft is applied to an empty session * that is being opened. * * The draft is shared across all session types, so its `selectedModel` can belong to a * different pool in either direction — e.g. a `copilot/*` model leaking into an agent-host * session, or an `agent-host-*` model leaking into a general/local session. Applying such a * cross-pool model while the session is opening lets the sync resolve it to (and persist) a * wrong default over the destination pool's persisted model. Dropped when present but not valid * for `sessionType`; an in-pool draft model is kept. See * `chatInputPart._getPersistedEmptyInputState`. */ export declare function shouldDropAgnosticDraftModel(draftModel: ILanguageModelChatMetadataAndIdentifier | undefined, allModels: ILanguageModelChatMetadataAndIdentifier[], sessionType: string | undefined): boolean; /** * Whether the input should treat a session as a brand-new conversation, which is what unlocks the * shared new-chat draft, the default mode/permission level, and `chat.defaultModel`. * * `hasNoRequests` is sampled when the input binds, and a contributed session's requests load after * that — so on its own it reports a started agent-host session as new. A contributed session's * resource keeps its `untitled-` path until the session is started, so it stays accurate * regardless of load timing. Local sessions have no such marker and rely on `hasNoRequests`. */ export declare function isNewConversation(sessionResource: URI, hasNoRequests: boolean): boolean; /** * Whether a chat input counts as bound to a conversation that is already underway. * * An unbound input counts as started: a session switch clears the bound model for the duration of * an async load while the outgoing session type is still published, and a notice must not surface * in that window. Only a model seen to be request-free is unstarted. */ export declare function isSessionStarted(hasBoundModel: boolean, hasRequests: boolean): boolean; /** * Whether the persisted per-session-type model should be restored (into the picker) when the * input switches to a session. * * True only for a FRESH untitled own-pool session — one with no incoming `selectedModel` in its * own input state. A session that already carries its own model (a transferred/handoff or * startup-restored draft) keeps that model in-memory and is left alone. */ export declare function shouldRestorePerTypeModelOnSessionSwitch(isEmpty: boolean, sessionOwnsPool: boolean, hadIncomingModel: boolean): boolean; /** * Find a model in `pool` that matches `previous` by id, then family, then * name (case-insensitive). Used to carry a selection across model pools * (e.g. `copilot/claude-sonnet-4.6` → `agent-host-copilotcli:claude-sonnet-4.6`). * Returns `undefined` when no candidate matches. * Candidates that would change which account is billed are never matches. */ export declare function findBestMatchingModel(previous: ILanguageModelChatMetadataAndIdentifier | undefined, pool: readonly ILanguageModelChatMetadataAndIdentifier[]): ILanguageModelChatMetadataAndIdentifier | undefined; /** * Determines whether the current model should be reset because it is no longer * compatible with the current mode, session, or availability. * * Returns true if the model should be reset to default. */ export declare function shouldResetModelToDefault(currentModel: ILanguageModelChatMetadataAndIdentifier | undefined, availableModels: ILanguageModelChatMetadataAndIdentifier[], isModelSupportedHere: IsModelSupportedHere, allModels: ILanguageModelChatMetadataAndIdentifier[], sessionType: string | undefined): boolean; /** * Determines whether a model from a sync state should be applied to the current view. * * Returns an action: * - `'keep'` - the view already has the same model; no change needed. * - `'apply'` - the state model is valid; the caller should switch to it. * - `'default'` - the state model is incompatible (wrong session pool, unsupported * mode, or missing inline-chat capability); the caller should fall * back to the default model for the current location. * * @param isModelSupportedHere Optional because some callers (e.g. unit tests, or * code paths that only care about session-pool validation) cannot say. When * omitted, only session-pool membership is validated. */ export declare function resolveModelFromSyncState(stateModel: ILanguageModelChatMetadataAndIdentifier, currentModel: ILanguageModelChatMetadataAndIdentifier | undefined, allModels: ILanguageModelChatMetadataAndIdentifier[], sessionType: string | undefined, isModelSupportedHere?: IsModelSupportedHere): { action: "keep" | "apply" | "default"; }; /** * Merges live models with cached models per-vendor, evicting cache for vendors no longer contributed. * * - `resolvedVendors`: vendors that have finished resolving. An empty live list for these is authoritative * (e.g. BYOK key removed), so their cache is dropped. * - Copilot is the exception: its models are gated on an async token that can resolve slower than fast/local BYOK * providers, so an early empty resolution is transient. Keeping its cache avoids resetting (and persisting) a * restored Copilot selection to a BYOK default, which also preserves the selection across sign-out/in (see #321037). * - An agent-host vendor is judged on models of its OWN: it also publishes bridged copies of the workbench's * BYOK models, and counting those as live evicts the cache mid-publication and persists the gap. * - When nothing is contributed yet and there are no live models (startup / reload), the full cache is returned to * avoid flickering the picker to empty. */ export declare function mergeModelsWithCache(liveModels: ILanguageModelChatMetadataAndIdentifier[], cachedModels: ILanguageModelChatMetadataAndIdentifier[], contributedVendors: Set, resolvedVendors?: ReadonlySet): ILanguageModelChatMetadataAndIdentifier[]; /** * Determines whether the currently selected model should be reset to default * when the language model list changes. * * Returns true if the model should be reset to default (i.e., the selected model * is no longer in the available models list). */ export declare function shouldResetOnModelListChange(currentModelId: string | undefined, availableModels: ILanguageModelChatMetadataAndIdentifier[]): boolean; /** * The selection a request should be sent with, given what an inline request editor had chosen. * * Resubmitting an edited request must use the picker the user actually chose in. That editor is * torn down before the request is built, so its selection is captured up front and always wins * * `edited` is `undefined` when no inline edit is in flight, in which case the composer is correct. */ export declare function resolveEditedRequestSelection(edited: T | undefined, composer: T): T;