@f5-sales-demo/xcsh 21.6.4 → 21.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/config/auto-config.ts +9 -3
- package/src/config/model-registry.ts +24 -6
- package/src/config/model-resolver.ts +18 -6
- package/src/extensibility/extensions/types.ts +5 -1
- package/src/internal-urls/build-info.generated.ts +8 -8
- package/src/modes/acp/acp-agent.ts +3 -1
- package/src/modes/components/auth-link-presenter.ts +10 -0
- package/src/modes/components/context-add-wizard.ts +4 -31
- package/src/modes/components/model-selector.ts +346 -146
- package/src/modes/controllers/selector-controller.ts +55 -8
- package/src/services/xcsh-context.ts +29 -106
- package/src/session/agent-session.ts +1 -1
- package/src/session/session-manager.ts +4 -4
- package/src/thinking.ts +22 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ThinkingLevel } from "@f5-sales-demo/pi-agent-core";
|
|
2
|
-
import {
|
|
2
|
+
import { getSupportedReasoningEfforts, type Model, modelsAreEqual, ReasoningEffort } from "@f5-sales-demo/pi-ai";
|
|
3
3
|
import {
|
|
4
4
|
Container,
|
|
5
5
|
getKeybindings,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
type TUI,
|
|
13
13
|
visibleWidth,
|
|
14
14
|
} from "@f5-sales-demo/pi-tui";
|
|
15
|
-
import type { ModelRegistry } from "../../config/model-registry";
|
|
15
|
+
import type { ModelRegistry, ProviderDiscoveryState, ProviderDiscoveryStatus } from "../../config/model-registry";
|
|
16
16
|
import { getKnownRoleIds, getRoleInfo, MODEL_ROLE_IDS, MODEL_ROLES } from "../../config/model-registry";
|
|
17
17
|
import { resolveModelRoleValue } from "../../config/model-resolver";
|
|
18
18
|
import type { Settings } from "../../config/settings";
|
|
@@ -43,7 +43,7 @@ function getAlphaSearchTokens(query: string): string[] {
|
|
|
43
43
|
return [...normalizeSearchText(query).matchAll(/[a-z]+/g)].map(match => match[0]).filter(token => token.length > 0);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
interface ModelItem {
|
|
46
|
+
export interface ModelItem {
|
|
47
47
|
kind: "provider";
|
|
48
48
|
provider: string;
|
|
49
49
|
id: string;
|
|
@@ -73,23 +73,227 @@ export interface DefaultPickerModelPresentation {
|
|
|
73
73
|
selector: string;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
/** Collapse subscription tiers only in the ordinary picker; explicit --models scopes keep raw access. */
|
|
76
|
+
/** Present every service selector exactly; access tiers are not interchangeable aliases. */
|
|
79
77
|
export function presentModelsForDefaultPicker(
|
|
80
78
|
models: readonly Model[],
|
|
81
|
-
|
|
79
|
+
_explicitlyScoped = false,
|
|
82
80
|
): DefaultPickerModelPresentation[] {
|
|
83
|
-
return models
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
return models
|
|
82
|
+
.filter(model => model.visibility !== "hide")
|
|
83
|
+
.map(model => {
|
|
84
|
+
const selector = `${model.provider}/${model.id}`;
|
|
85
|
+
return { model, displaySelector: selector, selector };
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function getModelSearchText(item: DefaultPickerModelPresentation): string {
|
|
90
|
+
const { model, selector } = item;
|
|
91
|
+
return [model.provider, model.publisher, model.family, model.tier, model.name, model.description, selector]
|
|
92
|
+
.filter(Boolean)
|
|
93
|
+
.join(" ");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getModelDisplayName(model: Model): string {
|
|
97
|
+
const tieredName = [model.family, model.tier].filter(Boolean).join(" ");
|
|
98
|
+
if (tieredName && compactSearchText(tieredName) === compactSearchText(model.name)) return tieredName;
|
|
99
|
+
return model.name;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function getModelPublisher(model: Model): string {
|
|
103
|
+
if (model.publisher) return model.publisher;
|
|
104
|
+
if (model.provider.startsWith("google-")) return "Google";
|
|
105
|
+
if (model.provider === "openai" || model.provider === "openai-codex") return "OpenAI";
|
|
106
|
+
if (model.provider === "anthropic") return "Anthropic";
|
|
107
|
+
return getProviderDisplayName(model.provider);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function getModelFamily(model: Model): string {
|
|
111
|
+
if (model.family) return model.family;
|
|
112
|
+
return (
|
|
113
|
+
model.name.match(/^(?:Gemini\s+\d+(?:\.\d+)?|GPT-\d+(?:\.\d+)?|Claude\s+\S+(?:\s+\d+(?:\.\d+)?)?)/i)?.[0] ??
|
|
114
|
+
model.name
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function modelHierarchyKey(item: ModelItem, includeProvider: boolean): string {
|
|
119
|
+
return [
|
|
120
|
+
includeProvider ? getProviderDisplayName(item.provider) : "",
|
|
121
|
+
getModelPublisher(item.model),
|
|
122
|
+
getModelFamily(item.model),
|
|
123
|
+
]
|
|
124
|
+
.join("\0")
|
|
125
|
+
.toLocaleLowerCase();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function sortModelsByHierarchy(items: ModelItem[], includeProvider: boolean): void {
|
|
129
|
+
items.sort((left, right) =>
|
|
130
|
+
modelHierarchyKey(left, includeProvider).localeCompare(modelHierarchyKey(right, includeProvider)),
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function compareVersions(left: string, right: string): number {
|
|
135
|
+
const leftParts = left.split(".").map(Number);
|
|
136
|
+
const rightParts = right.split(".").map(Number);
|
|
137
|
+
for (let index = 0; index < Math.max(leftParts.length, rightParts.length); index += 1) {
|
|
138
|
+
const difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
|
|
139
|
+
if (difference !== 0) return difference;
|
|
140
|
+
}
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Keep historical catalogs authoritative while presenting only current user-facing families. */
|
|
145
|
+
export function filterCurrentBrowserModels(models: readonly Model[]): Model[] {
|
|
146
|
+
const newestGeminiVersion = new Map<string, string>();
|
|
147
|
+
const newestClaudeVersion = new Map<string, string>();
|
|
148
|
+
for (const model of models) {
|
|
149
|
+
if (model.provider.startsWith("google-")) {
|
|
150
|
+
const gemini = model.id.match(/^gemini-(\d+(?:\.\d+)?)-(flash|pro)(?:-|$)/i);
|
|
151
|
+
if (gemini?.[1] && gemini[2]) {
|
|
152
|
+
const key = `${model.provider}:${gemini[2].toLowerCase()}`;
|
|
153
|
+
const previous = newestGeminiVersion.get(key);
|
|
154
|
+
if (!previous || compareVersions(gemini[1], previous) > 0) newestGeminiVersion.set(key, gemini[1]);
|
|
155
|
+
}
|
|
87
156
|
}
|
|
88
|
-
|
|
89
|
-
|
|
157
|
+
const claude = model.id.match(/^claude-(opus|sonnet|haiku)-(\d+)(?:[.-](\d+))?(?:-|$)/i);
|
|
158
|
+
if (claude?.[1] && claude[2]) {
|
|
159
|
+
const key = `${model.provider}:${claude[1].toLowerCase()}`;
|
|
160
|
+
const version = `${claude[2]}.${claude[3] ?? "0"}`;
|
|
161
|
+
const previous = newestClaudeVersion.get(key);
|
|
162
|
+
if (!previous || compareVersions(version, previous) > 0) newestClaudeVersion.set(key, version);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return models.filter(model => {
|
|
167
|
+
const gpt = model.id.match(/^gpt-(\d+(?:\.\d+)?)(?:-|$)/i);
|
|
168
|
+
if (gpt?.[1]) {
|
|
169
|
+
// Older GPT generations are still available through explicit --models scopes,
|
|
170
|
+
// but the general browser starts at the current 5.6 family.
|
|
171
|
+
if (compareVersions(gpt[1], "5.6") < 0) return false;
|
|
172
|
+
if (model.provider === "openai-codex") return /^gpt-5\.6-(?:sol|terra|luna)$/i.test(model.id);
|
|
173
|
+
}
|
|
174
|
+
const claude = model.id.match(/^claude-(opus|sonnet|haiku)-(\d+)(?:[.-](\d+))?(?:-|$)/i);
|
|
175
|
+
if (claude?.[1] && claude[2]) {
|
|
176
|
+
const version = `${claude[2]}.${claude[3] ?? "0"}`;
|
|
177
|
+
return newestClaudeVersion.get(`${model.provider}:${claude[1].toLowerCase()}`) === version;
|
|
178
|
+
}
|
|
179
|
+
if (!model.provider.startsWith("google-")) return true;
|
|
180
|
+
if (!model.id.startsWith("gemini-")) {
|
|
181
|
+
// Antigravity discovery can expose implementation-only experiment ids
|
|
182
|
+
// alongside its supported Gemini, Claude, and GPT-OSS catalog.
|
|
183
|
+
return model.provider === "google-antigravity" && /^gpt-oss-/i.test(model.id);
|
|
184
|
+
}
|
|
185
|
+
const match = model.id.match(/^gemini-(\d+(?:\.\d+)?)-(flash|pro)(?:-|$)/i);
|
|
186
|
+
if (!match?.[1] || !match[2]) return false;
|
|
187
|
+
return newestGeminiVersion.get(`${model.provider}:${match[2].toLowerCase()}`) === match[1];
|
|
90
188
|
});
|
|
91
189
|
}
|
|
92
190
|
|
|
191
|
+
export function getProviderDisplayName(provider: string): string {
|
|
192
|
+
if (provider === "openai-codex") return "ChatGPT Subscription";
|
|
193
|
+
if (provider === "openai") return "OpenAI API Key";
|
|
194
|
+
if (provider === "google-vertex") return "Google Vertex";
|
|
195
|
+
if (provider === "google-antigravity") return "Antigravity (Gemini, Claude, GPT-OSS)";
|
|
196
|
+
if (provider === "vllm") return "vLLM";
|
|
197
|
+
if (provider === "lm-studio") return "LM Studio";
|
|
198
|
+
if (provider === "llama.cpp") return "llama.cpp";
|
|
199
|
+
if (provider === "ollama") return "Ollama";
|
|
200
|
+
return provider
|
|
201
|
+
.split("-")
|
|
202
|
+
.map(part => part.charAt(0).toUpperCase() + part.slice(1))
|
|
203
|
+
.join(" ");
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const LOCAL_PROVIDER_IDS = new Set(["ollama", "vllm", "lm-studio", "llama.cpp"]);
|
|
207
|
+
const LOCAL_PROVIDERS_TAB = "local-providers";
|
|
208
|
+
|
|
209
|
+
export interface ProviderModelGroup {
|
|
210
|
+
id: string;
|
|
211
|
+
label: string;
|
|
212
|
+
classification: "authenticated" | "local";
|
|
213
|
+
discoveryStatus: ProviderDiscoveryStatus;
|
|
214
|
+
stale: boolean;
|
|
215
|
+
models: ModelItem[];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function modelItems(models: readonly Model[], currentOnly = true): ModelItem[] {
|
|
219
|
+
return presentModelsForDefaultPicker(currentOnly ? filterCurrentBrowserModels(models) : models).map(item => ({
|
|
220
|
+
kind: "provider",
|
|
221
|
+
provider: item.model.provider,
|
|
222
|
+
id: item.displaySelector.slice(item.displaySelector.indexOf("/") + 1),
|
|
223
|
+
model: item.model,
|
|
224
|
+
selector: item.selector,
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** Build tabs only from provider catalogs whose authenticated/local discovery produced models. */
|
|
229
|
+
export function buildProviderModelGroups(
|
|
230
|
+
models: readonly Model[],
|
|
231
|
+
getDiscoveryState: (provider: string) => ProviderDiscoveryState | undefined,
|
|
232
|
+
configuredProviderOrder: readonly string[] = [],
|
|
233
|
+
currentProvider?: string,
|
|
234
|
+
hasAuth: (provider: string) => boolean = () => true,
|
|
235
|
+
currentOnly = true,
|
|
236
|
+
): ProviderModelGroup[] {
|
|
237
|
+
const items = modelItems(models, currentOnly);
|
|
238
|
+
const byProvider = new Map<string, ModelItem[]>();
|
|
239
|
+
for (const item of items) {
|
|
240
|
+
const providerItems = byProvider.get(item.provider) ?? [];
|
|
241
|
+
providerItems.push(item);
|
|
242
|
+
byProvider.set(item.provider, providerItems);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const authenticated: ProviderModelGroup[] = [];
|
|
246
|
+
const localItems: ModelItem[] = [];
|
|
247
|
+
for (const [provider, providerItems] of byProvider) {
|
|
248
|
+
const discovery = getDiscoveryState(provider);
|
|
249
|
+
if (LOCAL_PROVIDER_IDS.has(provider)) {
|
|
250
|
+
if (discovery?.status !== "ok") continue;
|
|
251
|
+
localItems.push(...providerItems);
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (!hasAuth(provider)) continue;
|
|
255
|
+
if (discovery?.status !== "ok" && discovery?.status !== "cached") continue;
|
|
256
|
+
sortModelsByHierarchy(providerItems, false);
|
|
257
|
+
authenticated.push({
|
|
258
|
+
id: provider,
|
|
259
|
+
label: getProviderDisplayName(provider),
|
|
260
|
+
classification: "authenticated",
|
|
261
|
+
discoveryStatus: discovery.status,
|
|
262
|
+
stale: discovery.stale || discovery.status === "cached",
|
|
263
|
+
models: providerItems,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const configuredRank = new Map<string, number>();
|
|
268
|
+
for (const provider of configuredProviderOrder) {
|
|
269
|
+
const normalized = provider.trim().toLowerCase();
|
|
270
|
+
if (normalized && !configuredRank.has(normalized)) configuredRank.set(normalized, configuredRank.size);
|
|
271
|
+
}
|
|
272
|
+
authenticated.sort((left, right) => {
|
|
273
|
+
if (left.id === currentProvider && right.id !== currentProvider) return -1;
|
|
274
|
+
if (right.id === currentProvider && left.id !== currentProvider) return 1;
|
|
275
|
+
const leftRank = configuredRank.get(left.id.toLowerCase()) ?? Number.MAX_SAFE_INTEGER;
|
|
276
|
+
const rightRank = configuredRank.get(right.id.toLowerCase()) ?? Number.MAX_SAFE_INTEGER;
|
|
277
|
+
if (leftRank !== rightRank) return leftRank - rightRank;
|
|
278
|
+
return left.label.localeCompare(right.label);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
if (localItems.length > 0) {
|
|
282
|
+
sortModelsByHierarchy(localItems, true);
|
|
283
|
+
const localGroup: ProviderModelGroup = {
|
|
284
|
+
id: LOCAL_PROVIDERS_TAB,
|
|
285
|
+
label: "Local Providers",
|
|
286
|
+
classification: "local",
|
|
287
|
+
discoveryStatus: "ok",
|
|
288
|
+
stale: false,
|
|
289
|
+
models: localItems,
|
|
290
|
+
};
|
|
291
|
+
if (currentProvider && LOCAL_PROVIDER_IDS.has(currentProvider)) authenticated.unshift(localGroup);
|
|
292
|
+
else authenticated.push(localGroup);
|
|
293
|
+
}
|
|
294
|
+
return authenticated;
|
|
295
|
+
}
|
|
296
|
+
|
|
93
297
|
interface RoleAssignment {
|
|
94
298
|
model: Model;
|
|
95
299
|
thinkingLevel: ThinkingLevel;
|
|
@@ -102,9 +306,6 @@ interface MenuRoleAction {
|
|
|
102
306
|
role: string; // now accepts custom role strings
|
|
103
307
|
}
|
|
104
308
|
|
|
105
|
-
const ALL_TAB = "ALL";
|
|
106
|
-
const CANONICAL_TAB = "CANONICAL";
|
|
107
|
-
|
|
108
309
|
/**
|
|
109
310
|
* Component that renders a model selector with provider tabs and context menu.
|
|
110
311
|
* - Tab/Arrow Left/Right: Switch between provider tabs
|
|
@@ -132,11 +333,13 @@ export class ModelSelectorComponent extends Container {
|
|
|
132
333
|
#tui: TUI;
|
|
133
334
|
#scopedModels: ReadonlyArray<ScopedModelItem>;
|
|
134
335
|
#temporaryOnly: boolean;
|
|
336
|
+
#currentModel: Model | undefined;
|
|
337
|
+
#providerGroups: ProviderModelGroup[] = [];
|
|
135
338
|
|
|
136
339
|
#menuRoleActions: MenuRoleAction[] = [];
|
|
137
340
|
|
|
138
341
|
// Tab state
|
|
139
|
-
#providers: string[] = [
|
|
342
|
+
#providers: string[] = [];
|
|
140
343
|
#activeTabIndex: number = 0;
|
|
141
344
|
|
|
142
345
|
// Context menu state
|
|
@@ -164,6 +367,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
164
367
|
this.#onSelectCallback = onSelect;
|
|
165
368
|
this.#onCancelCallback = onCancel;
|
|
166
369
|
this.#temporaryOnly = options?.temporaryOnly ?? false;
|
|
370
|
+
this.#currentModel = _currentModel;
|
|
167
371
|
const initialSearchInput = options?.initialSearchInput;
|
|
168
372
|
|
|
169
373
|
// Initialize menu role actions (built-in + custom from settings)
|
|
@@ -228,7 +432,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
228
432
|
if (currentQuery) {
|
|
229
433
|
this.#filterModels(currentQuery);
|
|
230
434
|
} else {
|
|
231
|
-
this.#
|
|
435
|
+
this.#applyTabFilter();
|
|
232
436
|
}
|
|
233
437
|
// Request re-render after models are loaded
|
|
234
438
|
this.#tui.requestRender();
|
|
@@ -258,6 +462,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
258
462
|
matchPreferences,
|
|
259
463
|
modelRegistry: this.#modelRegistry,
|
|
260
464
|
});
|
|
465
|
+
if (resolved.warning) this.#errorMessage = resolved.warning;
|
|
261
466
|
if (resolved.model) {
|
|
262
467
|
this.#roles[role] = {
|
|
263
468
|
model: resolved.model,
|
|
@@ -400,20 +605,13 @@ export class ModelSelectorComponent extends Container {
|
|
|
400
605
|
const loadError = this.#modelRegistry.getError();
|
|
401
606
|
if (loadError) {
|
|
402
607
|
this.#errorMessage = loadError;
|
|
403
|
-
} else {
|
|
608
|
+
} else if (!this.#errorMessage) {
|
|
404
609
|
this.#errorMessage = undefined;
|
|
405
610
|
}
|
|
406
611
|
|
|
407
612
|
// Load available models (built-in models still work even if models.json failed)
|
|
408
613
|
try {
|
|
409
|
-
|
|
410
|
-
models = presentModelsForDefaultPicker(availableModels).map(item => ({
|
|
411
|
-
kind: "provider",
|
|
412
|
-
provider: item.model.provider,
|
|
413
|
-
id: item.displaySelector.slice(item.displaySelector.indexOf("/") + 1),
|
|
414
|
-
model: item.model,
|
|
415
|
-
selector: item.selector,
|
|
416
|
-
}));
|
|
614
|
+
models = modelItems(this.#modelRegistry.getAvailable());
|
|
417
615
|
} catch (error) {
|
|
418
616
|
this.#allModels = [];
|
|
419
617
|
this.#filteredModels = [];
|
|
@@ -424,88 +622,49 @@ export class ModelSelectorComponent extends Container {
|
|
|
424
622
|
}
|
|
425
623
|
}
|
|
426
624
|
|
|
427
|
-
const canonicalRecords = this.#modelRegistry.getCanonicalModels({
|
|
428
|
-
availableOnly: this.#scopedModels.length === 0,
|
|
429
|
-
candidates: models.map(item => item.model),
|
|
430
|
-
});
|
|
431
|
-
const canonicalModels = canonicalRecords
|
|
432
|
-
.map(record => {
|
|
433
|
-
const selectedModel = this.#modelRegistry.resolveCanonicalModel(record.id, {
|
|
434
|
-
availableOnly: this.#scopedModels.length === 0,
|
|
435
|
-
candidates: models.map(item => item.model),
|
|
436
|
-
});
|
|
437
|
-
if (!selectedModel) return undefined;
|
|
438
|
-
const searchText = [
|
|
439
|
-
record.id,
|
|
440
|
-
record.name,
|
|
441
|
-
selectedModel.provider,
|
|
442
|
-
selectedModel.id,
|
|
443
|
-
selectedModel.name,
|
|
444
|
-
...record.variants.flatMap(variant => [variant.selector, variant.model.name]),
|
|
445
|
-
].join(" ");
|
|
446
|
-
return {
|
|
447
|
-
kind: "canonical" as const,
|
|
448
|
-
id: record.id,
|
|
449
|
-
model: selectedModel,
|
|
450
|
-
selector: record.id,
|
|
451
|
-
variantCount: record.variants.length,
|
|
452
|
-
searchText,
|
|
453
|
-
normalizedSearchText: normalizeSearchText(searchText),
|
|
454
|
-
compactSearchText: compactSearchText(searchText),
|
|
455
|
-
};
|
|
456
|
-
})
|
|
457
|
-
.filter((item): item is CanonicalModelItem => item !== undefined)
|
|
458
|
-
.filter(
|
|
459
|
-
item =>
|
|
460
|
-
this.#scopedModels.length > 0 ||
|
|
461
|
-
item.model.provider !== "openai-codex" ||
|
|
462
|
-
!OPENAI_CODEX_GPT56_TIERS.has(item.model.id),
|
|
463
|
-
);
|
|
464
|
-
if (this.#scopedModels.length === 0) {
|
|
465
|
-
const friendly = models.find(item => item.provider === "openai-codex" && item.id === "gpt-5.6");
|
|
466
|
-
if (friendly) {
|
|
467
|
-
canonicalModels.push({
|
|
468
|
-
kind: "canonical",
|
|
469
|
-
id: "openai-codex/gpt-5.6",
|
|
470
|
-
model: friendly.model,
|
|
471
|
-
selector: friendly.selector,
|
|
472
|
-
variantCount: 1,
|
|
473
|
-
searchText: "openai-codex/gpt-5.6 GPT-5.6 Sol",
|
|
474
|
-
normalizedSearchText: normalizeSearchText("openai-codex/gpt-5.6 GPT-5.6 Sol"),
|
|
475
|
-
compactSearchText: compactSearchText("openai-codex/gpt-5.6 GPT-5.6 Sol"),
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
625
|
this.#sortModels(models);
|
|
481
|
-
this.#sortCanonicalModels(canonicalModels);
|
|
482
626
|
|
|
483
627
|
this.#allModels = models;
|
|
484
628
|
this.#filteredModels = models;
|
|
485
|
-
this.#canonicalModels =
|
|
486
|
-
this.#filteredCanonicalModels =
|
|
629
|
+
this.#canonicalModels = [];
|
|
630
|
+
this.#filteredCanonicalModels = [];
|
|
487
631
|
this.#selectedIndex = Math.min(this.#selectedIndex, Math.max(0, models.length - 1));
|
|
488
632
|
}
|
|
489
633
|
|
|
490
634
|
#buildProviderTabs(): void {
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
}
|
|
498
|
-
const
|
|
499
|
-
this.#
|
|
635
|
+
const previousProvider = this.#getActiveProvider();
|
|
636
|
+
const discoveryState = (provider: string): ProviderDiscoveryState | undefined => {
|
|
637
|
+
if (this.#scopedModels.length > 0 || typeof this.#modelRegistry.getProviderDiscoveryState !== "function") {
|
|
638
|
+
return { provider, status: "ok", optional: false, stale: false, models: [] };
|
|
639
|
+
}
|
|
640
|
+
return this.#modelRegistry.getProviderDiscoveryState(provider);
|
|
641
|
+
};
|
|
642
|
+
const configuredOrder = this.#settings.get("modelProviderOrder");
|
|
643
|
+
this.#providerGroups = buildProviderModelGroups(
|
|
644
|
+
this.#allModels.map(item => item.model),
|
|
645
|
+
discoveryState,
|
|
646
|
+
configuredOrder,
|
|
647
|
+
this.#currentModel?.provider,
|
|
648
|
+
provider =>
|
|
649
|
+
this.#scopedModels.length > 0 ||
|
|
650
|
+
typeof this.#modelRegistry.authStorage?.hasAuth !== "function" ||
|
|
651
|
+
this.#modelRegistry.authStorage.hasAuth(provider),
|
|
652
|
+
this.#scopedModels.length === 0,
|
|
653
|
+
);
|
|
654
|
+
this.#providers = this.#providerGroups.map(group => group.id);
|
|
655
|
+
const previousIndex = this.#providers.indexOf(previousProvider);
|
|
656
|
+
this.#activeTabIndex = previousIndex >= 0 ? previousIndex : 0;
|
|
500
657
|
}
|
|
501
658
|
|
|
502
659
|
async #refreshSelectedProvider(): Promise<void> {
|
|
503
|
-
const
|
|
504
|
-
if (this.#
|
|
660
|
+
const activeGroup = this.#providerGroups[this.#activeTabIndex];
|
|
661
|
+
if (!activeGroup || typeof this.#modelRegistry.refreshProvider !== "function" || this.#scopedModels.length > 0)
|
|
505
662
|
return;
|
|
506
|
-
|
|
507
|
-
await this.#modelRegistry.refreshProvider(
|
|
508
|
-
|
|
663
|
+
const providers = new Set(activeGroup.models.map(item => item.provider));
|
|
664
|
+
await Promise.all([...providers].map(provider => this.#modelRegistry.refreshProvider(provider, "online")));
|
|
665
|
+
const models = modelItems(this.#modelRegistry.getAvailable());
|
|
666
|
+
this.#sortModels(models);
|
|
667
|
+
this.#allModels = models;
|
|
509
668
|
this.#buildProviderTabs();
|
|
510
669
|
this.#updateTabBar();
|
|
511
670
|
this.#applyTabFilter();
|
|
@@ -515,7 +674,10 @@ export class ModelSelectorComponent extends Container {
|
|
|
515
674
|
#updateTabBar(): void {
|
|
516
675
|
this.#headerContainer.clear();
|
|
517
676
|
|
|
518
|
-
const tabs: Tab[] = this.#
|
|
677
|
+
const tabs: Tab[] = this.#providerGroups.map(group => ({
|
|
678
|
+
id: group.id,
|
|
679
|
+
label: `${group.label}${group.stale ? " (stale)" : ""}`,
|
|
680
|
+
}));
|
|
519
681
|
const tabBar = new TabBar("Models", tabs, getTabBarTheme(), this.#activeTabIndex);
|
|
520
682
|
tabBar.onTabChange = (_tab, index) => {
|
|
521
683
|
this.#activeTabIndex = index;
|
|
@@ -532,37 +694,25 @@ export class ModelSelectorComponent extends Container {
|
|
|
532
694
|
}
|
|
533
695
|
|
|
534
696
|
#getActiveProvider(): string {
|
|
535
|
-
return this.#providers[this.#activeTabIndex] ??
|
|
697
|
+
return this.#providers[this.#activeTabIndex] ?? "";
|
|
536
698
|
}
|
|
537
699
|
|
|
538
700
|
#isCanonicalTab(): boolean {
|
|
539
|
-
return
|
|
701
|
+
return false;
|
|
540
702
|
}
|
|
541
703
|
|
|
542
704
|
#filterModels(query: string): void {
|
|
543
|
-
const
|
|
544
|
-
const
|
|
705
|
+
const isCanonicalTab = false;
|
|
706
|
+
const activeGroup = this.#providerGroups[this.#activeTabIndex];
|
|
545
707
|
|
|
546
|
-
//
|
|
547
|
-
|
|
708
|
+
// Search is a temporary global grouped view; the active provider tab remains unchanged.
|
|
709
|
+
const baseModels = query.trim()
|
|
710
|
+
? this.#providerGroups.flatMap(group => group.models)
|
|
711
|
+
: (activeGroup?.models ?? []);
|
|
548
712
|
const baseCanonicalModels = this.#canonicalModels;
|
|
549
|
-
if (!isCanonicalTab && activeProvider !== ALL_TAB) {
|
|
550
|
-
baseModels = this.#allModels.filter(m => m.provider.toUpperCase() === activeProvider);
|
|
551
|
-
}
|
|
552
713
|
|
|
553
714
|
// Apply fuzzy filter if query is present
|
|
554
715
|
if (query.trim()) {
|
|
555
|
-
// If user is searching from a provider tab, auto-switch to ALL to show global provider results.
|
|
556
|
-
if (activeProvider !== ALL_TAB && !isCanonicalTab) {
|
|
557
|
-
this.#activeTabIndex = 0;
|
|
558
|
-
if (this.#tabBar && this.#tabBar.getActiveIndex() !== 0) {
|
|
559
|
-
this.#tabBar.setActiveIndex(0);
|
|
560
|
-
return;
|
|
561
|
-
}
|
|
562
|
-
this.#updateTabBar();
|
|
563
|
-
baseModels = this.#allModels;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
716
|
if (isCanonicalTab) {
|
|
567
717
|
const alphaTokens = getAlphaSearchTokens(query);
|
|
568
718
|
const alphaFiltered =
|
|
@@ -586,12 +736,24 @@ export class ModelSelectorComponent extends Container {
|
|
|
586
736
|
this.#sortCanonicalModels(fuzzyMatches);
|
|
587
737
|
this.#filteredCanonicalModels = fuzzyMatches;
|
|
588
738
|
} else {
|
|
739
|
+
const selectorQuery = query.trim().toLowerCase();
|
|
740
|
+
const selectorMatches = selectorQuery.includes("/")
|
|
741
|
+
? baseModels.filter(item => item.selector.toLowerCase().includes(selectorQuery))
|
|
742
|
+
: undefined;
|
|
743
|
+
const alphaTokens = getAlphaSearchTokens(query);
|
|
744
|
+
const alphaFiltered = (selectorMatches ?? baseModels).filter(item => {
|
|
745
|
+
const searchText = normalizeSearchText(
|
|
746
|
+
getModelSearchText({ model: item.model, selector: item.selector, displaySelector: item.selector }),
|
|
747
|
+
);
|
|
748
|
+
return alphaTokens.every(token => searchText.includes(token));
|
|
749
|
+
});
|
|
589
750
|
const fuzzyMatches = fuzzyFilter(
|
|
590
|
-
baseModels,
|
|
751
|
+
selectorMatches ?? (alphaFiltered.length > 0 ? alphaFiltered : baseModels),
|
|
591
752
|
query,
|
|
592
|
-
({
|
|
753
|
+
({ model, selector }) => getModelSearchText({ model, selector, displaySelector: selector }),
|
|
593
754
|
);
|
|
594
755
|
this.#sortModels(fuzzyMatches);
|
|
756
|
+
sortModelsByHierarchy(fuzzyMatches, true);
|
|
595
757
|
this.#filteredModels = fuzzyMatches;
|
|
596
758
|
}
|
|
597
759
|
} else {
|
|
@@ -622,11 +784,11 @@ export class ModelSelectorComponent extends Container {
|
|
|
622
784
|
}
|
|
623
785
|
|
|
624
786
|
#getProviderEmptyStateMessage(): string | undefined {
|
|
625
|
-
const
|
|
626
|
-
if (
|
|
787
|
+
const activeGroup = this.#providerGroups[this.#activeTabIndex];
|
|
788
|
+
if (!activeGroup || activeGroup.classification === "local" || this.#searchInput.getValue().trim()) {
|
|
627
789
|
return undefined;
|
|
628
790
|
}
|
|
629
|
-
const state = this.#modelRegistry.getProviderDiscoveryState(
|
|
791
|
+
const state = this.#modelRegistry.getProviderDiscoveryState(activeGroup.id);
|
|
630
792
|
if (!state) {
|
|
631
793
|
return undefined;
|
|
632
794
|
}
|
|
@@ -659,15 +821,42 @@ export class ModelSelectorComponent extends Container {
|
|
|
659
821
|
);
|
|
660
822
|
const endIndex = Math.min(startIndex + maxVisible, visibleItems.length);
|
|
661
823
|
|
|
662
|
-
const
|
|
663
|
-
const
|
|
824
|
+
const activeGroup = this.#providerGroups[this.#activeTabIndex];
|
|
825
|
+
const searching = Boolean(this.#searchInput.getValue().trim());
|
|
826
|
+
const showProvider = searching || activeGroup?.classification === "local";
|
|
827
|
+
if (!searching && activeGroup?.stale) {
|
|
828
|
+
const providerState =
|
|
829
|
+
activeGroup.classification === "authenticated"
|
|
830
|
+
? this.#modelRegistry.getProviderDiscoveryState(activeGroup.id)
|
|
831
|
+
: undefined;
|
|
832
|
+
const age = this.#formatDiscoveryAge(providerState?.fetchedAt);
|
|
833
|
+
this.#listContainer.addChild(
|
|
834
|
+
new Text(theme.fg("warning", ` Stale cached catalog${age ? ` from ${age}` : ""}`), 0, 0),
|
|
835
|
+
);
|
|
836
|
+
this.#listContainer.addChild(new Spacer(1));
|
|
837
|
+
}
|
|
664
838
|
|
|
665
839
|
// Show visible slice of filtered models
|
|
840
|
+
let previousGroup: string | undefined;
|
|
666
841
|
for (let i = startIndex; i < endIndex; i++) {
|
|
667
842
|
const item = visibleItems[i];
|
|
668
843
|
if (!item) continue;
|
|
669
844
|
const canonicalItem = isCanonicalTab ? (item as CanonicalModelItem) : undefined;
|
|
670
845
|
const providerItem = isCanonicalTab ? undefined : (item as ModelItem);
|
|
846
|
+
const group = showProvider
|
|
847
|
+
? [
|
|
848
|
+
getProviderDisplayName(providerItem?.provider ?? ""),
|
|
849
|
+
getModelPublisher(item.model),
|
|
850
|
+
getModelFamily(item.model),
|
|
851
|
+
]
|
|
852
|
+
.filter(Boolean)
|
|
853
|
+
.join(" › ")
|
|
854
|
+
: [getModelPublisher(item.model), getModelFamily(item.model)].filter(Boolean).join(" › ");
|
|
855
|
+
if (group && group !== previousGroup) {
|
|
856
|
+
if (previousGroup) this.#listContainer.addChild(new Spacer(1));
|
|
857
|
+
this.#listContainer.addChild(new Text(theme.fg("muted", ` ${group}`), 0, 0));
|
|
858
|
+
previousGroup = group;
|
|
859
|
+
}
|
|
671
860
|
|
|
672
861
|
const isSelected = i === this.#selectedIndex;
|
|
673
862
|
|
|
@@ -700,11 +889,8 @@ export class ModelSelectorComponent extends Container {
|
|
|
700
889
|
const variants = theme.fg("dim", ` [${canonicalItem?.variantCount ?? 0}]`);
|
|
701
890
|
const backing = theme.fg("dim", ` -> ${item.model.provider}/${item.model.id}`);
|
|
702
891
|
line = `${prefix}${theme.fg("accent", item.id)}${variants}${backing}${badgeText}`;
|
|
703
|
-
} else if (showProvider) {
|
|
704
|
-
const providerPrefix = theme.fg("dim", `${providerItem?.provider ?? ""}/`);
|
|
705
|
-
line = `${prefix}${providerPrefix}${theme.fg("accent", providerItem?.id ?? item.id)}${badgeText}`;
|
|
706
892
|
} else {
|
|
707
|
-
line = `${prefix}${theme.fg("accent", item.
|
|
893
|
+
line = `${prefix}${theme.fg("accent", getModelDisplayName(item.model))} ${theme.fg("dim", `[${item.selector}]`)}${badgeText}`;
|
|
708
894
|
}
|
|
709
895
|
} else {
|
|
710
896
|
const prefix = " ";
|
|
@@ -712,11 +898,8 @@ export class ModelSelectorComponent extends Container {
|
|
|
712
898
|
const variants = theme.fg("dim", ` [${canonicalItem?.variantCount ?? 0}]`);
|
|
713
899
|
const backing = theme.fg("dim", ` -> ${item.model.provider}/${item.model.id}`);
|
|
714
900
|
line = `${prefix}${item.id}${variants}${backing}${badgeText}`;
|
|
715
|
-
} else if (showProvider) {
|
|
716
|
-
const providerPrefix = theme.fg("dim", `${providerItem?.provider ?? ""}/`);
|
|
717
|
-
line = `${prefix}${providerPrefix}${providerItem?.id ?? item.id}${badgeText}`;
|
|
718
901
|
} else {
|
|
719
|
-
line = `${prefix}${item.
|
|
902
|
+
line = `${prefix}${getModelDisplayName(item.model)} ${theme.fg("dim", `[${item.selector}]`)}${badgeText}`;
|
|
720
903
|
}
|
|
721
904
|
}
|
|
722
905
|
|
|
@@ -748,15 +931,16 @@ export class ModelSelectorComponent extends Container {
|
|
|
748
931
|
? ` (${selected.model.provider}/${selected.model.id}, ${(selected as CanonicalModelItem).variantCount} variants)`
|
|
749
932
|
: "";
|
|
750
933
|
this.#listContainer.addChild(
|
|
751
|
-
new Text(theme.fg("muted", ` Model Name: ${selected.model
|
|
934
|
+
new Text(theme.fg("muted", ` Model Name: ${getModelDisplayName(selected.model)}${suffix}`), 0, 0),
|
|
752
935
|
);
|
|
753
936
|
}
|
|
754
937
|
}
|
|
755
938
|
#getThinkingLevelsForModel(model: Model): ReadonlyArray<ThinkingLevel> {
|
|
756
939
|
return [
|
|
757
940
|
ThinkingLevel.Inherit,
|
|
758
|
-
...(model.
|
|
759
|
-
|
|
941
|
+
...getSupportedReasoningEfforts(model).map(level =>
|
|
942
|
+
level === ReasoningEffort.None ? ThinkingLevel.Off : (level as ThinkingLevel),
|
|
943
|
+
),
|
|
760
944
|
];
|
|
761
945
|
}
|
|
762
946
|
|
|
@@ -787,6 +971,16 @@ export class ModelSelectorComponent extends Container {
|
|
|
787
971
|
this.#updateMenu();
|
|
788
972
|
}
|
|
789
973
|
|
|
974
|
+
#openThinkingMenu(role: string): void {
|
|
975
|
+
const selected = this.#getSelectedItem();
|
|
976
|
+
if (!selected) return;
|
|
977
|
+
this.#isMenuOpen = true;
|
|
978
|
+
this.#menuStep = "thinking";
|
|
979
|
+
this.#menuSelectedRole = role;
|
|
980
|
+
this.#menuSelectedIndex = this.#getThinkingPreselectIndex(role, selected.model);
|
|
981
|
+
this.#updateMenu();
|
|
982
|
+
}
|
|
983
|
+
|
|
790
984
|
#closeMenu(): void {
|
|
791
985
|
this.#isMenuOpen = false;
|
|
792
986
|
this.#menuStep = "role";
|
|
@@ -806,7 +1000,12 @@ export class ModelSelectorComponent extends Container {
|
|
|
806
1000
|
? thinkingOptions.map((thinkingLevel, index) => {
|
|
807
1001
|
const prefix = index === this.#menuSelectedIndex ? ` ${theme.nav.cursor} ` : " ";
|
|
808
1002
|
const label = getThinkingLevelMetadata(thinkingLevel).label;
|
|
809
|
-
|
|
1003
|
+
const effort = thinkingLevel === ThinkingLevel.Off ? ReasoningEffort.None : thinkingLevel;
|
|
1004
|
+
const description =
|
|
1005
|
+
thinkingLevel === ThinkingLevel.Inherit
|
|
1006
|
+
? "Use the provider default"
|
|
1007
|
+
: selectedItem.model.thinking?.supportedLevels.find(level => level.effort === effort)?.description;
|
|
1008
|
+
return `${prefix}${label}${description ? ` — ${description}` : ""}`;
|
|
810
1009
|
})
|
|
811
1010
|
: this.#menuRoleActions.map((action, index) => {
|
|
812
1011
|
const prefix = index === this.#menuSelectedIndex ? ` ${theme.nav.cursor} ` : " ";
|
|
@@ -882,20 +1081,21 @@ export class ModelSelectorComponent extends Container {
|
|
|
882
1081
|
return;
|
|
883
1082
|
}
|
|
884
1083
|
|
|
885
|
-
// Enter
|
|
1084
|
+
// Enter selects the model and opens its exact reasoning picker.
|
|
886
1085
|
if (matchesKey(keyData, "enter") || matchesKey(keyData, "return") || keyData === "\n") {
|
|
887
1086
|
const selectedItem = this.#getSelectedItem();
|
|
888
1087
|
if (selectedItem) {
|
|
889
|
-
|
|
890
|
-
// In temporary mode, skip menu and select directly
|
|
891
|
-
this.#handleSelect(selectedItem, null);
|
|
892
|
-
} else {
|
|
893
|
-
this.#openMenu();
|
|
894
|
-
}
|
|
1088
|
+
this.#openThinkingMenu(this.#temporaryOnly ? "default" : "default");
|
|
895
1089
|
}
|
|
896
1090
|
return;
|
|
897
1091
|
}
|
|
898
1092
|
|
|
1093
|
+
// Role assignment is deliberately secondary.
|
|
1094
|
+
if (keyData.toLowerCase() === "r" && !this.#temporaryOnly && this.#searchInput.getValue().length === 0) {
|
|
1095
|
+
this.#openMenu();
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
899
1099
|
// Escape or Ctrl+C - close selector
|
|
900
1100
|
if (getKeybindings().matches(keyData, "tui.select.cancel")) {
|
|
901
1101
|
this.#onCancelCallback();
|
|
@@ -943,7 +1143,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
943
1143
|
const thinkingOptions = this.#getThinkingLevelsForModel(selectedItem.model);
|
|
944
1144
|
const thinkingLevel = thinkingOptions[this.#menuSelectedIndex];
|
|
945
1145
|
if (!thinkingLevel) return;
|
|
946
|
-
this.#handleSelect(selectedItem, this.#menuSelectedRole, thinkingLevel);
|
|
1146
|
+
this.#handleSelect(selectedItem, this.#temporaryOnly ? null : this.#menuSelectedRole, thinkingLevel);
|
|
947
1147
|
this.#closeMenu();
|
|
948
1148
|
return;
|
|
949
1149
|
}
|
|
@@ -965,7 +1165,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
965
1165
|
#handleSelect(item: ModelItem | CanonicalModelItem, role: string | null, thinkingLevel?: ThinkingLevel): void {
|
|
966
1166
|
// For temporary role, don't save to settings - just notify caller
|
|
967
1167
|
if (role === null) {
|
|
968
|
-
this.#onSelectCallback(item.model, null,
|
|
1168
|
+
this.#onSelectCallback(item.model, null, thinkingLevel, item.selector);
|
|
969
1169
|
return;
|
|
970
1170
|
}
|
|
971
1171
|
|