@f5-sales-demo/xcsh 21.19.1 → 21.19.2
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 +37 -7
- package/src/config/model-registry.ts +209 -20
- package/src/config/settings-schema.ts +4 -0
- package/src/internal-urls/build-info.generated.ts +8 -8
- package/src/modes/components/model-selector.ts +158 -43
- package/src/modes/components/oauth-selector.ts +39 -12
- package/src/modes/controllers/litellm-login-transaction.ts +8 -0
- package/src/modes/controllers/selector-controller.ts +38 -7
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5-sales-demo/xcsh",
|
|
4
|
-
"version": "21.19.
|
|
4
|
+
"version": "21.19.2",
|
|
5
5
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
6
6
|
"homepage": "https://github.com/f5-sales-demo/xcsh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@agentclientprotocol/sdk": "1.3.0",
|
|
65
|
-
"@f5-sales-demo/pi-agent-core": "21.19.
|
|
66
|
-
"@f5-sales-demo/pi-ai": "21.19.
|
|
67
|
-
"@f5-sales-demo/pi-natives": "21.19.
|
|
68
|
-
"@f5-sales-demo/pi-resource-management": "21.19.
|
|
69
|
-
"@f5-sales-demo/pi-tui": "21.19.
|
|
70
|
-
"@f5-sales-demo/pi-utils": "21.19.
|
|
71
|
-
"@f5-sales-demo/xcsh-stats": "21.19.
|
|
65
|
+
"@f5-sales-demo/pi-agent-core": "21.19.2",
|
|
66
|
+
"@f5-sales-demo/pi-ai": "21.19.2",
|
|
67
|
+
"@f5-sales-demo/pi-natives": "21.19.2",
|
|
68
|
+
"@f5-sales-demo/pi-resource-management": "21.19.2",
|
|
69
|
+
"@f5-sales-demo/pi-tui": "21.19.2",
|
|
70
|
+
"@f5-sales-demo/pi-utils": "21.19.2",
|
|
71
|
+
"@f5-sales-demo/xcsh-stats": "21.19.2",
|
|
72
72
|
"@mozilla/readability": "^0.6",
|
|
73
73
|
"@sinclair/typebox": "^0.34",
|
|
74
74
|
"@xterm/headless": "^6.0",
|
|
@@ -20,9 +20,14 @@ import { hardenAgentConfigFileSync, writeAgentConfigFileSync } from "./agent-con
|
|
|
20
20
|
import { DEFAULT_MODEL_ROLE } from "./settings-schema";
|
|
21
21
|
|
|
22
22
|
/** Current config schema version. Bump when the generated format changes. */
|
|
23
|
-
export const CURRENT_CONFIG_VERSION =
|
|
23
|
+
export const CURRENT_CONFIG_VERSION = 6;
|
|
24
24
|
const LITELLM_CONFIG_DIR_MODE = 0o700;
|
|
25
25
|
const LITELLM_MODELS_FILE_MODE = 0o600;
|
|
26
|
+
const GENERATED_LITELLM_MARKER = "# Auto-generated by xcsh for LiteLLM proxy";
|
|
27
|
+
|
|
28
|
+
function isGeneratedLiteLLMConfig(content: string): boolean {
|
|
29
|
+
return content.includes(GENERATED_LITELLM_MARKER);
|
|
30
|
+
}
|
|
26
31
|
|
|
27
32
|
// ---------------------------------------------------------------------------
|
|
28
33
|
// Detection
|
|
@@ -65,19 +70,35 @@ export function generateModelsYml(baseUrl: string, options?: GenerateModelsYmlOp
|
|
|
65
70
|
? "# API key stored as literal value"
|
|
66
71
|
: "# API key resolved from LITELLM_API_KEY env var at runtime";
|
|
67
72
|
const lines = [
|
|
68
|
-
|
|
73
|
+
GENERATED_LITELLM_MARKER,
|
|
69
74
|
keyComment,
|
|
70
75
|
`configVersion: ${CURRENT_CONFIG_VERSION}`,
|
|
71
76
|
"providers:",
|
|
72
77
|
" anthropic:",
|
|
73
78
|
` baseUrl: "${baseUrl}/anthropic"`,
|
|
74
79
|
` apiKey: ${apiKeyValue}`,
|
|
80
|
+
" modelAllowlist:",
|
|
81
|
+
" - claude-opus-5",
|
|
82
|
+
" - claude-sonnet-5",
|
|
83
|
+
" - claude-haiku-4-5",
|
|
84
|
+
" picker:",
|
|
85
|
+
" groupId: litellm",
|
|
86
|
+
" groupLabel: LiteLLM",
|
|
87
|
+
" sectionLabel: Anthropic",
|
|
75
88
|
" litellm:",
|
|
76
89
|
` baseUrl: "${baseUrl}${apiBase}"`,
|
|
77
90
|
` apiKey: ${apiKeyValue}`,
|
|
78
91
|
" api: openai-completions",
|
|
79
92
|
" discovery:",
|
|
80
93
|
" type: openai-compat",
|
|
94
|
+
" modelAllowlist:",
|
|
95
|
+
" - gpt-5.6-sol",
|
|
96
|
+
" - gpt-5.6-terra",
|
|
97
|
+
" - gpt-5.6-luna",
|
|
98
|
+
" picker:",
|
|
99
|
+
" groupId: litellm",
|
|
100
|
+
" groupLabel: LiteLLM",
|
|
101
|
+
" sectionLabel: OpenAI",
|
|
81
102
|
" modelOverrides:",
|
|
82
103
|
" gpt-5.6-sol:",
|
|
83
104
|
" reasoning: true",
|
|
@@ -176,7 +197,7 @@ export const DEFAULT_MODEL_ROLE_VALUE = DEFAULT_MODEL_ROLE;
|
|
|
176
197
|
*/
|
|
177
198
|
export function generateConfigYml(): string {
|
|
178
199
|
return [
|
|
179
|
-
|
|
200
|
+
GENERATED_LITELLM_MARKER,
|
|
180
201
|
"# The default model role ships in the binary — none is written here.",
|
|
181
202
|
"providers:",
|
|
182
203
|
" image: openai",
|
|
@@ -567,6 +588,16 @@ export interface FixResult {
|
|
|
567
588
|
* Always creates .bak backup before overwriting.
|
|
568
589
|
*/
|
|
569
590
|
export function autoFixModelsConfig(modelsPath: string): FixResult {
|
|
591
|
+
if (fs.existsSync(modelsPath)) {
|
|
592
|
+
try {
|
|
593
|
+
const content = fs.readFileSync(modelsPath, "utf-8");
|
|
594
|
+
if (!isGeneratedLiteLLMConfig(content)) {
|
|
595
|
+
return { fixed: false, changes: ["Skipped custom models.yml; only xcsh-generated files are upgraded"] };
|
|
596
|
+
}
|
|
597
|
+
} catch {
|
|
598
|
+
return { fixed: false, changes: ["Cannot inspect existing models.yml safely"] };
|
|
599
|
+
}
|
|
600
|
+
}
|
|
570
601
|
const existing = readLiteLLMConfig(modelsPath);
|
|
571
602
|
const baseUrl = getLiteLLMBaseUrl() ?? existing?.baseUrl;
|
|
572
603
|
const existingLiteralKey = readApiKeyLiteral(modelsPath);
|
|
@@ -637,8 +668,7 @@ export function startupHealthCheck(
|
|
|
637
668
|
if (status === "ok" && loadedProviders) {
|
|
638
669
|
try {
|
|
639
670
|
const content = fs.readFileSync(modelsPath, "utf-8");
|
|
640
|
-
const isAutoGenerated =
|
|
641
|
-
content.includes("Auto-generated by xcsh") || content.includes("apiKey: LITELLM_API_KEY");
|
|
671
|
+
const isAutoGenerated = isGeneratedLiteLLMConfig(content);
|
|
642
672
|
if (
|
|
643
673
|
isAutoGenerated &&
|
|
644
674
|
(!content.includes(`configVersion: ${CURRENT_CONFIG_VERSION}`) || !content.includes("type: openai-compat"))
|
|
@@ -661,7 +691,7 @@ export function startupHealthCheck(
|
|
|
661
691
|
let isAutoGenerated = false;
|
|
662
692
|
try {
|
|
663
693
|
const content = fs.readFileSync(modelsPath, "utf-8");
|
|
664
|
-
isAutoGenerated =
|
|
694
|
+
isAutoGenerated = isGeneratedLiteLLMConfig(content);
|
|
665
695
|
} catch {
|
|
666
696
|
// File unreadable — skip, don't block startup
|
|
667
697
|
}
|
|
@@ -729,7 +759,7 @@ export async function probeAndUpgradeLiteLLMConfig(
|
|
|
729
759
|
// Only upgrade configs that were auto-generated by xcsh. User-written configs
|
|
730
760
|
// with custom proxy URLs must never be silently overwritten by LiteLLM probing.
|
|
731
761
|
// Recognize both env-var-ref configs and literal-key configs as auto-generated.
|
|
732
|
-
if (!
|
|
762
|
+
if (!isGeneratedLiteLLMConfig(content)) {
|
|
733
763
|
return false;
|
|
734
764
|
}
|
|
735
765
|
|
|
@@ -270,6 +270,12 @@ const ProviderDiscoverySchema = Type.Object({
|
|
|
270
270
|
|
|
271
271
|
const ProviderAuthSchema = Type.Union([Type.Literal("apiKey"), Type.Literal("none")]);
|
|
272
272
|
|
|
273
|
+
const ProviderPickerSchema = Type.Object({
|
|
274
|
+
groupId: Type.Optional(Type.String({ minLength: 1 })),
|
|
275
|
+
groupLabel: Type.Optional(Type.String({ minLength: 1 })),
|
|
276
|
+
sectionLabel: Type.Optional(Type.String({ minLength: 1 })),
|
|
277
|
+
});
|
|
278
|
+
|
|
273
279
|
const ProviderConfigSchema = Type.Object({
|
|
274
280
|
baseUrl: Type.Optional(Type.String({ minLength: 1 })),
|
|
275
281
|
apiKey: Type.Optional(Type.String({ minLength: 1 })),
|
|
@@ -289,6 +295,8 @@ const ProviderConfigSchema = Type.Object({
|
|
|
289
295
|
authHeader: Type.Optional(Type.Boolean()),
|
|
290
296
|
auth: Type.Optional(ProviderAuthSchema),
|
|
291
297
|
discovery: Type.Optional(ProviderDiscoverySchema),
|
|
298
|
+
modelAllowlist: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
|
|
299
|
+
picker: Type.Optional(ProviderPickerSchema),
|
|
292
300
|
models: Type.Optional(Type.Array(ModelDefinitionSchema)),
|
|
293
301
|
modelOverrides: Type.Optional(Type.Record(Type.String(), ModelOverrideSchema)),
|
|
294
302
|
});
|
|
@@ -429,7 +437,7 @@ interface DiscoveryProviderConfig {
|
|
|
429
437
|
optional?: boolean;
|
|
430
438
|
}
|
|
431
439
|
|
|
432
|
-
export type ProviderDiscoveryStatus = "idle" | "ok" | "cached" | "unavailable" | "unauthenticated";
|
|
440
|
+
export type ProviderDiscoveryStatus = "idle" | "checking" | "ok" | "cached" | "unavailable" | "unauthenticated";
|
|
433
441
|
|
|
434
442
|
export interface ProviderDiscoveryState {
|
|
435
443
|
provider: string;
|
|
@@ -441,6 +449,53 @@ export interface ProviderDiscoveryState {
|
|
|
441
449
|
error?: string;
|
|
442
450
|
}
|
|
443
451
|
|
|
452
|
+
export type ProviderCredentialSource =
|
|
453
|
+
| "stored-oauth"
|
|
454
|
+
| "stored-api-key"
|
|
455
|
+
| "environment"
|
|
456
|
+
| "runtime"
|
|
457
|
+
| "configuration"
|
|
458
|
+
| "keyless";
|
|
459
|
+
export type ProviderAccessStatus =
|
|
460
|
+
| "unconfigured"
|
|
461
|
+
| "checking"
|
|
462
|
+
| "configured-unverified"
|
|
463
|
+
| "connected"
|
|
464
|
+
| "reauth-required"
|
|
465
|
+
| "unreachable";
|
|
466
|
+
|
|
467
|
+
export interface ProviderAccessState {
|
|
468
|
+
provider: string;
|
|
469
|
+
credentialSource?: ProviderCredentialSource;
|
|
470
|
+
status: ProviderAccessStatus;
|
|
471
|
+
catalogFreshness: "none" | "fresh" | "stale";
|
|
472
|
+
failureReason?: string;
|
|
473
|
+
verifiedAt?: number;
|
|
474
|
+
selectable: boolean;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
export interface ProviderPickerMetadata {
|
|
478
|
+
groupId?: string;
|
|
479
|
+
groupLabel?: string;
|
|
480
|
+
sectionLabel?: string;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
export function sanitizeProviderFailure(reason: string | undefined): string | undefined {
|
|
484
|
+
if (!reason) return undefined;
|
|
485
|
+
return reason
|
|
486
|
+
.replace(/([?&](?:key|token|api[_-]?key|access[_-]?token)=)[^&\s]+/gi, "$1[redacted]")
|
|
487
|
+
.replace(/\b(?:Bearer|Basic)\s+[^\s]+/gi, match => `${match.split(/\s/, 1)[0]} [redacted]`)
|
|
488
|
+
.replace(/\b(?:sk|xox|gh[opusr])[-_][A-Za-z0-9._-]{8,}\b/g, "[redacted]")
|
|
489
|
+
.slice(0, 240);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function isProviderAuthenticationFailure(reason: string | undefined): boolean {
|
|
493
|
+
return (
|
|
494
|
+
!!reason &&
|
|
495
|
+
/(?:\b401\b|\b403\b|unauthori[sz]ed|forbidden|invalid[_ -]grant|invalid[_ -]token|reauth)/i.test(reason)
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
|
|
444
499
|
export interface CanonicalModelQueryOptions {
|
|
445
500
|
availableOnly?: boolean;
|
|
446
501
|
candidates?: readonly Model<Api>[];
|
|
@@ -451,6 +506,8 @@ interface CustomModelsResult {
|
|
|
451
506
|
models?: CustomModelOverlay[];
|
|
452
507
|
overrides?: Map<string, ProviderOverride>;
|
|
453
508
|
modelOverrides?: Map<string, Map<string, ModelOverride>>;
|
|
509
|
+
modelAllowlists?: Map<string, Set<string>>;
|
|
510
|
+
pickerMetadata?: Map<string, ProviderPickerMetadata>;
|
|
454
511
|
keylessProviders?: Set<string>;
|
|
455
512
|
discoverableProviders?: DiscoveryProviderConfig[];
|
|
456
513
|
configuredProviders?: Set<string>;
|
|
@@ -784,11 +841,14 @@ export class ModelRegistry {
|
|
|
784
841
|
#customModelOverlays: CustomModelOverlay[] = [];
|
|
785
842
|
#providerOverrides: Map<string, ProviderOverride> = new Map();
|
|
786
843
|
#modelOverrides: Map<string, Map<string, ModelOverride>> = new Map();
|
|
844
|
+
#modelAllowlists: Map<string, Set<string>> = new Map();
|
|
845
|
+
#pickerMetadata: Map<string, ProviderPickerMetadata> = new Map();
|
|
787
846
|
#equivalenceConfig: ModelEquivalenceConfig | undefined;
|
|
788
847
|
#configError: ConfigError | undefined = undefined;
|
|
789
848
|
#modelsConfigFile: ConfigFile<ModelsConfig>;
|
|
790
849
|
#registeredProviderSources: Set<string> = new Set();
|
|
791
850
|
#providerDiscoveryStates: Map<string, ProviderDiscoveryState> = new Map();
|
|
851
|
+
#lastCredentialSources: Map<string, ProviderCredentialSource> = new Map();
|
|
792
852
|
#cacheDbPath?: string;
|
|
793
853
|
#suppressedSelectors: Map<string, number> = new Map();
|
|
794
854
|
#backgroundRefresh?: Promise<void>;
|
|
@@ -893,17 +953,47 @@ export class ModelRegistry {
|
|
|
893
953
|
}
|
|
894
954
|
|
|
895
955
|
refreshProvider(providerId: string, strategy: ModelRefreshStrategy = "online"): Promise<void> {
|
|
896
|
-
return this
|
|
897
|
-
}
|
|
956
|
+
return this.refreshProviders([providerId], strategy);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
refreshProviders(providerIds: readonly string[], strategy: ModelRefreshStrategy = "online"): Promise<void> {
|
|
960
|
+
return this.#enqueueRefresh(async () => {
|
|
961
|
+
const disabled = getDisabledProviderIdsFromSettings();
|
|
962
|
+
const providers = [...new Set(providerIds)].filter(provider => !disabled.has(provider));
|
|
963
|
+
const previousStates = new Map<string, ProviderDiscoveryState | undefined>();
|
|
964
|
+
for (const providerId of providers) {
|
|
965
|
+
const credentialSource = this.#keylessProviders.has(providerId)
|
|
966
|
+
? "keyless"
|
|
967
|
+
: this.authStorage.getCredentialSource(providerId);
|
|
968
|
+
if (credentialSource) this.#lastCredentialSources.set(providerId, credentialSource);
|
|
969
|
+
const previous = this.#providerDiscoveryStates.get(providerId);
|
|
970
|
+
previousStates.set(providerId, previous);
|
|
971
|
+
this.#providerDiscoveryStates.set(providerId, {
|
|
972
|
+
provider: providerId,
|
|
973
|
+
status: "checking",
|
|
974
|
+
optional: previous?.optional ?? false,
|
|
975
|
+
stale: previous?.stale ?? true,
|
|
976
|
+
fetchedAt: previous?.fetchedAt,
|
|
977
|
+
models: previous?.models ?? [],
|
|
978
|
+
});
|
|
979
|
+
for (const selector of this.#suppressedSelectors.keys()) {
|
|
980
|
+
if (selector.startsWith(`${providerId}/`)) this.#suppressedSelectors.delete(selector);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
898
983
|
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
984
|
+
try {
|
|
985
|
+
for (let index = 0; index < providers.length; index += 4) {
|
|
986
|
+
await this.#refreshRuntimeDiscoveries(strategy, new Set(providers.slice(index, index + 4)));
|
|
987
|
+
}
|
|
988
|
+
} finally {
|
|
989
|
+
for (const providerId of providers) {
|
|
990
|
+
if (this.#providerDiscoveryStates.get(providerId)?.status !== "checking") continue;
|
|
991
|
+
const previous = previousStates.get(providerId);
|
|
992
|
+
if (previous) this.#providerDiscoveryStates.set(providerId, previous);
|
|
993
|
+
else this.#providerDiscoveryStates.delete(providerId);
|
|
994
|
+
}
|
|
904
995
|
}
|
|
905
|
-
}
|
|
906
|
-
await this.#refreshRuntimeDiscoveries(strategy, new Set([providerId]));
|
|
996
|
+
});
|
|
907
997
|
}
|
|
908
998
|
|
|
909
999
|
#reloadStaticModels(): void {
|
|
@@ -918,6 +1008,9 @@ export class ModelRegistry {
|
|
|
918
1008
|
}
|
|
919
1009
|
this.#providerOverrides.clear();
|
|
920
1010
|
this.#modelOverrides.clear();
|
|
1011
|
+
this.#modelAllowlists.clear();
|
|
1012
|
+
this.#pickerMetadata.clear();
|
|
1013
|
+
this.#lastCredentialSources.clear();
|
|
921
1014
|
this.#equivalenceConfig = undefined;
|
|
922
1015
|
this.#configError = undefined;
|
|
923
1016
|
this.#providerDiscoveryStates.clear();
|
|
@@ -937,6 +1030,8 @@ export class ModelRegistry {
|
|
|
937
1030
|
models: customModels = [],
|
|
938
1031
|
overrides = new Map(),
|
|
939
1032
|
modelOverrides = new Map(),
|
|
1033
|
+
modelAllowlists = new Map(),
|
|
1034
|
+
pickerMetadata = new Map(),
|
|
940
1035
|
keylessProviders = new Set(),
|
|
941
1036
|
discoverableProviders = [],
|
|
942
1037
|
configuredProviders = new Set(),
|
|
@@ -950,6 +1045,8 @@ export class ModelRegistry {
|
|
|
950
1045
|
this.#customModelOverlays = customModels;
|
|
951
1046
|
this.#providerOverrides = overrides;
|
|
952
1047
|
this.#modelOverrides = modelOverrides;
|
|
1048
|
+
this.#modelAllowlists = modelAllowlists;
|
|
1049
|
+
this.#pickerMetadata = pickerMetadata;
|
|
953
1050
|
this.#equivalenceConfig = equivalence;
|
|
954
1051
|
|
|
955
1052
|
this.#addImplicitDiscoverableProviders(configuredProviders);
|
|
@@ -960,7 +1057,7 @@ export class ModelRegistry {
|
|
|
960
1057
|
// Merge runtime extension models so they survive refresh() cycles
|
|
961
1058
|
const combined = this.#mergeCustomModels(withConfigModels, this.#runtimeModelOverlays);
|
|
962
1059
|
|
|
963
|
-
this.#models = this.#applyModelOverrides(combined, this.#modelOverrides);
|
|
1060
|
+
this.#models = this.#applyProviderModelAllowlists(this.#applyModelOverrides(combined, this.#modelOverrides));
|
|
964
1061
|
this.#rebuildCanonicalIndex();
|
|
965
1062
|
}
|
|
966
1063
|
|
|
@@ -1033,6 +1130,13 @@ export class ModelRegistry {
|
|
|
1033
1130
|
return merged;
|
|
1034
1131
|
}
|
|
1035
1132
|
|
|
1133
|
+
#applyProviderModelAllowlists(models: Model<Api>[]): Model<Api>[] {
|
|
1134
|
+
return models.filter(model => {
|
|
1135
|
+
const allowlist = this.#modelAllowlists.get(model.provider);
|
|
1136
|
+
return !allowlist || allowlist.has(model.id);
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1036
1140
|
#loadCachedDiscoverableModels(): Model<Api>[] {
|
|
1037
1141
|
const cachedModels: Model<Api>[] = [];
|
|
1038
1142
|
for (const providerConfig of this.#discoverableProviders) {
|
|
@@ -1159,12 +1263,18 @@ export class ModelRegistry {
|
|
|
1159
1263
|
|
|
1160
1264
|
const overrides = new Map<string, ProviderOverride>();
|
|
1161
1265
|
const allModelOverrides = new Map<string, Map<string, ModelOverride>>();
|
|
1266
|
+
const modelAllowlists = new Map<string, Set<string>>();
|
|
1267
|
+
const pickerMetadata = new Map<string, ProviderPickerMetadata>();
|
|
1162
1268
|
const keylessProviders = new Set<string>();
|
|
1163
1269
|
const discoverableProviders: DiscoveryProviderConfig[] = [];
|
|
1164
1270
|
const providerEntries = Object.entries(value.providers ?? {});
|
|
1165
1271
|
const configuredProviders = new Set(Object.keys(value.providers ?? {}));
|
|
1166
1272
|
|
|
1167
1273
|
for (const [providerName, providerConfig] of providerEntries) {
|
|
1274
|
+
if (providerConfig.modelAllowlist) {
|
|
1275
|
+
modelAllowlists.set(providerName, new Set(providerConfig.modelAllowlist));
|
|
1276
|
+
}
|
|
1277
|
+
if (providerConfig.picker) pickerMetadata.set(providerName, providerConfig.picker);
|
|
1168
1278
|
// Always set overrides when baseUrl/headers/apiKey/compat are present
|
|
1169
1279
|
if (providerConfig.baseUrl || providerConfig.headers || providerConfig.apiKey || providerConfig.compat) {
|
|
1170
1280
|
overrides.set(providerName, {
|
|
@@ -1211,6 +1321,8 @@ export class ModelRegistry {
|
|
|
1211
1321
|
models: this.#parseModels(value),
|
|
1212
1322
|
overrides,
|
|
1213
1323
|
modelOverrides: allModelOverrides,
|
|
1324
|
+
modelAllowlists,
|
|
1325
|
+
pickerMetadata,
|
|
1214
1326
|
keylessProviders,
|
|
1215
1327
|
discoverableProviders,
|
|
1216
1328
|
configuredProviders,
|
|
@@ -1274,7 +1386,7 @@ export class ModelRegistry {
|
|
|
1274
1386
|
const withConfigModels = this.#mergeCustomModels(resolved, this.#customModelOverlays);
|
|
1275
1387
|
// Merge runtime extension models so they survive online discovery completion
|
|
1276
1388
|
const combined = this.#mergeCustomModels(withConfigModels, this.#runtimeModelOverlays);
|
|
1277
|
-
this.#models = this.#applyModelOverrides(combined, this.#modelOverrides);
|
|
1389
|
+
this.#models = this.#applyProviderModelAllowlists(this.#applyModelOverrides(combined, this.#modelOverrides));
|
|
1278
1390
|
this.#rebuildCanonicalIndex();
|
|
1279
1391
|
}
|
|
1280
1392
|
|
|
@@ -1322,9 +1434,11 @@ export class ModelRegistry {
|
|
|
1322
1434
|
});
|
|
1323
1435
|
const result = await manager.refresh(strategy);
|
|
1324
1436
|
const status = discoveryError
|
|
1325
|
-
?
|
|
1326
|
-
? "
|
|
1327
|
-
:
|
|
1437
|
+
? isProviderAuthenticationFailure(discoveryError)
|
|
1438
|
+
? "unauthenticated"
|
|
1439
|
+
: result.models.length > 0
|
|
1440
|
+
? "cached"
|
|
1441
|
+
: "unavailable"
|
|
1328
1442
|
: !result.stale && strategy !== "offline"
|
|
1329
1443
|
? "ok"
|
|
1330
1444
|
: cached
|
|
@@ -1471,7 +1585,29 @@ export class ModelRegistry {
|
|
|
1471
1585
|
selected(descriptor.providerId) ? this.getApiKeyForProvider(descriptor.providerId) : undefined;
|
|
1472
1586
|
const [standardProviderKeys, specialKeys] = await Promise.all([
|
|
1473
1587
|
Promise.all(PROVIDER_DESCRIPTORS.map(peekKey)),
|
|
1474
|
-
Promise.all(
|
|
1588
|
+
Promise.all(
|
|
1589
|
+
specialProviderDescriptors.map(async descriptor => {
|
|
1590
|
+
try {
|
|
1591
|
+
return await resolveSpecialKey(descriptor);
|
|
1592
|
+
} catch (error) {
|
|
1593
|
+
if (selected(descriptor.providerId)) {
|
|
1594
|
+
const previous = this.#providerDiscoveryStates.get(descriptor.providerId);
|
|
1595
|
+
this.#providerDiscoveryStates.set(descriptor.providerId, {
|
|
1596
|
+
provider: descriptor.providerId,
|
|
1597
|
+
status: isProviderAuthenticationFailure(error instanceof Error ? error.message : String(error))
|
|
1598
|
+
? "unauthenticated"
|
|
1599
|
+
: "unavailable",
|
|
1600
|
+
optional: false,
|
|
1601
|
+
stale: true,
|
|
1602
|
+
fetchedAt: previous?.fetchedAt,
|
|
1603
|
+
models: previous?.models ?? [],
|
|
1604
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
return undefined;
|
|
1608
|
+
}
|
|
1609
|
+
}),
|
|
1610
|
+
),
|
|
1475
1611
|
]);
|
|
1476
1612
|
const options: ModelManagerOptions<Api>[] = [];
|
|
1477
1613
|
for (let i = 0; i < PROVIDER_DESCRIPTORS.length; i++) {
|
|
@@ -1484,6 +1620,16 @@ export class ModelRegistry {
|
|
|
1484
1620
|
baseUrl: this.getProviderBaseUrl(descriptor.providerId),
|
|
1485
1621
|
}),
|
|
1486
1622
|
);
|
|
1623
|
+
} else if (selected(descriptor.providerId) && this.authStorage.getCredentialSource(descriptor.providerId)) {
|
|
1624
|
+
const previous = this.#providerDiscoveryStates.get(descriptor.providerId);
|
|
1625
|
+
this.#providerDiscoveryStates.set(descriptor.providerId, {
|
|
1626
|
+
provider: descriptor.providerId,
|
|
1627
|
+
status: "unauthenticated",
|
|
1628
|
+
optional: false,
|
|
1629
|
+
stale: true,
|
|
1630
|
+
fetchedAt: previous?.fetchedAt,
|
|
1631
|
+
models: previous?.models ?? [],
|
|
1632
|
+
});
|
|
1487
1633
|
}
|
|
1488
1634
|
}
|
|
1489
1635
|
|
|
@@ -1554,14 +1700,19 @@ export class ModelRegistry {
|
|
|
1554
1700
|
previous && (previous.status === "ok" || previous.status === "cached") && previous.models.length > 0
|
|
1555
1701
|
? previous
|
|
1556
1702
|
: undefined;
|
|
1703
|
+
const failureReason = error instanceof Error ? error.message : String(error);
|
|
1557
1704
|
this.#providerDiscoveryStates.set(options.providerId, {
|
|
1558
1705
|
provider: options.providerId,
|
|
1559
|
-
status:
|
|
1706
|
+
status: isProviderAuthenticationFailure(failureReason)
|
|
1707
|
+
? "unauthenticated"
|
|
1708
|
+
: retained
|
|
1709
|
+
? "cached"
|
|
1710
|
+
: "unavailable",
|
|
1560
1711
|
optional: false,
|
|
1561
1712
|
stale: true,
|
|
1562
1713
|
fetchedAt: retained?.fetchedAt,
|
|
1563
1714
|
models: retained?.models ?? [],
|
|
1564
|
-
error:
|
|
1715
|
+
error: failureReason,
|
|
1565
1716
|
});
|
|
1566
1717
|
logger.warn("model discovery failed for provider", {
|
|
1567
1718
|
provider: options.providerId,
|
|
@@ -1887,9 +2038,11 @@ export class ModelRegistry {
|
|
|
1887
2038
|
}
|
|
1888
2039
|
|
|
1889
2040
|
#applyProviderModelOverrides(provider: string, models: Model<Api>[]): Model<Api>[] {
|
|
2041
|
+
const allowlist = this.#modelAllowlists.get(provider);
|
|
2042
|
+
const allowedModels = allowlist ? models.filter(model => allowlist.has(model.id)) : models;
|
|
1890
2043
|
const overrides = this.#modelOverrides.get(provider);
|
|
1891
|
-
if (!overrides || overrides.size === 0) return
|
|
1892
|
-
return
|
|
2044
|
+
if (!overrides || overrides.size === 0) return allowedModels;
|
|
2045
|
+
return allowedModels.map(model => {
|
|
1893
2046
|
const override = overrides.get(model.id);
|
|
1894
2047
|
if (!override) return model;
|
|
1895
2048
|
return applyModelOverride(model, override);
|
|
@@ -2142,6 +2295,42 @@ export class ModelRegistry {
|
|
|
2142
2295
|
return this.#providerDiscoveryStates.get(provider);
|
|
2143
2296
|
}
|
|
2144
2297
|
|
|
2298
|
+
getProviderPickerMetadata(provider: string): ProviderPickerMetadata | undefined {
|
|
2299
|
+
return this.#pickerMetadata.get(provider);
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
getProviderAccessState(provider: string): ProviderAccessState {
|
|
2303
|
+
const groupId = this.#pickerMetadata.get(provider)?.groupId;
|
|
2304
|
+
const discovery =
|
|
2305
|
+
this.#providerDiscoveryStates.get(provider) ??
|
|
2306
|
+
(groupId
|
|
2307
|
+
? [...this.#pickerMetadata.entries()]
|
|
2308
|
+
.filter(([, metadata]) => metadata.groupId === groupId)
|
|
2309
|
+
.map(([groupProvider]) => this.#providerDiscoveryStates.get(groupProvider))
|
|
2310
|
+
.find(Boolean)
|
|
2311
|
+
: undefined);
|
|
2312
|
+
const credentialSource: ProviderCredentialSource | undefined = this.#keylessProviders.has(provider)
|
|
2313
|
+
? "keyless"
|
|
2314
|
+
: (this.authStorage.getCredentialSource(provider) ?? this.#lastCredentialSources.get(provider));
|
|
2315
|
+
const catalogFreshness = discovery?.stale ? "stale" : discovery?.status === "ok" ? "fresh" : "none";
|
|
2316
|
+
let status: ProviderAccessStatus;
|
|
2317
|
+
if (!credentialSource) status = "unconfigured";
|
|
2318
|
+
else if (discovery?.status === "checking") status = "checking";
|
|
2319
|
+
else if (discovery?.status === "unauthenticated") status = "reauth-required";
|
|
2320
|
+
else if (discovery?.status === "unavailable" || discovery?.status === "cached") status = "unreachable";
|
|
2321
|
+
else if (discovery?.status === "ok") status = "connected";
|
|
2322
|
+
else status = "configured-unverified";
|
|
2323
|
+
return {
|
|
2324
|
+
provider,
|
|
2325
|
+
credentialSource,
|
|
2326
|
+
status,
|
|
2327
|
+
catalogFreshness,
|
|
2328
|
+
failureReason: sanitizeProviderFailure(discovery?.error),
|
|
2329
|
+
verifiedAt: discovery?.status === "ok" ? discovery.fetchedAt : undefined,
|
|
2330
|
+
selectable: (status === "connected" || status === "configured-unverified") && !discovery?.stale,
|
|
2331
|
+
};
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2145
2334
|
/**
|
|
2146
2335
|
* Find a model by provider and ID.
|
|
2147
2336
|
*/
|
|
@@ -276,6 +276,10 @@ export const SETTINGS_SCHEMA = {
|
|
|
276
276
|
|
|
277
277
|
modelProviderOrder: { type: "array", default: EMPTY_STRING_ARRAY },
|
|
278
278
|
|
|
279
|
+
// Restricts only normal /model picker visibility. Explicit CLI model scopes
|
|
280
|
+
// continue to resolve against the complete configured registry.
|
|
281
|
+
modelProviderAllowlist: { type: "array", default: EMPTY_STRING_ARRAY },
|
|
282
|
+
|
|
279
283
|
cycleOrder: { type: "array", default: DEFAULT_CYCLE_ORDER },
|
|
280
284
|
|
|
281
285
|
// ────────────────────────────────────────────────────────────────────────
|
|
@@ -17,17 +17,17 @@ export interface BuildInfo {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const BUILD_INFO: BuildInfo = {
|
|
20
|
-
"version": "21.19.
|
|
21
|
-
"commit": "
|
|
22
|
-
"shortCommit": "
|
|
20
|
+
"version": "21.19.2",
|
|
21
|
+
"commit": "746a32333421a84686abe7db03a12c95841d020c",
|
|
22
|
+
"shortCommit": "746a323",
|
|
23
23
|
"branch": "main",
|
|
24
|
-
"tag": "v21.19.
|
|
25
|
-
"commitDate": "2026-09-
|
|
26
|
-
"buildDate": "2026-09-
|
|
24
|
+
"tag": "v21.19.2",
|
|
25
|
+
"commitDate": "2026-09-08T23:33:56+00:00",
|
|
26
|
+
"buildDate": "2026-09-09T00:25:22.545Z",
|
|
27
27
|
"dirty": true,
|
|
28
28
|
"prNumber": "",
|
|
29
29
|
"repoUrl": "https://github.com/f5-sales-demo/xcsh",
|
|
30
30
|
"repoSlug": "f5-sales-demo/xcsh",
|
|
31
|
-
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/
|
|
32
|
-
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.19.
|
|
31
|
+
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/746a32333421a84686abe7db03a12c95841d020c",
|
|
32
|
+
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.19.2"
|
|
33
33
|
};
|
|
@@ -13,7 +13,13 @@ import {
|
|
|
13
13
|
truncateToWidth,
|
|
14
14
|
visibleWidth,
|
|
15
15
|
} from "@f5-sales-demo/pi-tui";
|
|
16
|
-
import type {
|
|
16
|
+
import type {
|
|
17
|
+
ModelRegistry,
|
|
18
|
+
ProviderAccessState,
|
|
19
|
+
ProviderDiscoveryState,
|
|
20
|
+
ProviderDiscoveryStatus,
|
|
21
|
+
ProviderPickerMetadata,
|
|
22
|
+
} from "../../config/model-registry";
|
|
17
23
|
import { getKnownRoleIds, getRoleInfo, MODEL_ROLE_IDS, MODEL_ROLES } from "../../config/model-registry";
|
|
18
24
|
import { resolveModelRoleValue } from "../../config/model-resolver";
|
|
19
25
|
import type { Settings } from "../../config/settings";
|
|
@@ -50,6 +56,9 @@ export interface ModelItem {
|
|
|
50
56
|
id: string;
|
|
51
57
|
model: Model;
|
|
52
58
|
selector: string;
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
sectionLabel?: string;
|
|
61
|
+
groupId?: string;
|
|
53
62
|
}
|
|
54
63
|
|
|
55
64
|
interface CanonicalModelItem {
|
|
@@ -120,7 +129,7 @@ function getModelFamily(model: Model): string {
|
|
|
120
129
|
function modelHierarchyKey(item: ModelItem, includeProvider: boolean): string {
|
|
121
130
|
return [
|
|
122
131
|
includeProvider ? getProviderDisplayName(item.provider) : "",
|
|
123
|
-
getModelPublisher(item.model),
|
|
132
|
+
item.sectionLabel ?? getModelPublisher(item.model),
|
|
124
133
|
getModelFamily(item.model),
|
|
125
134
|
]
|
|
126
135
|
.join("\0")
|
|
@@ -219,13 +228,21 @@ export interface ProviderModelGroup {
|
|
|
219
228
|
providers: string[];
|
|
220
229
|
}
|
|
221
230
|
|
|
222
|
-
function modelItems(
|
|
231
|
+
function modelItems(
|
|
232
|
+
models: readonly Model[],
|
|
233
|
+
currentOnly = true,
|
|
234
|
+
getPickerMetadata: (provider: string) => ProviderPickerMetadata | undefined = () => undefined,
|
|
235
|
+
getAccessState: (provider: string) => ProviderAccessState | undefined = () => undefined,
|
|
236
|
+
): ModelItem[] {
|
|
223
237
|
return presentModelsForDefaultPicker(currentOnly ? filterCurrentBrowserModels(models) : models).map(item => ({
|
|
224
238
|
kind: "provider",
|
|
225
239
|
provider: item.model.provider,
|
|
226
240
|
id: item.displaySelector.slice(item.displaySelector.indexOf("/") + 1),
|
|
227
241
|
model: item.model,
|
|
228
242
|
selector: item.selector,
|
|
243
|
+
disabled: getAccessState(item.model.provider)?.selectable === false,
|
|
244
|
+
sectionLabel: getPickerMetadata(item.model.provider)?.sectionLabel,
|
|
245
|
+
groupId: getPickerMetadata(item.model.provider)?.groupId,
|
|
229
246
|
}));
|
|
230
247
|
}
|
|
231
248
|
|
|
@@ -238,39 +255,58 @@ export function buildProviderModelGroups(
|
|
|
238
255
|
hasAuth: (provider: string) => boolean = () => true,
|
|
239
256
|
currentOnly = true,
|
|
240
257
|
inventory: readonly string[] = [],
|
|
258
|
+
getPickerMetadata: (provider: string) => ProviderPickerMetadata | undefined = () => undefined,
|
|
259
|
+
getAccessState: (provider: string) => ProviderAccessState | undefined = () => undefined,
|
|
241
260
|
): ProviderModelGroup[] {
|
|
242
|
-
const items = modelItems(models, currentOnly);
|
|
261
|
+
const items = modelItems(models, currentOnly, getPickerMetadata, getAccessState);
|
|
243
262
|
const byProvider = new Map<string, ModelItem[]>();
|
|
244
263
|
for (const item of items) {
|
|
245
|
-
const providerItems = byProvider.get(item.provider) ?? [];
|
|
264
|
+
const providerItems = byProvider.get(item.groupId ?? item.provider) ?? [];
|
|
246
265
|
providerItems.push(item);
|
|
247
|
-
byProvider.set(item.provider, providerItems);
|
|
266
|
+
byProvider.set(item.groupId ?? item.provider, providerItems);
|
|
248
267
|
}
|
|
249
268
|
|
|
250
269
|
for (const provider of inventory) {
|
|
251
|
-
|
|
270
|
+
const groupId = getPickerMetadata(provider)?.groupId ?? provider;
|
|
271
|
+
if (!byProvider.has(groupId)) byProvider.set(groupId, []);
|
|
252
272
|
}
|
|
253
273
|
const authenticated: ProviderModelGroup[] = [];
|
|
254
274
|
const localProviders: string[] = [];
|
|
255
275
|
const localItems: ModelItem[] = [];
|
|
256
276
|
let localStale = false;
|
|
257
|
-
for (const [
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
277
|
+
for (const [groupId, providerItems] of byProvider) {
|
|
278
|
+
const providers = [
|
|
279
|
+
...new Set([
|
|
280
|
+
...providerItems.map(item => item.provider),
|
|
281
|
+
...inventory.filter(provider => (getPickerMetadata(provider)?.groupId ?? provider) === groupId),
|
|
282
|
+
]),
|
|
283
|
+
];
|
|
284
|
+
const discovery = providers.map(provider => getDiscoveryState(provider)).find(Boolean);
|
|
285
|
+
if (providers.length > 0 && providers.every(provider => LOCAL_PROVIDER_IDS.has(provider))) {
|
|
286
|
+
localProviders.push(...providers);
|
|
261
287
|
localStale ||= discovery?.status !== "ok" || discovery.stale;
|
|
262
288
|
localItems.push(...providerItems);
|
|
263
289
|
continue;
|
|
264
290
|
}
|
|
265
|
-
if (!hasAuth(provider)
|
|
291
|
+
if (!providers.some(provider => hasAuth(provider) || inventory.includes(provider))) continue;
|
|
266
292
|
sortModelsByHierarchy(providerItems, false);
|
|
293
|
+
const accessStates = providers.map(provider => getAccessState(provider)).filter(state => state !== undefined);
|
|
294
|
+
const statuses = accessStates.map(state => state.status);
|
|
295
|
+
const groupMetadata = providers.map(getPickerMetadata).find(metadata => metadata?.groupLabel);
|
|
267
296
|
authenticated.push({
|
|
268
|
-
id:
|
|
269
|
-
label: getProviderDisplayName(
|
|
297
|
+
id: groupId,
|
|
298
|
+
label: groupMetadata?.groupLabel ?? getProviderDisplayName(groupId),
|
|
270
299
|
classification: "authenticated",
|
|
271
|
-
discoveryStatus:
|
|
272
|
-
|
|
273
|
-
|
|
300
|
+
discoveryStatus: statuses.includes("reauth-required")
|
|
301
|
+
? "unauthenticated"
|
|
302
|
+
: providers.some(provider => getDiscoveryState(provider)?.status === "unavailable")
|
|
303
|
+
? "unavailable"
|
|
304
|
+
: (discovery?.status ?? "idle"),
|
|
305
|
+
stale:
|
|
306
|
+
accessStates.length > 0
|
|
307
|
+
? accessStates.some(state => state.catalogFreshness === "stale")
|
|
308
|
+
: providers.some(provider => getDiscoveryState(provider)?.stale ?? true),
|
|
309
|
+
providers,
|
|
274
310
|
models: providerItems,
|
|
275
311
|
});
|
|
276
312
|
}
|
|
@@ -281,8 +317,8 @@ export function buildProviderModelGroups(
|
|
|
281
317
|
if (normalized && !configuredRank.has(normalized)) configuredRank.set(normalized, configuredRank.size);
|
|
282
318
|
}
|
|
283
319
|
authenticated.sort((left, right) => {
|
|
284
|
-
if (left.
|
|
285
|
-
if (right.
|
|
320
|
+
if (left.providers.includes(currentProvider ?? "") && !right.providers.includes(currentProvider ?? "")) return -1;
|
|
321
|
+
if (right.providers.includes(currentProvider ?? "") && !left.providers.includes(currentProvider ?? "")) return 1;
|
|
286
322
|
const leftRank = configuredRank.get(left.id.toLowerCase()) ?? Number.MAX_SAFE_INTEGER;
|
|
287
323
|
const rightRank = configuredRank.get(right.id.toLowerCase()) ?? Number.MAX_SAFE_INTEGER;
|
|
288
324
|
if (leftRank !== rightRank) return leftRank - rightRank;
|
|
@@ -483,13 +519,10 @@ export class ModelSelectorComponent extends Container {
|
|
|
483
519
|
this.addChild(new DynamicBorder());
|
|
484
520
|
this.addChild(new Spacer(1));
|
|
485
521
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
: "Only showing models from configured providers (see README for details)";
|
|
491
|
-
this.addChild(new Text(theme.fg("warning", hintText), 0, 0));
|
|
492
|
-
this.addChild(new Spacer(1));
|
|
522
|
+
if (scopedModels.length > 0) {
|
|
523
|
+
this.addChild(new Text(theme.fg("warning", "Showing models from --models scope"), 0, 0));
|
|
524
|
+
this.addChild(new Spacer(1));
|
|
525
|
+
}
|
|
493
526
|
|
|
494
527
|
// Create header container for tab bar
|
|
495
528
|
this.#headerContainer = new Container();
|
|
@@ -542,7 +575,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
542
575
|
}
|
|
543
576
|
// Request re-render after models are loaded
|
|
544
577
|
this.#tui.requestRender();
|
|
545
|
-
void this.#
|
|
578
|
+
void this.#refreshVisibleProviders().catch(error => {
|
|
546
579
|
this.#errorMessage = String(error);
|
|
547
580
|
this.#updateList();
|
|
548
581
|
this.#tui.requestRender();
|
|
@@ -743,18 +776,51 @@ export class ModelSelectorComponent extends Container {
|
|
|
743
776
|
}
|
|
744
777
|
|
|
745
778
|
#availableItems(): ModelItem[] {
|
|
746
|
-
const
|
|
779
|
+
const providerAllowlist = new Set(this.#settings.get("modelProviderAllowlist"));
|
|
780
|
+
const providerVisible = (provider: string) => providerAllowlist.size === 0 || providerAllowlist.has(provider);
|
|
781
|
+
const available = this.#modelRegistry
|
|
782
|
+
.getAvailable()
|
|
783
|
+
.filter(model => (this.#scopedModels.length > 0 ? true : providerVisible(model.provider)));
|
|
784
|
+
if (this.#scopedModels.length === 0) {
|
|
785
|
+
for (const model of this.#modelRegistry.getAll()) {
|
|
786
|
+
if (!providerVisible(model.provider) || available.some(candidate => modelsAreEqual(candidate, model)))
|
|
787
|
+
continue;
|
|
788
|
+
const discovery = this.#modelRegistry.getProviderDiscoveryState?.(model.provider);
|
|
789
|
+
if (
|
|
790
|
+
discovery?.stale &&
|
|
791
|
+
discovery.models.includes(model.id) &&
|
|
792
|
+
this.#modelRegistry.getProviderAccessState?.(model.provider)?.status !== "unconfigured"
|
|
793
|
+
) {
|
|
794
|
+
available.push(model);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
747
798
|
const retained = [this.#currentModel, ...Object.values(this.#roles).map(role => role?.model)].filter(
|
|
748
799
|
(model): model is Model => Boolean(model),
|
|
749
800
|
);
|
|
750
|
-
const items = modelItems(
|
|
801
|
+
const items = modelItems(
|
|
802
|
+
available,
|
|
803
|
+
true,
|
|
804
|
+
provider => this.#modelRegistry.getProviderPickerMetadata?.(provider),
|
|
805
|
+
provider => this.#modelRegistry.getProviderAccessState?.(provider),
|
|
806
|
+
);
|
|
751
807
|
for (const model of retained) {
|
|
752
808
|
if (
|
|
753
|
-
|
|
754
|
-
|
|
809
|
+
!providerVisible(model.provider) ||
|
|
810
|
+
(this.#modelRegistry.getProviderInventory &&
|
|
811
|
+
!this.#modelRegistry.getProviderInventory().includes(model.provider))
|
|
755
812
|
)
|
|
756
813
|
continue;
|
|
757
|
-
if (!items.some(item => modelsAreEqual(item.model, model)))
|
|
814
|
+
if (!items.some(item => modelsAreEqual(item.model, model))) {
|
|
815
|
+
items.push(
|
|
816
|
+
...modelItems(
|
|
817
|
+
[model],
|
|
818
|
+
false,
|
|
819
|
+
provider => this.#modelRegistry.getProviderPickerMetadata?.(provider),
|
|
820
|
+
provider => this.#modelRegistry.getProviderAccessState?.(provider),
|
|
821
|
+
),
|
|
822
|
+
);
|
|
823
|
+
}
|
|
758
824
|
}
|
|
759
825
|
return items;
|
|
760
826
|
}
|
|
@@ -779,7 +845,14 @@ export class ModelSelectorComponent extends Container {
|
|
|
779
845
|
this.#modelRegistry.isProviderKeyless?.(provider) ||
|
|
780
846
|
this.#modelRegistry.authStorage.hasAuth(provider),
|
|
781
847
|
false,
|
|
782
|
-
this.#scopedModels.length > 0
|
|
848
|
+
this.#scopedModels.length > 0
|
|
849
|
+
? []
|
|
850
|
+
: (this.#modelRegistry.getProviderInventory?.() ?? []).filter(provider => {
|
|
851
|
+
const allowlist = this.#settings.get("modelProviderAllowlist");
|
|
852
|
+
return allowlist.length === 0 || allowlist.includes(provider);
|
|
853
|
+
}),
|
|
854
|
+
provider => this.#modelRegistry.getProviderPickerMetadata?.(provider),
|
|
855
|
+
provider => this.#modelRegistry.getProviderAccessState?.(provider),
|
|
783
856
|
);
|
|
784
857
|
this.#providers = this.#providerGroups.map(group => group.id);
|
|
785
858
|
const previousIndex = this.#providers.indexOf(previousProvider);
|
|
@@ -810,7 +883,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
810
883
|
}
|
|
811
884
|
}
|
|
812
885
|
try {
|
|
813
|
-
await
|
|
886
|
+
await this.#refreshProviders([...providers]);
|
|
814
887
|
const models = this.#availableItems();
|
|
815
888
|
this.#sortModels(models);
|
|
816
889
|
this.#allModels = models;
|
|
@@ -830,6 +903,43 @@ export class ModelSelectorComponent extends Container {
|
|
|
830
903
|
}
|
|
831
904
|
}
|
|
832
905
|
|
|
906
|
+
async #refreshProviders(providers: readonly string[]): Promise<void> {
|
|
907
|
+
if (typeof this.#modelRegistry.refreshProviders === "function") {
|
|
908
|
+
await this.#modelRegistry.refreshProviders(providers, "online");
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
await Promise.all(providers.map(provider => this.#modelRegistry.refreshProvider(provider, "online")));
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
async #refreshVisibleProviders(): Promise<void> {
|
|
915
|
+
const activeGroup = this.#providerGroups[this.#activeTabIndex];
|
|
916
|
+
if (!activeGroup || typeof this.#modelRegistry.refreshProvider !== "function") return;
|
|
917
|
+
const providers = [...new Set(this.#providerGroups.flatMap(group => group.providers))];
|
|
918
|
+
this.#refreshingProvider = activeGroup.id;
|
|
919
|
+
this.#pendingRefreshes++;
|
|
920
|
+
if (!this.#spinnerTimer) {
|
|
921
|
+
this.#spinnerTimer = setInterval(() => {
|
|
922
|
+
this.#spinnerFrame++;
|
|
923
|
+
this.#tui.requestRender();
|
|
924
|
+
}, 80);
|
|
925
|
+
this.#spinnerTimer.unref();
|
|
926
|
+
}
|
|
927
|
+
this.#updateList();
|
|
928
|
+
try {
|
|
929
|
+
await this.#refreshProviders(providers);
|
|
930
|
+
const models = this.#availableItems();
|
|
931
|
+
this.#sortModels(models);
|
|
932
|
+
this.#allModels = models;
|
|
933
|
+
this.#buildProviderTabs();
|
|
934
|
+
this.#updateTabBar();
|
|
935
|
+
this.#applyTabFilter();
|
|
936
|
+
} finally {
|
|
937
|
+
if (--this.#pendingRefreshes === 0) this.#stopSpinner();
|
|
938
|
+
if (this.#refreshingProvider === activeGroup.id) this.#refreshingProvider = undefined;
|
|
939
|
+
this.#updateList();
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
833
943
|
#updateTabBar(): void {
|
|
834
944
|
this.#headerContainer.clear();
|
|
835
945
|
|
|
@@ -981,6 +1091,8 @@ export class ModelSelectorComponent extends Container {
|
|
|
981
1091
|
return " Provider requires authentication before models can be discovered.";
|
|
982
1092
|
case "idle":
|
|
983
1093
|
return " Provider has not been refreshed yet.";
|
|
1094
|
+
case "checking":
|
|
1095
|
+
return " Checking provider availability…";
|
|
984
1096
|
case "ok":
|
|
985
1097
|
return " Provider reported no models.";
|
|
986
1098
|
}
|
|
@@ -1010,15 +1122,12 @@ export class ModelSelectorComponent extends Container {
|
|
|
1010
1122
|
if (!item) continue;
|
|
1011
1123
|
const canonicalItem = isCanonicalTab ? (item as CanonicalModelItem) : undefined;
|
|
1012
1124
|
const providerItem = isCanonicalTab ? undefined : (item as ModelItem);
|
|
1125
|
+
const sectionLabel = providerItem?.sectionLabel ?? getModelPublisher(item.model);
|
|
1013
1126
|
const group = showProvider
|
|
1014
|
-
? [
|
|
1015
|
-
getProviderDisplayName(providerItem?.provider ?? ""),
|
|
1016
|
-
getModelPublisher(item.model),
|
|
1017
|
-
getModelFamily(item.model),
|
|
1018
|
-
]
|
|
1127
|
+
? [getProviderDisplayName(providerItem?.provider ?? ""), sectionLabel, getModelFamily(item.model)]
|
|
1019
1128
|
.filter(Boolean)
|
|
1020
1129
|
.join(" › ")
|
|
1021
|
-
: [
|
|
1130
|
+
: [sectionLabel, getModelFamily(item.model)].filter(Boolean).join(" › ");
|
|
1022
1131
|
if (group && group !== previousGroup) {
|
|
1023
1132
|
if (previousGroup) this.#listContainer.addChild(new Spacer(1));
|
|
1024
1133
|
this.#listContainer.addChild(new Text(theme.fg("muted", ` ${group}`), 0, 0));
|
|
@@ -1050,6 +1159,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
1050
1159
|
const badgeText = roleBadgeTokens.length > 0 ? ` ${roleBadgeTokens.join(" ")}` : "";
|
|
1051
1160
|
|
|
1052
1161
|
let line = "";
|
|
1162
|
+
const disabled = !isCanonicalTab && providerItem ? this.#isItemDisabled(providerItem) : false;
|
|
1053
1163
|
if (isSelected) {
|
|
1054
1164
|
const prefix = theme.fg("accent", `${theme.nav.cursor} `);
|
|
1055
1165
|
if (isCanonicalTab) {
|
|
@@ -1057,7 +1167,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
1057
1167
|
const backing = theme.fg("dim", ` -> ${item.model.provider}/${item.model.id}`);
|
|
1058
1168
|
line = `${prefix}${theme.fg("accent", item.id)}${variants}${backing}${badgeText}`;
|
|
1059
1169
|
} else {
|
|
1060
|
-
line = `${prefix}${theme.fg("accent", getModelDisplayName(item.model))} ${theme.fg("dim", `[${item.selector}]`)}${badgeText}`;
|
|
1170
|
+
line = `${prefix}${theme.fg(disabled ? "dim" : "accent", getModelDisplayName(item.model))} ${theme.fg("dim", `[${item.selector}]`)}${disabled ? theme.fg("warning", " unavailable") : badgeText}`;
|
|
1061
1171
|
}
|
|
1062
1172
|
} else {
|
|
1063
1173
|
const prefix = " ";
|
|
@@ -1066,7 +1176,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
1066
1176
|
const backing = theme.fg("dim", ` -> ${item.model.provider}/${item.model.id}`);
|
|
1067
1177
|
line = `${prefix}${item.id}${variants}${backing}${badgeText}`;
|
|
1068
1178
|
} else {
|
|
1069
|
-
line = `${prefix}${getModelDisplayName(item.model)} ${theme.fg("dim", `[${item.selector}]`)}${badgeText}`;
|
|
1179
|
+
line = `${prefix}${theme.fg(disabled ? "dim" : "text", getModelDisplayName(item.model))} ${theme.fg("dim", `[${item.selector}]`)}${disabled ? theme.fg("warning", " unavailable") : badgeText}`;
|
|
1070
1180
|
}
|
|
1071
1181
|
}
|
|
1072
1182
|
|
|
@@ -1129,9 +1239,14 @@ export class ModelSelectorComponent extends Container {
|
|
|
1129
1239
|
: this.#filteredModels[this.#selectedIndex];
|
|
1130
1240
|
}
|
|
1131
1241
|
|
|
1242
|
+
#isItemDisabled(item: ModelItem | CanonicalModelItem): boolean {
|
|
1243
|
+
if (item.kind === "canonical" || this.#scopedModels.length > 0) return false;
|
|
1244
|
+
return this.#modelRegistry.getProviderAccessState?.(item.provider)?.selectable === false;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1132
1247
|
#openMenu(): void {
|
|
1133
1248
|
this.#menuItem = this.#getSelectedItem();
|
|
1134
|
-
if (!this.#menuItem) return;
|
|
1249
|
+
if (!this.#menuItem || this.#isItemDisabled(this.#menuItem)) return;
|
|
1135
1250
|
this.#isMenuOpen = true;
|
|
1136
1251
|
this.#menuScope = "conversation";
|
|
1137
1252
|
this.#menuStep = "scope";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { OAuthProviderInfo } from "@f5-sales-demo/pi-ai";
|
|
2
2
|
import { Container, Input, matchesKey, Spacer, Text, TruncatedText } from "@f5-sales-demo/pi-tui";
|
|
3
|
+
import type { ProviderAccessState } from "../../config/model-registry";
|
|
3
4
|
import { theme } from "../../modes/theme/theme";
|
|
4
5
|
import { matchesSelectCancel } from "../../modes/utils/keybinding-matchers";
|
|
5
6
|
import type { AuthStorage } from "../../session/auth-storage";
|
|
@@ -22,6 +23,9 @@ export class OAuthSelectorComponent extends Container {
|
|
|
22
23
|
#onCancelCallback: () => void;
|
|
23
24
|
#statusMessage: string | undefined;
|
|
24
25
|
#validateAuthCallback?: (providerId: string) => Promise<boolean>;
|
|
26
|
+
#getAccessState?: (providerId: string) => ProviderAccessState;
|
|
27
|
+
#validateAccess?: (providerId: string) => Promise<ProviderAccessState>;
|
|
28
|
+
#isExcluded?: (providerId: string) => boolean;
|
|
25
29
|
#requestRenderCallback?: () => void;
|
|
26
30
|
#authState: Map<string, "checking" | "valid" | "invalid"> = new Map();
|
|
27
31
|
#spinnerFrame: number = 0;
|
|
@@ -34,6 +38,9 @@ export class OAuthSelectorComponent extends Container {
|
|
|
34
38
|
onCancel: () => void,
|
|
35
39
|
options?: {
|
|
36
40
|
validateAuth?: (providerId: string) => Promise<boolean>;
|
|
41
|
+
getAccessState?: (providerId: string) => ProviderAccessState;
|
|
42
|
+
validateAccess?: (providerId: string) => Promise<ProviderAccessState>;
|
|
43
|
+
isExcluded?: (providerId: string) => boolean;
|
|
37
44
|
requestRender?: () => void;
|
|
38
45
|
},
|
|
39
46
|
) {
|
|
@@ -43,6 +50,9 @@ export class OAuthSelectorComponent extends Container {
|
|
|
43
50
|
this.#onSelectCallback = onSelect;
|
|
44
51
|
this.#onCancelCallback = onCancel;
|
|
45
52
|
this.#validateAuthCallback = options?.validateAuth;
|
|
53
|
+
this.#getAccessState = options?.getAccessState;
|
|
54
|
+
this.#validateAccess = options?.validateAccess;
|
|
55
|
+
this.#isExcluded = options?.isExcluded;
|
|
46
56
|
this.#requestRenderCallback = options?.requestRender;
|
|
47
57
|
// Load all OAuth providers
|
|
48
58
|
this.#loadProviders();
|
|
@@ -97,13 +107,14 @@ export class OAuthSelectorComponent extends Container {
|
|
|
97
107
|
}
|
|
98
108
|
|
|
99
109
|
#startValidation(): void {
|
|
100
|
-
if (!this.#validateAuthCallback) return;
|
|
110
|
+
if (!this.#validateAuthCallback && !this.#validateAccess) return;
|
|
101
111
|
const generation = this.#validationGeneration + 1;
|
|
102
112
|
this.#validationGeneration = generation;
|
|
103
113
|
|
|
104
114
|
let pending = 0;
|
|
105
115
|
for (const provider of this.#allProviders) {
|
|
106
|
-
|
|
116
|
+
const access = this.#getAccessState?.(provider.id);
|
|
117
|
+
if (!this.#authStorage.hasAuth(provider.id) && access?.credentialSource !== "keyless") {
|
|
107
118
|
this.#authState.delete(provider.id);
|
|
108
119
|
continue;
|
|
109
120
|
}
|
|
@@ -120,16 +131,23 @@ export class OAuthSelectorComponent extends Container {
|
|
|
120
131
|
}
|
|
121
132
|
|
|
122
133
|
async #validateProvider(providerId: string, generation: number): Promise<void> {
|
|
123
|
-
if (!this.#validateAuthCallback) return;
|
|
124
|
-
let
|
|
134
|
+
if (!this.#validateAuthCallback && !this.#validateAccess) return;
|
|
135
|
+
let result: "valid" | "invalid" | undefined;
|
|
125
136
|
try {
|
|
126
|
-
|
|
137
|
+
if (this.#validateAccess) {
|
|
138
|
+
const access = await this.#validateAccess(providerId);
|
|
139
|
+
if (access.status === "connected") result = "valid";
|
|
140
|
+
else if (access.status === "reauth-required") result = "invalid";
|
|
141
|
+
} else {
|
|
142
|
+
result = (await this.#validateAuthCallback!(providerId)) ? "valid" : "invalid";
|
|
143
|
+
}
|
|
127
144
|
} catch {
|
|
128
|
-
|
|
145
|
+
result = undefined;
|
|
129
146
|
}
|
|
130
147
|
|
|
131
148
|
if (generation !== this.#validationGeneration) return;
|
|
132
|
-
this.#authState.set(providerId,
|
|
149
|
+
if (result) this.#authState.set(providerId, result);
|
|
150
|
+
else this.#authState.delete(providerId);
|
|
133
151
|
if (![...this.#authState.values()].includes("checking")) {
|
|
134
152
|
this.#stopSpinner();
|
|
135
153
|
}
|
|
@@ -157,19 +175,28 @@ export class OAuthSelectorComponent extends Container {
|
|
|
157
175
|
}
|
|
158
176
|
|
|
159
177
|
#getStatusIndicator(providerId: string): string {
|
|
178
|
+
const excluded = this.#isExcluded?.(providerId) ? theme.fg("muted", " · excluded from picker") : "";
|
|
160
179
|
const state = this.#authState.get(providerId);
|
|
161
180
|
if (state === "checking") {
|
|
162
181
|
const frameCount = theme.spinnerFrames.length;
|
|
163
182
|
const spinner = frameCount > 0 ? `${theme.spinnerFrames[this.#spinnerFrame % frameCount]} ` : "";
|
|
164
|
-
return theme.fg("warning", ` ${spinner}checking`);
|
|
183
|
+
return theme.fg("warning", ` ${spinner}checking`) + excluded;
|
|
165
184
|
}
|
|
166
|
-
|
|
167
|
-
|
|
185
|
+
const access = this.#getAccessState?.(providerId);
|
|
186
|
+
if (state === "invalid" || access?.status === "reauth-required") {
|
|
187
|
+
return theme.fg("error", ` ${theme.status.error} re-authentication required`) + excluded;
|
|
168
188
|
}
|
|
169
189
|
if (state === "valid") {
|
|
170
|
-
return theme.fg("success", ` ${theme.status.success}
|
|
190
|
+
return theme.fg("success", ` ${theme.status.success} connected`) + excluded;
|
|
171
191
|
}
|
|
172
|
-
|
|
192
|
+
let label = "";
|
|
193
|
+
if (access?.credentialSource === "keyless")
|
|
194
|
+
label = theme.fg("success", ` ${theme.status.success} keyless configured`);
|
|
195
|
+
else if (access?.status === "unreachable") label = theme.fg("warning", ` ${theme.status.warning} unreachable`);
|
|
196
|
+
else if (access?.status === "configured-unverified") label = theme.fg("warning", " credential detected");
|
|
197
|
+
else if (access?.status === "connected") label = theme.fg("success", ` ${theme.status.success} connected`);
|
|
198
|
+
else if (!access && this.#authStorage.hasAuth(providerId)) label = theme.fg("warning", " credential detected");
|
|
199
|
+
return label + excluded;
|
|
173
200
|
}
|
|
174
201
|
#updateList(): void {
|
|
175
202
|
this.#listContainer.clear();
|
|
@@ -25,7 +25,9 @@ interface TransactionSession {
|
|
|
25
25
|
setThinkingLevel(level: ThinkingLevel): void;
|
|
26
26
|
settings: {
|
|
27
27
|
getModelRoles(): Readonly<Record<string, string | undefined>>;
|
|
28
|
+
get?(key: "modelProviderAllowlist"): string[];
|
|
28
29
|
set(key: "modelRoles", value: Record<string, string>): void;
|
|
30
|
+
set(key: "modelProviderAllowlist", value: string[]): void;
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -36,6 +38,7 @@ interface CommitLiteLLMLoginOptions {
|
|
|
36
38
|
probe: ProbeResult;
|
|
37
39
|
choice: LiteLLMLoginModelChoice;
|
|
38
40
|
session: TransactionSession;
|
|
41
|
+
restrictPicker?: boolean;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
interface FileSnapshot {
|
|
@@ -80,6 +83,7 @@ export async function commitLiteLLMLogin(options: CommitLiteLLMLoginOptions): Pr
|
|
|
80
83
|
(entry): entry is [string, string] => entry[1] !== undefined,
|
|
81
84
|
),
|
|
82
85
|
);
|
|
86
|
+
const previousProviderAllowlist = [...(session.settings.get?.("modelProviderAllowlist") ?? [])];
|
|
83
87
|
|
|
84
88
|
try {
|
|
85
89
|
const yml = generateModelsYml(credentials.baseUrl, {
|
|
@@ -95,6 +99,9 @@ export async function commitLiteLLMLogin(options: CommitLiteLLMLoginOptions): Pr
|
|
|
95
99
|
const applied = await applyModelAfterLogin(session, choice);
|
|
96
100
|
if (!applied) throw new Error(`Model unavailable after refresh: ${choice.provider}/${choice.modelId}`);
|
|
97
101
|
session.settings.set("modelRoles", getLiteLLMLoginModelRoles(choice));
|
|
102
|
+
if (options.restrictPicker !== undefined) {
|
|
103
|
+
session.settings.set("modelProviderAllowlist", options.restrictPicker ? ["litellm", "anthropic"] : []);
|
|
104
|
+
}
|
|
98
105
|
} catch (error) {
|
|
99
106
|
const rollbackErrors: unknown[] = [];
|
|
100
107
|
for (const [filePath, snapshot] of [
|
|
@@ -110,6 +117,7 @@ export async function commitLiteLLMLogin(options: CommitLiteLLMLoginOptions): Pr
|
|
|
110
117
|
|
|
111
118
|
try {
|
|
112
119
|
session.settings.set("modelRoles", previousModelRoles);
|
|
120
|
+
session.settings.set("modelProviderAllowlist", previousProviderAllowlist);
|
|
113
121
|
} catch (rollbackError) {
|
|
114
122
|
rollbackErrors.push(rollbackError);
|
|
115
123
|
}
|
|
@@ -634,6 +634,29 @@ export class SelectorController {
|
|
|
634
634
|
return promise;
|
|
635
635
|
}
|
|
636
636
|
|
|
637
|
+
async #showLiteLLMPickerScopeSelector(): Promise<boolean | undefined> {
|
|
638
|
+
const { promise, resolve } = Promise.withResolvers<boolean | undefined>();
|
|
639
|
+
this.showSelector(done => {
|
|
640
|
+
const selector = new HookSelectorComponent(
|
|
641
|
+
"Restrict the normal model picker to LiteLLM?",
|
|
642
|
+
["Yes — show only LiteLLM", "No — keep all configured providers"],
|
|
643
|
+
option => {
|
|
644
|
+
done();
|
|
645
|
+
resolve(option.startsWith("Yes"));
|
|
646
|
+
this.ctx.ui.requestRender();
|
|
647
|
+
},
|
|
648
|
+
() => {
|
|
649
|
+
done();
|
|
650
|
+
resolve(undefined);
|
|
651
|
+
this.ctx.ui.requestRender();
|
|
652
|
+
},
|
|
653
|
+
{ maxVisible: 2, helpText: "up/down navigate enter select esc keep current scope" },
|
|
654
|
+
);
|
|
655
|
+
return { component: selector, focus: selector };
|
|
656
|
+
});
|
|
657
|
+
return promise;
|
|
658
|
+
}
|
|
659
|
+
|
|
637
660
|
async #showVllmLoginModelSelector(choices: readonly LoginModelChoice[]): Promise<LoginModelChoice | null> {
|
|
638
661
|
const { promise, resolve } = Promise.withResolvers<LoginModelChoice | null>();
|
|
639
662
|
this.showSelector(done => {
|
|
@@ -1136,6 +1159,7 @@ export class SelectorController {
|
|
|
1136
1159
|
const modelsPath = path.join(getAgentDir(), "models.yml");
|
|
1137
1160
|
const configPath = path.join(path.dirname(modelsPath), "config.yml");
|
|
1138
1161
|
let defaults = readLiteLLMConfig(modelsPath);
|
|
1162
|
+
let restrictPicker: boolean | undefined;
|
|
1139
1163
|
|
|
1140
1164
|
try {
|
|
1141
1165
|
const flowResult = await runLiteLLMLoginFlow({
|
|
@@ -1202,13 +1226,18 @@ export class SelectorController {
|
|
|
1202
1226
|
}
|
|
1203
1227
|
return probe;
|
|
1204
1228
|
},
|
|
1205
|
-
selectModel: choices =>
|
|
1229
|
+
selectModel: async choices => {
|
|
1230
|
+
const choice = await this.#showLiteLLMLoginModelSelector(choices);
|
|
1231
|
+
if (choice) restrictPicker = await this.#showLiteLLMPickerScopeSelector();
|
|
1232
|
+
return choice;
|
|
1233
|
+
},
|
|
1206
1234
|
commit: input =>
|
|
1207
1235
|
commitLiteLLMLogin({
|
|
1208
1236
|
...input,
|
|
1209
1237
|
modelsPath,
|
|
1210
1238
|
configPath,
|
|
1211
1239
|
session: this.ctx.session,
|
|
1240
|
+
restrictPicker,
|
|
1212
1241
|
}),
|
|
1213
1242
|
recover: request => this.#showLoginRecovery(request),
|
|
1214
1243
|
});
|
|
@@ -1707,12 +1736,14 @@ export class SelectorController {
|
|
|
1707
1736
|
this.ctx.ui.requestRender();
|
|
1708
1737
|
},
|
|
1709
1738
|
{
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1739
|
+
getAccessState: provider => this.ctx.session.modelRegistry.getProviderAccessState?.(provider),
|
|
1740
|
+
validateAccess: async selectedProviderId => {
|
|
1741
|
+
await this.ctx.session.modelRegistry.refreshProvider(selectedProviderId, "online");
|
|
1742
|
+
return this.ctx.session.modelRegistry.getProviderAccessState?.(selectedProviderId);
|
|
1743
|
+
},
|
|
1744
|
+
isExcluded: provider => {
|
|
1745
|
+
const allowlist = this.ctx.settings?.get?.("modelProviderAllowlist") ?? [];
|
|
1746
|
+
return allowlist.length > 0 && !allowlist.includes(provider);
|
|
1716
1747
|
},
|
|
1717
1748
|
requestRender: () => {
|
|
1718
1749
|
this.ctx.ui.requestRender();
|