130
: undefined;
131
}
133
>
export const enum ModelSelectionReason {
134
>
ConfiguredDefault = 'configuredDefault',
135
>
FirstAvailable = 'firstAvailable',
136
>
NoModels = 'noModels',
137
>
ProgrammaticSelection = 'programmaticSelection',
138
>
Remembered = 'remembered',
139
>
RemovedModelFallback = 'removedModelFallback',
140
>
SessionRestore = 'sessionRestore',
141
>
NewChatRepush = 'newChatRepush',
142
>
UserSelection = 'userSelection',
143
>
}
144
>
145
>
export type ModelSelectionApplyReason = Exclude<ModelSelectionReason, ModelSelectionReason.NoModels>;
146
>
147
>
export function isAuthoritativeModelSelectionReason(reason: ModelSelectionApplyReason | undefined): boolean {
148
return reason === ModelSelectionReason.ProgrammaticSelection
149
|| reason === ModelSelectionReason.SessionRestore
150
|| reason === ModelSelectionReason.UserSelection;
151
}
153
>
export interface IPendingModelSelection {
154
>
readonly reference: string;
155
>
}
156
>
157
>
export type InitialModelSelectionResult =
158
>
| { readonly kind: 'none' }
159
>
| { readonly kind: 'pending'; readonly selection: IPendingModelSelection }
160
>
| { readonly kind: 'apply'; readonly model: ILanguageModelChatMetadataAndIdentifier; readonly reason: ModelSelectionApplyReason };
161
>
162
>
export interface IInitialModelSelectionInput {
163
>
readonly configuredModel: ILanguageModelChatMetadataAndIdentifier | undefined;
164
>
readonly desiredModelResolution: ModelIdentifierResolution;
165
>
readonly desiredReason: ModelSelectionReason.SessionRestore | ModelSelectionReason.Remembered;
166
>
readonly fallbackModel: ILanguageModelChatMetadataAndIdentifier | undefined;
167
>
readonly fallbackReason: ModelSelectionReason.FirstAvailable | ModelSelectionReason.RemovedModelFallback;
168
>
}
169
>
170
>
/** Applies the shared configured, desired, pending, then fallback precedence. */
171
>
export function resolveInitialModelSelection(input: IInitialModelSelectionInput): InitialModelSelectionResult {
172
if (input.configuredModel) {
173
return { kind: 'apply', model: input.configuredModel, reason: ModelSelectionReason.ConfiguredDefault };