@f5-sales-demo/xcsh 21.21.2 → 21.21.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@f5-sales-demo/xcsh",
4
- "version": "21.21.2",
4
+ "version": "21.21.3",
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.21.2",
66
- "@f5-sales-demo/pi-ai": "21.21.2",
67
- "@f5-sales-demo/pi-natives": "21.21.2",
68
- "@f5-sales-demo/pi-resource-management": "21.21.2",
69
- "@f5-sales-demo/pi-tui": "21.21.2",
70
- "@f5-sales-demo/pi-utils": "21.21.2",
71
- "@f5-sales-demo/xcsh-stats": "21.21.2",
65
+ "@f5-sales-demo/pi-agent-core": "21.21.3",
66
+ "@f5-sales-demo/pi-ai": "21.21.3",
67
+ "@f5-sales-demo/pi-natives": "21.21.3",
68
+ "@f5-sales-demo/pi-resource-management": "21.21.3",
69
+ "@f5-sales-demo/pi-tui": "21.21.3",
70
+ "@f5-sales-demo/pi-utils": "21.21.3",
71
+ "@f5-sales-demo/xcsh-stats": "21.21.3",
72
72
  "@mozilla/readability": "^0.6",
73
73
  "@sinclair/typebox": "^0.34",
74
74
  "@xterm/headless": "^6.0",
@@ -445,6 +445,7 @@ export interface ProviderDiscoveryState {
445
445
  optional: boolean;
446
446
  stale: boolean;
447
447
  fetchedAt?: number;
448
+ checkedAt?: number;
448
449
  models: string[];
449
450
  error?: string;
450
451
  }
@@ -466,11 +467,12 @@ export type ProviderAccessStatus =
466
467
 
467
468
  export interface ProviderAccessState {
468
469
  provider: string;
470
+ configured: boolean;
469
471
  credentialSource?: ProviderCredentialSource;
470
472
  status: ProviderAccessStatus;
471
473
  catalogFreshness: "none" | "fresh" | "stale";
472
474
  failureReason?: string;
473
- verifiedAt?: number;
475
+ lastCheckedAt?: number;
474
476
  selectable: boolean;
475
477
  }
476
478
 
@@ -496,6 +498,20 @@ function isProviderAuthenticationFailure(reason: string | undefined): boolean {
496
498
  );
497
499
  }
498
500
 
501
+ /** Locally detectable credential failures that do not make a network-connectivity claim. */
502
+ export function getProviderLocalCredentialFailure(
503
+ provider: string,
504
+ environment: Record<string, string | undefined> = $env,
505
+ now: () => number = Date.now,
506
+ ): string | undefined {
507
+ if (provider !== "amazon-bedrock") return undefined;
508
+ const rawExpiration = environment.AWS_CREDENTIAL_EXPIRATION ?? environment.AWS_SESSION_EXPIRATION;
509
+ if (!rawExpiration) return undefined;
510
+ const expiration = Date.parse(rawExpiration);
511
+ if (!Number.isFinite(expiration) || expiration > now()) return undefined;
512
+ return `AWS credentials expired at ${new Date(expiration).toISOString()}`;
513
+ }
514
+
499
515
  export interface CanonicalModelQueryOptions {
500
516
  availableOnly?: boolean;
501
517
  candidates?: readonly Model<Api>[];
@@ -974,6 +990,7 @@ export class ModelRegistry {
974
990
  optional: previous?.optional ?? false,
975
991
  stale: previous?.stale ?? true,
976
992
  fetchedAt: previous?.fetchedAt,
993
+ checkedAt: previous?.checkedAt,
977
994
  models: previous?.models ?? [],
978
995
  });
979
996
  for (const selector of this.#suppressedSelectors.keys()) {
@@ -1394,6 +1411,7 @@ export class ModelRegistry {
1394
1411
  providerConfig: DiscoveryProviderConfig,
1395
1412
  strategy: ModelRefreshStrategy,
1396
1413
  ): Promise<Model<Api>[]> {
1414
+ const previous = this.#providerDiscoveryStates.get(providerConfig.provider);
1397
1415
  const cached = readModelCache<Api>(providerConfig.provider, 24 * 60 * 60 * 1000, Date.now, this.#cacheDbPath);
1398
1416
  const requiresAuth = !this.#keylessProviders.has(providerConfig.provider);
1399
1417
  if (requiresAuth) {
@@ -1405,6 +1423,7 @@ export class ModelRegistry {
1405
1423
  optional: providerConfig.optional ?? false,
1406
1424
  stale: cached !== null,
1407
1425
  fetchedAt: cached?.updatedAt,
1426
+ checkedAt: Date.now(),
1408
1427
  models: cached?.models.map(model => model.id) ?? [],
1409
1428
  });
1410
1429
  this.#lastDiscoveryWarnings.delete(providerConfig.provider);
@@ -1450,6 +1469,7 @@ export class ModelRegistry {
1450
1469
  optional: providerConfig.optional ?? false,
1451
1470
  stale: result.stale || status === "cached",
1452
1471
  fetchedAt: discoveryError || strategy === "offline" ? cached?.updatedAt : Date.now(),
1472
+ checkedAt: strategy === "offline" ? previous?.checkedAt : Date.now(),
1453
1473
  models: result.models.map(model => model.id),
1454
1474
  error: discoveryError,
1455
1475
  });
@@ -1600,6 +1620,7 @@ export class ModelRegistry {
1600
1620
  optional: false,
1601
1621
  stale: true,
1602
1622
  fetchedAt: previous?.fetchedAt,
1623
+ checkedAt: Date.now(),
1603
1624
  models: previous?.models ?? [],
1604
1625
  error: error instanceof Error ? error.message : String(error),
1605
1626
  });
@@ -1628,6 +1649,7 @@ export class ModelRegistry {
1628
1649
  optional: false,
1629
1650
  stale: true,
1630
1651
  fetchedAt: previous?.fetchedAt,
1652
+ checkedAt: Date.now(),
1631
1653
  models: previous?.models ?? [],
1632
1654
  });
1633
1655
  }
@@ -1645,6 +1667,7 @@ export class ModelRegistry {
1645
1667
  optional: false,
1646
1668
  stale: true,
1647
1669
  fetchedAt: previous?.fetchedAt,
1670
+ checkedAt: Date.now(),
1648
1671
  models: previous?.models ?? [],
1649
1672
  });
1650
1673
  }
@@ -1685,12 +1708,20 @@ export class ModelRegistry {
1685
1708
  const models = result.models.map(model =>
1686
1709
  model.provider === options.providerId ? model : { ...model, provider: options.providerId },
1687
1710
  );
1711
+ const status: ProviderDiscoveryStatus = discoveryError
1712
+ ? isProviderAuthenticationFailure(discoveryError)
1713
+ ? "unauthenticated"
1714
+ : "cached"
1715
+ : result.stale
1716
+ ? "cached"
1717
+ : "ok";
1688
1718
  this.#providerDiscoveryStates.set(options.providerId, {
1689
1719
  provider: options.providerId,
1690
- status: result.stale ? "cached" : "ok",
1720
+ status,
1691
1721
  optional: false,
1692
- stale: result.stale,
1693
- fetchedAt: result.stale ? previous?.fetchedAt : Date.now(),
1722
+ stale: result.stale || status !== "ok",
1723
+ fetchedAt: discoveryError || result.stale ? previous?.fetchedAt : Date.now(),
1724
+ checkedAt: strategy === "offline" ? previous?.checkedAt : Date.now(),
1694
1725
  error: discoveryError,
1695
1726
  models: models.map(model => model.id),
1696
1727
  });
@@ -1711,6 +1742,7 @@ export class ModelRegistry {
1711
1742
  optional: false,
1712
1743
  stale: true,
1713
1744
  fetchedAt: retained?.fetchedAt,
1745
+ checkedAt: Date.now(),
1714
1746
  models: retained?.models ?? [],
1715
1747
  error: failureReason,
1716
1748
  });
@@ -2283,7 +2315,8 @@ export class ModelRegistry {
2283
2315
  ...this.#configuredProviderIds,
2284
2316
  ...this.#discoverableProviders
2285
2317
  .filter(
2286
- provider => !provider.optional || this.#models.some(model => model.provider === provider.provider),
2318
+ provider =>
2319
+ !provider.optional || this.#providerDiscoveryStates.get(provider.provider)?.status === "ok",
2287
2320
  )
2288
2321
  .map(provider => provider.provider),
2289
2322
  ...this.#models.filter(model => this.authStorage.hasAuth(model.provider)).map(model => model.provider),
@@ -2309,12 +2342,25 @@ export class ModelRegistry {
2309
2342
  .map(([groupProvider]) => this.#providerDiscoveryStates.get(groupProvider))
2310
2343
  .find(Boolean)
2311
2344
  : undefined);
2312
- const credentialSource: ProviderCredentialSource | undefined = this.#keylessProviders.has(provider)
2313
- ? "keyless"
2314
- : (this.authStorage.getCredentialSource(provider) ?? this.#lastCredentialSources.get(provider));
2345
+ const explicitConfiguration = this.#configuredProviderIds.has(provider);
2346
+ const detected = discovery?.status === "ok";
2347
+ const observedCredentialSource =
2348
+ this.authStorage.getCredentialSource(provider) ?? this.#lastCredentialSources.get(provider);
2349
+ const configured =
2350
+ explicitConfiguration || (observedCredentialSource !== undefined && observedCredentialSource !== "keyless");
2351
+ const optionalImplicitProvider = discovery?.optional === true && !explicitConfiguration;
2352
+ const credentialSource: ProviderCredentialSource | undefined =
2353
+ this.#keylessProviders.has(provider) && (explicitConfiguration || detected)
2354
+ ? "keyless"
2355
+ : observedCredentialSource === "keyless"
2356
+ ? undefined
2357
+ : observedCredentialSource;
2315
2358
  const catalogFreshness = discovery?.stale ? "stale" : discovery?.status === "ok" ? "fresh" : "none";
2359
+ const localCredentialFailure = getProviderLocalCredentialFailure(provider);
2316
2360
  let status: ProviderAccessStatus;
2317
- if (!credentialSource) status = "unconfigured";
2361
+ if (localCredentialFailure) status = "reauth-required";
2362
+ else if (optionalImplicitProvider && !configured && !detected) status = "unconfigured";
2363
+ else if (!credentialSource && !detected) status = "unconfigured";
2318
2364
  else if (discovery?.status === "checking") status = "checking";
2319
2365
  else if (discovery?.status === "unauthenticated") status = "reauth-required";
2320
2366
  else if (discovery?.status === "unavailable" || discovery?.status === "cached") status = "unreachable";
@@ -2322,11 +2368,12 @@ export class ModelRegistry {
2322
2368
  else status = "configured-unverified";
2323
2369
  return {
2324
2370
  provider,
2371
+ configured,
2325
2372
  credentialSource,
2326
2373
  status,
2327
2374
  catalogFreshness,
2328
- failureReason: sanitizeProviderFailure(discovery?.error),
2329
- verifiedAt: discovery?.status === "ok" ? discovery.fetchedAt : undefined,
2375
+ failureReason: localCredentialFailure ?? sanitizeProviderFailure(discovery?.error),
2376
+ lastCheckedAt: localCredentialFailure ? Date.now() : discovery?.checkedAt,
2330
2377
  selectable: (status === "connected" || status === "configured-unverified") && !discovery?.stale,
2331
2378
  };
2332
2379
  }
@@ -168,7 +168,9 @@ export type CanonicalModelRegistry = Partial<
168
168
  Pick<ModelRegistry, "resolveCanonicalModel" | "getCanonicalVariants" | "getCanonicalId">
169
169
  >;
170
170
  export type ModelLookupRegistry = Pick<ModelRegistry, "getAvailable"> & Partial<CanonicalModelRegistry>;
171
- type CliModelRegistry = Pick<ModelRegistry, "getAll"> & Partial<CanonicalModelRegistry>;
171
+ type CliModelRegistry = Pick<ModelRegistry, "getAll"> &
172
+ Partial<Pick<ModelRegistry, "getAvailable" | "getProviderAccessState">> &
173
+ Partial<CanonicalModelRegistry>;
172
174
  type InitialModelRegistry = Pick<ModelRegistry, "getAvailable" | "find">;
173
175
  type RestorableModelRegistry = Pick<ModelRegistry, "getAvailable" | "find" | "getApiKey">;
174
176
 
@@ -898,6 +900,13 @@ export interface ResolveCliModelResult {
898
900
  thinkingLevel?: ThinkingLevel;
899
901
  warning: string | undefined;
900
902
  error: string | undefined;
903
+ /** Unknown bare selectors may resolve after extensions register models. */
904
+ deferToExtensions?: boolean;
905
+ }
906
+
907
+ function formatAmbiguousCliModel(pattern: string, models: readonly Model<Api>[]): string {
908
+ const choices = [...new Set(models.map(formatModelString))].sort();
909
+ return `Model "${pattern}" is ambiguous. Use a qualified selector: ${choices.join(", ")}.`;
901
910
  }
902
911
 
903
912
  /**
@@ -915,8 +924,11 @@ export function resolveCliModel(options: {
915
924
  return { model: undefined, selector: undefined, warning: undefined, error: undefined };
916
925
  }
917
926
 
918
- const availableModels = modelRegistry.getAll();
919
- if (availableModels.length === 0) {
927
+ const allModels = modelRegistry.getAll();
928
+ const availableModels = (modelRegistry.getAvailable?.() ?? allModels).filter(
929
+ model => modelRegistry.getProviderAccessState?.(model.provider).selectable !== false,
930
+ );
931
+ if (allModels.length === 0) {
920
932
  return {
921
933
  model: undefined,
922
934
  selector: undefined,
@@ -926,7 +938,7 @@ export function resolveCliModel(options: {
926
938
  }
927
939
 
928
940
  const providerMap = new Map<string, string>();
929
- for (const model of availableModels) {
941
+ for (const model of allModels) {
930
942
  providerMap.set(model.provider.toLowerCase(), model.provider);
931
943
  }
932
944
 
@@ -943,6 +955,80 @@ export function resolveCliModel(options: {
943
955
  const trimmedModel = cliModel.trim();
944
956
  if (!provider) {
945
957
  const lower = trimmedModel.toLowerCase();
958
+ const lastColonIndex = trimmedModel.lastIndexOf(":");
959
+ const thinkingSuffix =
960
+ lastColonIndex === -1 ? undefined : parseThinkingLevel(trimmedModel.slice(lastColonIndex + 1));
961
+ const barePattern = thinkingSuffix ? trimmedModel.slice(0, lastColonIndex) : trimmedModel;
962
+ if (!barePattern.includes("/")) {
963
+ const exactUsable = availableModels.filter(model => model.id.toLowerCase() === barePattern.toLowerCase());
964
+ const canonicalUsable =
965
+ modelRegistry
966
+ .getCanonicalVariants?.(barePattern, { availableOnly: true, candidates: availableModels })
967
+ .map(variant => variant.model) ?? [];
968
+ const usableMatches = [
969
+ ...new Map([...exactUsable, ...canonicalUsable].map(model => [formatModelString(model), model])).values(),
970
+ ];
971
+ if (usableMatches.length > 1) {
972
+ return {
973
+ model: undefined,
974
+ selector: undefined,
975
+ thinkingLevel: thinkingSuffix,
976
+ warning: undefined,
977
+ error: formatAmbiguousCliModel(barePattern, usableMatches),
978
+ };
979
+ }
980
+ if (usableMatches.length === 1) {
981
+ return {
982
+ model: usableMatches[0],
983
+ selector: formatModelString(usableMatches[0]),
984
+ thinkingLevel: thinkingSuffix,
985
+ warning: undefined,
986
+ error: undefined,
987
+ };
988
+ }
989
+ const knownMatches = allModels.filter(model => model.id.toLowerCase() === barePattern.toLowerCase());
990
+ if (knownMatches.length > 0) {
991
+ return {
992
+ model: undefined,
993
+ selector: undefined,
994
+ thinkingLevel: thinkingSuffix,
995
+ warning: undefined,
996
+ error: `Model "${barePattern}" is unavailable. Configure or sign in to one of: ${[
997
+ ...new Set(knownMatches.map(formatModelString)),
998
+ ]
999
+ .sort()
1000
+ .join(", ")}.`,
1001
+ };
1002
+ }
1003
+
1004
+ const usableProviders = [...new Set(availableModels.map(model => model.provider))];
1005
+ const fuzzyUsable = usableProviders.flatMap(providerId => {
1006
+ const providerModels = availableModels.filter(model => model.provider === providerId);
1007
+ const match = parseModelPattern(barePattern, providerModels, preferences, {
1008
+ allowInvalidThinkingSelectorFallback: false,
1009
+ modelRegistry,
1010
+ }).model;
1011
+ return match ? [match] : [];
1012
+ });
1013
+ if (fuzzyUsable.length > 1) {
1014
+ return {
1015
+ model: undefined,
1016
+ selector: undefined,
1017
+ thinkingLevel: thinkingSuffix,
1018
+ warning: undefined,
1019
+ error: formatAmbiguousCliModel(barePattern, fuzzyUsable),
1020
+ };
1021
+ }
1022
+ if (fuzzyUsable.length === 1) {
1023
+ return {
1024
+ model: fuzzyUsable[0],
1025
+ selector: formatModelString(fuzzyUsable[0]),
1026
+ thinkingLevel: thinkingSuffix,
1027
+ warning: undefined,
1028
+ error: undefined,
1029
+ };
1030
+ }
1031
+ }
946
1032
  // When input has provider/id format (e.g. "zai/glm-5"), prefer decomposed
947
1033
  // provider+id match over flat id match. Without this, a model with id
948
1034
  // "zai/glm-5" on provider "vercel-ai-gateway" wins over provider "zai"
@@ -955,7 +1041,10 @@ export function resolveCliModel(options: {
955
1041
  exact = resolveProviderModelReference(prefix, suffix, availableModels);
956
1042
  }
957
1043
  if (!exact && !trimmedModel.includes(":")) {
958
- const canonicalMatch = modelRegistry.resolveCanonicalModel?.(trimmedModel, { availableOnly: false });
1044
+ const canonicalMatch = modelRegistry.resolveCanonicalModel?.(trimmedModel, {
1045
+ availableOnly: true,
1046
+ candidates: availableModels,
1047
+ });
959
1048
  if (canonicalMatch) {
960
1049
  return {
961
1050
  model: canonicalMatch,
@@ -1022,12 +1111,23 @@ export function resolveCliModel(options: {
1022
1111
 
1023
1112
  if (!model) {
1024
1113
  const display = provider ? `${provider}/${pattern}` : cliModel;
1114
+ const knownProviderModel = provider
1115
+ ? parseModelPattern(
1116
+ pattern,
1117
+ allModels.filter(model => model.provider === provider),
1118
+ preferences,
1119
+ { allowInvalidThinkingSelectorFallback: false, modelRegistry },
1120
+ ).model
1121
+ : undefined;
1025
1122
  return {
1026
1123
  model: undefined,
1027
1124
  selector: undefined,
1028
1125
  thinkingLevel: undefined,
1029
1126
  warning,
1030
- error: `Model "${display}" not found. Use --list-models to see available models.`,
1127
+ error: knownProviderModel
1128
+ ? `Model "${display}" is unavailable. Configure or sign in to provider "${provider}".`
1129
+ : `Model "${display}" not found. Use --list-models to see available models.`,
1130
+ deferToExtensions: !provider && !display.includes("/"),
1031
1131
  };
1032
1132
  }
1033
1133
 
@@ -17,17 +17,17 @@ export interface BuildInfo {
17
17
  }
18
18
 
19
19
  export const BUILD_INFO: BuildInfo = {
20
- "version": "21.21.2",
21
- "commit": "543254c7b2d3468a5af620a1905064da069837eb",
22
- "shortCommit": "543254c",
20
+ "version": "21.21.3",
21
+ "commit": "7e54131642306d980389560cbdf1a0edb9fc9493",
22
+ "shortCommit": "7e54131",
23
23
  "branch": "main",
24
- "tag": "v21.21.2",
25
- "commitDate": "2026-09-09T14:40:15+00:00",
26
- "buildDate": "2026-09-09T15:51:38.046Z",
24
+ "tag": "v21.21.3",
25
+ "commitDate": "2026-09-09T15:46:05+00:00",
26
+ "buildDate": "2026-09-09T16:41:57.008Z",
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/543254c7b2d3468a5af620a1905064da069837eb",
32
- "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.21.2"
31
+ "commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/7e54131642306d980389560cbdf1a0edb9fc9493",
32
+ "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.21.3"
33
33
  };
@@ -28,7 +28,7 @@ export const EMBEDDED_DOCS: Readonly<Record<string, string>> = {
28
28
  "en/automate-extend/skills.mdx": "---\ntitle: \"Create and load skills\"\ndescription: \"Package task-specific instructions in `SKILL.md` files at user or project scope.\"\nsidebar:\n order: 5\n label: \"Create and load skills\"\n---\n\nA skill is a directory centered on `SKILL.md`. It tells an agent when and how to perform a bounded kind of work; it is not executable proof by itself.\n\n## Where do skills live?\n\nUse project scope under `.xcsh/skills/` for repository-specific instructions and user scope under the xcsh data directory for personal skills. Project instructions should be reviewable with the repository.\n\n## How do I test one?\n\nStart xcsh with `--skills <GLOB>` to narrow discovery, invoke a prompt that matches the trigger, and inspect the tools and output. Use `--no-skills` to confirm behavior without it.\n",
29
29
  "en/configure-secure/environment-reference.mdx": "---\ntitle: \"Environment variable reference\"\ndescription: \"Look up the environment variables that select models, credentials, tenants, execution behavior, storage roots, and diagnostics.\"\nsidebar:\n order: 2\n label: \"Environment variables\"\n---\n\nEnvironment variables carry credentials and process-scoped overrides. Settings files and command flags keep their documented precedence; a similarly named variable is not automatically supported. Provider adapters read their own vendor key names, which the adapter defines rather than this list.\n\n## Which variables configure models, providers, and search?\n\n| Variable | Controls |\n| --- | --- |\n| `PI_SMOL_MODEL` | Default model for the lightweight role, equivalent to `--smol` |\n| `PI_SLOW_MODEL` | Default model for the reasoning role, equivalent to `--slow` |\n| `PI_PLAN_MODEL` | Default model for the planning role, equivalent to `--plan` |\n| `XCSH_LOCALE` | Interface locale, ahead of `PI_LOCALE` and `LANG` |\n\nA flag beats the variable: `--smol` overrides `PI_SMOL_MODEL` for that invocation. Model selection stays a model-registry decision, so a name these variables set must still resolve through `xcsh --list-models <PROVIDER>`.\n\n## Which variables address an F5 Distributed Cloud tenant?\n\n| Variable | Controls |\n| --- | --- |\n| `XCSH_API_URL` | Tenant application programming interface (API) endpoint when no named context is active |\n| `XCSH_API_TOKEN` | Tenant API credential for that endpoint |\n| `XCSH_TENANT` | Tenant identifier reported in context status |\n| `XCSH_CONTEXT_NAME` | Name of the context the session binds to |\n| `XCSH_NAMESPACE` | Namespace applied when a command does not pass `-n` |\n| `F5XC_NAMESPACE` | Namespace source recorded in resource operation records |\n\nTreat every value in this group as a secret. Supply them through the runtime environment or a named context, never through a committed file or a command argument that reaches shell history.\n\n## Which variables configure Python, shell, and tool execution?\n\n| Variable | Controls |\n| --- | --- |\n| `PI_PYTHON_GATEWAY_URL` | Endpoint the Python tool sends code to |\n| `PI_PYTHON_GATEWAY_TOKEN` | Credential for that gateway |\n| `PI_PYTHON_SKIP_CHECK` | Skips the gateway warm-up probe |\n| `PI_SHELL_PREFIX` | Command prefix wrapped around shell tool invocations |\n| `PI_BASH_NO_LOGIN` | Runs the shell without `-l` |\n| `PI_NO_PTY` | Disables pseudo-terminal (PTY) execution, equivalent to `--no-pty` |\n| `PI_EDIT_VARIANT` | Selects the edit tool implementation and rejects an unknown value |\n\nShell execution inherits the launched process environment, subject to the sandbox and command policy. Restrict dependencies, working directory, and credentials at the process boundary rather than in the prompt.\n\n## Which variables configure storage, runtime, and diagnostics?\n\n| Variable | Controls |\n| --- | --- |\n| `PI_CODING_AGENT_DIR` | Primary agent data root, including session storage |\n| `PI_CONFIG_DIR` | Configuration root directory name, `.xcsh` by default |\n| `PI_PACKAGE_DIR` | Packaged asset directory the runtime resolves against |\n| `PI_SESSION_FILE` | Session file a child process attaches to |\n| `PI_NATIVE_VARIANT` | Hardware variant the native addon loader prefers |\n| `PI_CACHE_RETENTION` | Cache retention policy, `short` by default |\n| `PI_NO_TITLE` | Disables title auto-generation, equivalent to `--no-title` |\n| `PI_NOTIFICATIONS` | Desktop notification behavior |\n| `PI_DEBUG_STARTUP` | Startup phase diagnostics |\n| `PI_TIMING` | Phase timing output |\n| `PI_TUI_DEBUG` | Terminal user interface (TUI) rendering diagnostics |\n\nProject configuration stays under `.xcsh/` even when `PI_CODING_AGENT_DIR` moves the user root. Never print a credential-bearing variable into a diagnostic receipt; name the variable and state whether it was set.\n",
30
30
  "en/configure-secure/index.mdx": "---\ntitle: \"Configure and secure\"\ndescription: \"Control settings, providers, credentials, networking, secrets, sandboxing, and runtime boundaries.\"\nsidebar:\n order: 0\n label: \"Overview\"\n---\n\nConfiguration controls provider routing, settings precedence, filesystem access, and credential handling.\n\n## What should I configure first?\n\n1. Inspect [settings precedence and file locations](./settings-files/).\n2. Look up any [environment variable](./environment-reference/) the deployment sets.\n3. Choose a [provider and model route](./providers-routing/).\n4. Apply [secret handling and the filesystem boundary](./secrets-obfuscation/).\n5. Set the [sandbox boundaries](./sandbox-boundaries/) that enforce those decisions.\n\nStart with defaults; add project configuration only when collaborators need the same behavior.\n",
31
- "en/configure-secure/providers-routing.mdx": "---\ntitle: \"Configure providers and model routing\"\ndescription: \"Select models directly or map default, smol, slow, and plan roles.\"\nsidebar:\n order: 3\n label: \"Configure providers and model routing\"\n---\n\nxcsh resolves a requested model against available providers and credentials. A provider-qualified model name is the most explicit route.\n\n## How do I confirm a route?\n\nRun `xcsh --list-models <PROVIDER>`, then pass one returned name to `--model`. Environment keys and supported subscription sessions authenticate providers; never store tokens in committed settings.\n\n## How do I select a model in a conversation?\n\nOpen `/model`. Tab and Shift+Tab browse providers; typing searches across them. The active conversation model and saved role badges are shown separately. Configured providers remain visible when discovery is empty, unavailable, or requires authentication. Use Ctrl+R to refresh the current provider or Ctrl+L to open login.\n\nChoose a model with Enter, then choose its scope:\n\n- **Use in this conversation** is preselected. It changes this session, including resume, without changing saved role assignments.\n- **Save as default** changes the current conversation and the default for future sessions.\n- **Assign to role** saves Default, Fast/SMOL, Thorough/SLOW, Plan, or another existing role. Roles other than Default leave the current conversation unchanged.\n\nChoose a reasoning level supported by that exact model and press Enter to confirm. Inherit displays the provider default; an existing supported reasoning selection is preselected. Escape backs out without applying an unfinished choice. Failed writes are reported before badges show success.\n\nA manual conversation choice remains in effect under automatic routing. Entering planning mode uses the Plan assignment; exiting restores the prior conversation model and reasoning. Explicit `--models` scopes still limit the picker.\n\n## Where does LiteLLM fit?\n\nLiteLLM is an optional provider proxy installed or checked with `xcsh setup litellm`. Its base uniform resource locator (URL) and credential belong in the runtime environment. Successful text Responses support does not imply Realtime or audio support; test the exact endpoint your workflow uses.\n\n## How do I test licensed Vertex locally?\n\n`bun run dev` and local coding-agent binary builds load the licensed Vertex OAuth client pair automatically. Explicit `XCSH_VERTEX_OAUTH_CLIENT_ID` and `XCSH_VERTEX_OAUTH_CLIENT_SECRET` build inputs take precedence; supply both together.\n\nFor local UAT, the first launch can recover the embedded client pair from an installed official xcsh binary\nand retain it in `$XDG_CONFIG_HOME/xcsh/vertex-build.json` (default `~/.config/xcsh/vertex-build.json`). The\nfile is outside the checkout, shared by local sessions and worktrees for the same operating-system user, and\ncreated with owner-only permissions. Each worktree needs this development/build launcher to load it\nautomatically. Later launches reuse it even if the installed binary changes.\n`XCSH_VERTEX_OAUTH_CREDENTIALS_FILE` selects another private local file containing `clientId` and\n`clientSecret` fields.\n\nThe source-runtime preload keeps the pair in process memory; local compiled candidates embed it. Do not copy\nthis file or its values into source control, logs, or UAT reports. CI does not read or recover workstation\ncredentials: official release builds continue to receive the pair through GitHub secrets. Unit tests use\nfixture credentials; the live provider smoke script uses the same local preload as development UAT.\n",
31
+ "en/configure-secure/providers-routing.mdx": "---\ntitle: \"Configure providers and model routing\"\ndescription: \"Select models directly or map default, smol, slow, and plan roles.\"\nsidebar:\n order: 3\n label: \"Configure providers and model routing\"\n---\n\nxcsh resolves a requested model against available providers and credentials. A provider-qualified model name is the most explicit route.\n\n## How do I confirm a route?\n\nRun `xcsh --list-models <PROVIDER>`, then pass one returned name to `--model`. Environment keys and supported subscription sessions authenticate providers; never store tokens in committed settings.\n\n## How do I select a model in a conversation?\n\nOpen `/model`. Tab and Shift+Tab browse providers; typing searches across them. The active conversation model and saved role badges are shown separately. Configured providers remain visible when discovery is empty, unavailable, or requires authentication. Use Ctrl+R to refresh the current provider or Ctrl+L to open login.\n\nChoose a model with Enter, then choose its scope:\n\n- **Use in this conversation** is preselected. It changes this session, including resume, without changing saved role assignments.\n- **Save as default** changes the current conversation and the default for future sessions.\n- **Assign to role** saves Default, Fast/SMOL, Thorough/SLOW, Plan, or another existing role. Roles other than Default leave the current conversation unchanged.\n\nChoose a reasoning level supported by that exact model and press Enter to confirm. Inherit displays the provider default; an existing supported reasoning selection is preselected. Escape backs out without applying an unfinished choice. Failed writes are reported before badges show success.\n\nA manual conversation choice remains in effect under automatic routing. Entering planning mode uses the Plan assignment; exiting restores the prior conversation model and reasoning. Explicit `--models` scopes still limit the picker.\n\nOpen `/login` to see providers that are configured, credential-backed, allowlisted, active, or freshly detected. Optional local runtimes do not appear merely because xcsh attempted an automatic probe. Choose `Add provider…` to search the complete built-in catalog.\n\nProvider rows use human status labels. Press Right on a row to inspect its credential source, last verification, sanitized failure reason, model visibility, and any grouped routes. `/logout` lists only providers with stored credentials that xcsh can remove; environment and configuration credentials are not presented as removable.\n\nProvider grouping in `models.yml` is also used by the management view:\n\n```yaml\nproviders:\n litellm:\n picker:\n groupId: litellm\n groupLabel: LiteLLM\n sectionLabel: OpenAI\n modelAllowlist:\n - gpt-5.6-sol\n - gpt-5.6-terra\n - gpt-5.6-luna\n anthropic:\n picker:\n groupId: litellm\n groupLabel: LiteLLM\n sectionLabel: Anthropic\n modelAllowlist:\n - claude-opus-5\n - claude-sonnet-5\n - claude-haiku-4-5\n```\n\n`modelProviderAllowlist` is a settings key that limits normal `/model` visibility. An empty list means no picker restriction; it does not make every built-in provider relevant in `/login`. Explicit provider-qualified command-line selection and direct `/login <provider>` remain available.\n\n```bash\nxcsh config set modelProviderAllowlist '[\"litellm\", \"anthropic\"]'\nxcsh config set modelProviderOrder '[\"litellm\", \"anthropic\", \"google-vertex\"]'\n```\n\nFor command-line selection, qualify the provider whenever several usable providers expose the same model ID. A bare `--model` value succeeds only when one usable provider matches; otherwise xcsh prints the qualified choices and exits nonzero in noninteractive mode.\n\n## Where does LiteLLM fit?\n\nLiteLLM is an optional provider proxy installed or checked with `xcsh setup litellm`. Its base uniform resource locator (URL) and credential belong in the runtime environment. Successful text Responses support does not imply Realtime or audio support; test the exact endpoint your workflow uses.\n\n## How do I test licensed Vertex locally?\n\n`bun run dev` and local coding-agent binary builds load the licensed Vertex OAuth client pair automatically. Explicit `XCSH_VERTEX_OAUTH_CLIENT_ID` and `XCSH_VERTEX_OAUTH_CLIENT_SECRET` build inputs take precedence; supply both together.\n\nFor local UAT, the first launch can recover the embedded client pair from an installed official xcsh binary\nand retain it in `$XDG_CONFIG_HOME/xcsh/vertex-build.json` (default `~/.config/xcsh/vertex-build.json`). The\nfile is outside the checkout, shared by local sessions and worktrees for the same operating-system user, and\ncreated with owner-only permissions. Each worktree needs this development/build launcher to load it\nautomatically. Later launches reuse it even if the installed binary changes.\n`XCSH_VERTEX_OAUTH_CREDENTIALS_FILE` selects another private local file containing `clientId` and\n`clientSecret` fields.\n\nThe source-runtime preload keeps the pair in process memory; local compiled candidates embed it. Do not copy\nthis file or its values into source control, logs, or UAT reports. CI does not read or recover workstation\ncredentials: official release builds continue to receive the pair through GitHub secrets. Unit tests use\nfixture credentials; the live provider smoke script uses the same local preload as development UAT.\n",
32
32
  "en/configure-secure/sandbox-boundaries.mdx": "---\ntitle: \"Set sandbox boundaries\"\ndescription: \"Constrain filesystem, shell, native, browser, and extension effects at the layer that enforces them.\"\nsidebar:\n order: 5\n label: \"Sandbox boundaries\"\n---\n\nA model instruction is not a sandbox. Enforcement belongs to the tool, host process, container, operating system, or remote service that performs the action.\n\n## How do I restrict the exposed tool set?\n\nStart with `--no-tools` or an explicit `--tools` allow-list when a run needs only conversation. Disable Model Context Protocol (MCP) and extensions separately because they can register additional capabilities. Review custom tool and hook code with the same care as any locally executed module.\n\n## How do I constrain files and processes?\n\nFilesystem-aware tools resolve paths against their configured workspace boundary. The Bash runtime applies its sandbox and output limits before returning a result; large output may spill to an artifact instead of remaining inline. Containers add process and filesystem isolation, but mounted credentials and sockets still cross that boundary.\n\n## Where does remote authority differ from local authority?\n\nBrowser, editor, Office, and remote-service integrations enforce different permission models. Confirm the active host, account, context, namespace, and target immediately before a mutation. A successful read proves connectivity, not authorization for a write.\n",
33
33
  "en/configure-secure/secrets-obfuscation.mdx": "---\ntitle: \"Resolve secrets safely\"\ndescription: \"Reference sensitive values without placing plaintext credentials in prompts, manifests, logs, or commits.\"\nsidebar:\n order: 4\n label: \"Resolve secrets safely\"\n---\n\nKeep provider keys and F5 Distributed Cloud contexts outside prompts, session exports, logs, and committed files. Pass secrets through supported environment or protected runtime files.\n\n## How does obfuscation work?\n\nWhen secret obfuscation is enabled, values declared in the protected `secrets.yml` source are resolved at runtime and replaced in observable text before it is retained or rendered. Environment values take their documented precedence over file-backed values.\n\nObfuscation reduces accidental disclosure in supported paths; it is not encryption for a compromised process or an excuse to place secrets in prompts.\n\n## How does the filesystem boundary work?\n\nxcsh discovers a task root and guards access outside it. Add an explicit path with `--allow-path`; use `--allow-home` only when the home directory is intentionally the task root. `--no-sandbox` removes that guard and should be reserved for a controlled diagnostic.\n\n## How do I inspect the boundary?\n\nRun `xcsh sandbox check`, then start a read-only session with the smallest required `--allow-path` set. A sandbox boundary limits file discovery; it does not replace operating-system permissions or tool review.\n",
34
34
  "en/configure-secure/settings-files.mdx": "---\ntitle: \"Understand settings precedence\"\ndescription: \"Predict which user, project, environment, and command-line value xcsh resolves.\"\nsidebar:\n order: 1\n label: \"Understand settings precedence\"\n---\n\nProject settings apply to one repository; user settings apply across projects; command flags override both for one invocation. Use `xcsh config list --json` to inspect effective values.\n\n## How is configuration resolved?\n\nDiscovery collects fixed user, project, environment, and command-line sources, normalizes each through the schema-backed configuration wrapper, then resolves values by explicit priority. Capability-specific discovery uses the same roots but owns its own merge and deduplication rules. Native `.xcsh` providers participate through the documented provider interface, not an implicit recursive scan.\n\n## Where are settings stored?\n\nRun `xcsh config path` instead of assuming a platform path. Project data uses `.xcsh/`, including `settings.json`, `mcp.json`, contexts, skills, agents, extensions, tools, hooks, commands, and `XCSH.md`. Primary user data lives under the xcsh agent directory; `PI_CODING_AGENT_DIR` can override that location.\n\n## How do I change one value?\n\n```bash\nxcsh config get <KEY>\nxcsh config set <KEY> <VALUE>\nxcsh config reset <KEY>\n```\n\nUse environment variables for credentials and ephemeral process configuration. Do not copy an entire old settings file when only one key is needed.\n",
package/src/main.ts CHANGED
@@ -446,7 +446,7 @@ async function buildSessionOptions(
446
446
  process.stderr.write(`${chalk.yellow(`Warning: ${resolved.warning}`)}\n`);
447
447
  }
448
448
  if (resolved.error) {
449
- if (!parsed.provider && !parsed.model.includes(":")) {
449
+ if (resolved.deferToExtensions) {
450
450
  // Model not found in built-in registry — defer resolution to after extensions load
451
451
  // (extensions may register additional providers/models via registerProvider)
452
452
  options.modelPattern = parsed.model;
@@ -446,6 +446,7 @@ export class ModelSelectorComponent extends Container {
446
446
  }
447
447
  for (const [index, provider] of group.providers.entries()) {
448
448
  const state = this.#modelRegistry.getProviderDiscoveryState?.(provider);
449
+ const access = this.#modelRegistry.getProviderAccessState?.(provider);
449
450
  const label = getProviderDisplayName(provider);
450
451
  let message = "";
451
452
  let color: ThemeColor = "muted";
@@ -455,8 +456,15 @@ export class ModelSelectorComponent extends Container {
455
456
  } else if (state?.status === "unauthenticated" || group.discoveryStatus === "unauthenticated") {
456
457
  message = `${label}: authentication required · Ctrl+L: login`;
457
458
  color = "warning";
458
- } else if (!state || state.status === "idle") message = `${label}: availability unverified · Ctrl+R: refresh`;
459
- else if (state.status === "ok" && state.models.length === 0)
459
+ } else if (!state || state.status === "idle") {
460
+ if (access?.status === "connected") {
461
+ message = `${label}: ${access.credentialSource === "keyless" ? "Available" : "Connected"}`;
462
+ } else if (access?.status === "configured-unverified") {
463
+ message = `${label}: Configured`;
464
+ } else {
465
+ message = `${label}: availability unverified · Ctrl+R: refresh`;
466
+ }
467
+ } else if (state.status === "ok" && state.models.length === 0)
460
468
  message = `${label}: empty catalog · Ctrl+R: refresh`;
461
469
  rows[index + 1] = theme.fg(color, message);
462
470
  }
@@ -937,6 +945,7 @@ export class ModelSelectorComponent extends Container {
937
945
  if (--this.#pendingRefreshes === 0) this.#stopSpinner();
938
946
  if (this.#refreshingProvider === activeGroup.id) this.#refreshingProvider = undefined;
939
947
  this.#updateList();
948
+ this.#tui.requestRender();
940
949
  }
941
950
  }
942
951
 
@@ -1,10 +1,9 @@
1
- import type { OAuthProviderInfo } from "@f5-sales-demo/pi-ai";
2
1
  import { Container, Input, matchesKey, Spacer, Text, TruncatedText } from "@f5-sales-demo/pi-tui";
3
2
  import type { ProviderAccessState } from "../../config/model-registry";
4
3
  import { theme } from "../../modes/theme/theme";
5
4
  import { matchesSelectCancel } from "../../modes/utils/keybinding-matchers";
6
5
  import type { AuthStorage } from "../../session/auth-storage";
7
- import { getLoginOptions } from "../controllers/login-options";
6
+ import { getLoginOptions, type LoginOption } from "../controllers/login-options";
8
7
  import { DynamicBorder } from "./dynamic-border";
9
8
  /**
10
9
  * Component that renders an OAuth provider selector.
@@ -13,8 +12,12 @@ export class OAuthSelectorComponent extends Container {
13
12
  static readonly MAX_VISIBLE_PROVIDERS = 10;
14
13
 
15
14
  #listContainer: Container;
16
- #allProviders: OAuthProviderInfo[] = [];
17
- #filteredProviders: OAuthProviderInfo[] = [];
15
+ #allProviders: LoginOption[] = [];
16
+ #filteredProviders: LoginOption[] = [];
17
+ #managementProviders: LoginOption[] = [];
18
+ #catalogProviders: LoginOption[] = [];
19
+ #catalogMode = false;
20
+ #detailsProvider?: LoginOption;
18
21
  #searchInput: Input;
19
22
  #selectedIndex: number = 0;
20
23
  #mode: "login" | "logout";
@@ -37,6 +40,8 @@ export class OAuthSelectorComponent extends Container {
37
40
  onSelect: (providerId: string) => void,
38
41
  onCancel: () => void,
39
42
  options?: {
43
+ providers?: LoginOption[];
44
+ catalogProviders?: LoginOption[];
40
45
  validateAuth?: (providerId: string) => Promise<boolean>;
41
46
  getAccessState?: (providerId: string) => ProviderAccessState;
42
47
  validateAccess?: (providerId: string) => Promise<ProviderAccessState>;
@@ -55,7 +60,7 @@ export class OAuthSelectorComponent extends Container {
55
60
  this.#isExcluded = options?.isExcluded;
56
61
  this.#requestRenderCallback = options?.requestRender;
57
62
  // Load all OAuth providers
58
- this.#loadProviders();
63
+ this.#loadProviders(options?.providers, options?.catalogProviders);
59
64
  this.addChild(new DynamicBorder());
60
65
  this.addChild(new Spacer(1));
61
66
  // Add title
@@ -81,11 +86,14 @@ export class OAuthSelectorComponent extends Container {
81
86
  this.#validationGeneration += 1;
82
87
  this.#stopSpinner();
83
88
  }
84
- #loadProviders(): void {
85
- this.#allProviders =
89
+ #loadProviders(providers?: LoginOption[], catalogProviders?: LoginOption[]): void {
90
+ const defaultProviders =
86
91
  this.#mode === "login"
87
92
  ? getLoginOptions()
88
93
  : getLoginOptions().filter(provider => !provider.loginOnly && provider.id !== "google-vertex");
94
+ this.#managementProviders = providers ?? defaultProviders;
95
+ this.#catalogProviders = catalogProviders ?? getLoginOptions();
96
+ this.#allProviders = this.#managementProviders;
89
97
  // Keep the curated registry order stable except for explicit priorities.
90
98
  this.#allProviders = this.#allProviders
91
99
  .map((provider, index) => ({ provider, index }))
@@ -94,6 +102,10 @@ export class OAuthSelectorComponent extends Container {
94
102
  this.#filteredProviders = this.#allProviders;
95
103
  }
96
104
 
105
+ #providerIds(provider: LoginOption): string[] {
106
+ return provider.providerIds ?? [provider.id];
107
+ }
108
+
97
109
  #filterProviders(query: string): void {
98
110
  const normalizedQuery = query.trim().toLowerCase();
99
111
  this.#filteredProviders = normalizedQuery
@@ -113,14 +125,16 @@ export class OAuthSelectorComponent extends Container {
113
125
 
114
126
  let pending = 0;
115
127
  for (const provider of this.#allProviders) {
116
- const access = this.#getAccessState?.(provider.id);
117
- if (!this.#authStorage.hasAuth(provider.id) && access?.credentialSource !== "keyless") {
118
- this.#authState.delete(provider.id);
119
- continue;
128
+ for (const providerId of this.#providerIds(provider)) {
129
+ const access = this.#getAccessState?.(providerId);
130
+ if (!this.#authStorage.hasAuth(providerId) && access?.credentialSource !== "keyless") {
131
+ this.#authState.delete(providerId);
132
+ continue;
133
+ }
134
+ this.#authState.set(providerId, "checking");
135
+ pending += 1;
136
+ void this.#validateProvider(providerId, generation);
120
137
  }
121
- this.#authState.set(provider.id, "checking");
122
- pending += 1;
123
- void this.#validateProvider(provider.id, generation);
124
138
  }
125
139
 
126
140
  if (pending > 0) {
@@ -174,35 +188,110 @@ export class OAuthSelectorComponent extends Container {
174
188
  }
175
189
  }
176
190
 
177
- #getStatusIndicator(providerId: string): string {
178
- const excluded = this.#isExcluded?.(providerId) ? theme.fg("muted", " · excluded from picker") : "";
179
- const state = this.#authState.get(providerId);
180
- if (state === "checking") {
191
+ #getCombinedAccess(provider: LoginOption): ProviderAccessState | undefined {
192
+ const states = this.#providerIds(provider).flatMap(providerId => {
193
+ const access = this.#getAccessState?.(providerId);
194
+ return access ? [access] : [];
195
+ });
196
+ if (states.length === 0) return undefined;
197
+ const rank: Record<ProviderAccessState["status"], number> = {
198
+ checking: 6,
199
+ "reauth-required": 5,
200
+ unreachable: 4,
201
+ connected: 3,
202
+ "configured-unverified": 2,
203
+ unconfigured: 1,
204
+ };
205
+ return [...states].sort((a, b) => rank[b.status] - rank[a.status])[0];
206
+ }
207
+
208
+ #getStatusText(provider: LoginOption): string {
209
+ if (provider.action === "add-provider") return "";
210
+ const providerIds = this.#providerIds(provider);
211
+ const state = providerIds.map(providerId => this.#authState.get(providerId));
212
+ if (state.includes("checking")) {
181
213
  const frameCount = theme.spinnerFrames.length;
182
214
  const spinner = frameCount > 0 ? `${theme.spinnerFrames[this.#spinnerFrame % frameCount]} ` : "";
183
- return theme.fg("warning", ` ${spinner}checking`) + excluded;
184
- }
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;
188
- }
189
- if (access?.status === "unreachable") {
190
- return theme.fg("warning", ` ${theme.status.warning} unreachable`) + excluded;
215
+ return `${spinner}Checking…`;
191
216
  }
192
- if (access?.credentialSource === "keyless") {
193
- return theme.fg("success", ` ${theme.status.success} keyless configured`) + excluded;
217
+ const access = this.#getCombinedAccess(provider);
218
+ if (state.includes("invalid") || access?.status === "reauth-required") {
219
+ return access?.credentialSource === "stored-oauth" ? "Sign in again" : "Credentials need attention";
194
220
  }
195
- if (state === "valid") {
196
- return theme.fg("success", ` ${theme.status.success} connected`) + excluded;
221
+ if (access?.status === "unreachable") return "Can't connect";
222
+ if (access?.status === "connected") {
223
+ return access.credentialSource === "keyless" ? "Available" : "Connected";
197
224
  }
198
- let label = "";
199
- if (access?.status === "configured-unverified") label = theme.fg("warning", " credential detected");
200
- else if (access?.status === "connected") label = theme.fg("success", ` ${theme.status.success} connected`);
201
- else if (!access && this.#authStorage.hasAuth(providerId)) label = theme.fg("warning", " credential detected");
202
- return label + excluded;
225
+ if (state.includes("valid")) return "Connected";
226
+ if (access?.status === "configured-unverified") return "Configured";
227
+ if (providerIds.some(providerId => this.#authStorage.hasAuth(providerId))) return "Configured";
228
+ return "Set up";
229
+ }
230
+
231
+ #getStatusIndicator(provider: LoginOption): string {
232
+ const text = this.#getStatusText(provider);
233
+ if (!text) return "";
234
+ const access = this.#getCombinedAccess(provider);
235
+ const color =
236
+ text === "Connected" || text === "Available"
237
+ ? "success"
238
+ : text === "Sign in again" || text === "Credentials need attention"
239
+ ? "error"
240
+ : text === "Set up"
241
+ ? "muted"
242
+ : "warning";
243
+ const icon =
244
+ access?.status === "connected"
245
+ ? `${theme.status.success} `
246
+ : access?.status === "unreachable" || access?.status === "reauth-required"
247
+ ? `${theme.status.warning} `
248
+ : "";
249
+ return theme.fg(color, ` ${icon}${text}`);
203
250
  }
204
251
  #updateList(): void {
205
252
  this.#listContainer.clear();
253
+ if (this.#detailsProvider) {
254
+ const access = this.#getCombinedAccess(this.#detailsProvider);
255
+ const providerIds = this.#providerIds(this.#detailsProvider);
256
+ const credentialLabels: Record<string, string> = {
257
+ "stored-oauth": "Stored OAuth",
258
+ "stored-api-key": "Stored API key",
259
+ environment: "Environment",
260
+ runtime: "Runtime",
261
+ configuration: "Configuration",
262
+ keyless: "None required",
263
+ };
264
+ this.#listContainer.addChild(new TruncatedText(theme.bold(` Manage ${this.#detailsProvider.name}`), 0, 0));
265
+ this.#listContainer.addChild(
266
+ new TruncatedText(` Status: ${this.#getStatusText(this.#detailsProvider)}`, 0, 0),
267
+ );
268
+ this.#listContainer.addChild(
269
+ new TruncatedText(` Credential: ${credentialLabels[access?.credentialSource ?? ""] ?? "None"}`, 0, 0),
270
+ );
271
+ this.#listContainer.addChild(
272
+ new TruncatedText(
273
+ ` Last verification: ${access?.lastCheckedAt ? new Date(access.lastCheckedAt).toISOString() : "Never"}`,
274
+ 0,
275
+ 0,
276
+ ),
277
+ );
278
+ this.#listContainer.addChild(
279
+ new TruncatedText(
280
+ ` Model visibility: ${providerIds.every(providerId => this.#isExcluded?.(providerId)) ? "Hidden" : "Visible"}`,
281
+ 0,
282
+ 0,
283
+ ),
284
+ );
285
+ if (providerIds.length > 1) {
286
+ this.#listContainer.addChild(new TruncatedText(` Routes: ${providerIds.join(", ")}`, 0, 0));
287
+ }
288
+ if (access?.failureReason) {
289
+ this.#listContainer.addChild(new TruncatedText(` Reason: ${access.failureReason}`, 0, 0));
290
+ }
291
+ this.#listContainer.addChild(new Spacer(1));
292
+ this.#listContainer.addChild(new TruncatedText(theme.fg("muted", " Esc: back"), 0, 0));
293
+ return;
294
+ }
206
295
  const maxVisible = OAuthSelectorComponent.MAX_VISIBLE_PROVIDERS;
207
296
  const startIndex = Math.max(
208
297
  0,
@@ -215,7 +304,7 @@ export class OAuthSelectorComponent extends Container {
215
304
  if (!provider) continue;
216
305
  const isSelected = i === this.#selectedIndex;
217
306
  const isAvailable = provider.available;
218
- const statusIndicator = this.#getStatusIndicator(provider.id);
307
+ const statusIndicator = this.#getStatusIndicator(provider);
219
308
 
220
309
  let line = "";
221
310
  if (isSelected) {
@@ -233,7 +322,14 @@ export class OAuthSelectorComponent extends Container {
233
322
  }
234
323
 
235
324
  // Show "no providers" if empty
236
- if (this.#allProviders.length === 0) {
325
+ if (
326
+ this.#mode === "login" &&
327
+ !this.#catalogMode &&
328
+ this.#allProviders.length === 1 &&
329
+ this.#allProviders[0]?.action === "add-provider"
330
+ ) {
331
+ this.#listContainer.addChild(new TruncatedText(theme.fg("muted", " No providers configured"), 0, 0));
332
+ } else if (this.#allProviders.length === 0) {
237
333
  const message =
238
334
  this.#mode === "login" ? "No OAuth providers available" : "No OAuth providers logged in. Use /login first.";
239
335
  this.#listContainer.addChild(new TruncatedText(theme.fg("muted", ` ${message}`), 0, 0));
@@ -269,10 +365,21 @@ export class OAuthSelectorComponent extends Container {
269
365
  }
270
366
  this.#listContainer.addChild(new Spacer(1));
271
367
  this.#listContainer.addChild(
272
- new TruncatedText(theme.fg("muted", " Type to filter providers · Enter: select · Esc: clear/cancel"), 0, 0),
368
+ new TruncatedText(
369
+ theme.fg("muted", " Type to filter providers · Enter: select · Right: details · Esc: clear/back"),
370
+ 0,
371
+ 0,
372
+ ),
273
373
  );
274
374
  }
275
375
  handleInput(keyData: string): void {
376
+ if (this.#detailsProvider) {
377
+ if (matchesSelectCancel(keyData) || matchesKey(keyData, "left")) {
378
+ this.#detailsProvider = undefined;
379
+ this.#updateList();
380
+ }
381
+ return;
382
+ }
276
383
  // Up arrow
277
384
  if (matchesKey(keyData, "up")) {
278
385
  if (this.#filteredProviders.length > 0) {
@@ -317,11 +424,29 @@ export class OAuthSelectorComponent extends Container {
317
424
  this.#selectedIndex = Math.max(0, this.#filteredProviders.length - 1);
318
425
  this.#statusMessage = undefined;
319
426
  this.#updateList();
427
+ } else if (matchesKey(keyData, "right")) {
428
+ const selectedProvider = this.#filteredProviders[this.#selectedIndex];
429
+ if (selectedProvider && selectedProvider.action !== "add-provider") {
430
+ this.#detailsProvider = selectedProvider;
431
+ this.#updateList();
432
+ }
320
433
  }
321
434
  // Enter
322
435
  else if (matchesKey(keyData, "enter") || matchesKey(keyData, "return") || keyData === "\n") {
323
436
  const selectedProvider = this.#filteredProviders[this.#selectedIndex];
324
- if (selectedProvider?.available) {
437
+ if (selectedProvider?.action === "add-provider") {
438
+ this.stopValidation();
439
+ this.#catalogMode = true;
440
+ this.#allProviders = this.#catalogProviders;
441
+ this.#filteredProviders = this.#allProviders;
442
+ this.#selectedIndex = 0;
443
+ this.#searchInput.setValue("");
444
+ this.#updateList();
445
+ this.#startValidation();
446
+ } else if (selectedProvider?.action === "manage-only") {
447
+ this.#detailsProvider = selectedProvider;
448
+ this.#updateList();
449
+ } else if (selectedProvider?.available) {
325
450
  this.#statusMessage = undefined;
326
451
  this.stopValidation();
327
452
  this.#onSelectCallback(selectedProvider.id);
@@ -337,6 +462,15 @@ export class OAuthSelectorComponent extends Container {
337
462
  this.#filterProviders("");
338
463
  return;
339
464
  }
465
+ if (this.#catalogMode) {
466
+ this.stopValidation();
467
+ this.#catalogMode = false;
468
+ this.#allProviders = this.#managementProviders;
469
+ this.#filteredProviders = this.#allProviders;
470
+ this.#selectedIndex = 0;
471
+ this.#updateList();
472
+ return;
473
+ }
340
474
  this.stopValidation();
341
475
  this.#onCancelCallback();
342
476
  }
@@ -1,6 +1,120 @@
1
1
  import { getOAuthProviders, type OAuthProviderInfo } from "@f5-sales-demo/pi-ai";
2
+ import type { ProviderAccessState, ProviderPickerMetadata } from "../../config/model-registry";
2
3
 
3
- export type LoginOption = OAuthProviderInfo & { kind: "local" | "oauth" };
4
+ export type LoginOption = OAuthProviderInfo & {
5
+ kind: "local" | "oauth";
6
+ /** Provider routes managed by this row. Grouped transports share one row. */
7
+ providerIds?: string[];
8
+ /** Opens the searchable full catalog instead of starting authentication. */
9
+ action?: "add-provider" | "manage-only";
10
+ };
11
+
12
+ export interface ProviderManagementOptions {
13
+ mode: "login" | "logout";
14
+ providerInventory: Iterable<string>;
15
+ configuredProviderIds: Iterable<string>;
16
+ providerAllowlist: readonly string[];
17
+ getAccessState(providerId: string): ProviderAccessState | undefined;
18
+ getPickerMetadata(providerId: string): ProviderPickerMetadata | undefined;
19
+ hasStoredCredential(providerId: string): boolean;
20
+ }
21
+
22
+ export const ADD_PROVIDER_ID = "__add-provider__";
23
+
24
+ function catalogOption(providerId: string, catalog: readonly LoginOption[]): LoginOption {
25
+ return (
26
+ catalog.find(option => option.id === providerId) ?? {
27
+ id: providerId,
28
+ kind: "oauth",
29
+ name: providerId,
30
+ available: true,
31
+ action: "manage-only",
32
+ }
33
+ );
34
+ }
35
+
36
+ /**
37
+ * Build the compact provider-management list used by `/login` and `/logout`.
38
+ * The full built-in catalog is deliberately excluded unless the user chooses
39
+ * `Add provider…`; an empty allowlist is not an allow-everything signal here.
40
+ */
41
+ export function buildProviderManagementOptions(options: ProviderManagementOptions): LoginOption[] {
42
+ const catalog = getLoginOptions();
43
+ const inventory = new Set(options.providerInventory);
44
+ const configured = new Set(options.configuredProviderIds);
45
+ const allowlisted = new Set(options.providerAllowlist);
46
+ const providerIds = new Set<string>([...inventory, ...configured, ...allowlisted]);
47
+ for (const provider of catalog) {
48
+ const access = options.getAccessState(provider.id);
49
+ if (
50
+ options.hasStoredCredential(provider.id) ||
51
+ access?.configured ||
52
+ (access !== undefined && access.status !== "unconfigured")
53
+ ) {
54
+ providerIds.add(provider.id);
55
+ }
56
+ }
57
+
58
+ if (options.mode === "logout") {
59
+ return catalog
60
+ .filter(provider => !provider.loginOnly && options.hasStoredCredential(provider.id))
61
+ .map(provider => ({ ...provider, providerIds: [provider.id] }));
62
+ }
63
+
64
+ const groups = new Map<string, { members: string[]; order: number; metadata?: ProviderPickerMetadata }>();
65
+ for (const providerId of providerIds) {
66
+ const access = options.getAccessState(providerId);
67
+ const relevant =
68
+ inventory.has(providerId) ||
69
+ configured.has(providerId) ||
70
+ allowlisted.has(providerId) ||
71
+ options.hasStoredCredential(providerId) ||
72
+ access?.configured ||
73
+ (access !== undefined && access.status !== "unconfigured");
74
+ if (!relevant) continue;
75
+ const metadata = options.getPickerMetadata(providerId);
76
+ const groupId = metadata?.groupId ?? providerId;
77
+ const order = catalog.findIndex(provider => provider.id === providerId);
78
+ const existing = groups.get(groupId);
79
+ if (existing) {
80
+ existing.members.push(providerId);
81
+ existing.order = Math.min(existing.order, order < 0 ? Number.MAX_SAFE_INTEGER : order);
82
+ existing.metadata ??= metadata;
83
+ } else {
84
+ groups.set(groupId, {
85
+ members: [providerId],
86
+ order: order < 0 ? Number.MAX_SAFE_INTEGER : order,
87
+ metadata,
88
+ });
89
+ }
90
+ }
91
+
92
+ const relevant = [...groups.entries()]
93
+ .sort(([, a], [, b]) => a.order - b.order || a.members[0].localeCompare(b.members[0]))
94
+ .map(([groupId, group]) => {
95
+ const representativeId = group.members.includes(groupId) ? groupId : group.members[0];
96
+ const representative = catalogOption(representativeId, catalog);
97
+ return {
98
+ ...representative,
99
+ id: representativeId,
100
+ name: group.metadata?.groupLabel ?? representative.name,
101
+ providerIds: [...new Set(group.members)],
102
+ };
103
+ });
104
+
105
+ return [
106
+ ...relevant,
107
+ {
108
+ id: ADD_PROVIDER_ID,
109
+ kind: "local",
110
+ name: "Add provider…",
111
+ description: "Search the full provider catalog",
112
+ available: true,
113
+ action: "add-provider",
114
+ providerIds: [],
115
+ },
116
+ ];
117
+ }
4
118
 
5
119
  /**
6
120
  * The login menu is broader than OAuth. Keep local setup routes here instead
@@ -88,6 +88,7 @@ import {
88
88
  type LiteLLMLoginModelChoice,
89
89
  type LoginModelChoice,
90
90
  } from "./login-model";
91
+ import { buildProviderManagementOptions, getLoginOptions } from "./login-options";
91
92
  import { applyModelSelection } from "./model-selection";
92
93
  import {
93
94
  defaultVertexLoginRuntime,
@@ -1705,16 +1706,27 @@ export class SelectorController {
1705
1706
 
1706
1707
  if (mode === "logout") {
1707
1708
  await this.#refreshOAuthProviderAuthState();
1708
- const oauthProviders = getOAuthProviders().filter(provider => !provider.loginOnly);
1709
- const loggedInProviders = oauthProviders.filter(provider =>
1710
- this.ctx.session.modelRegistry.authStorage.hasAuth(provider.id),
1709
+ const loggedInProviders = getLoginOptions().filter(
1710
+ provider => !provider.loginOnly && this.ctx.session.modelRegistry.authStorage.has(provider.id),
1711
1711
  );
1712
1712
  if (loggedInProviders.length === 0) {
1713
- this.ctx.showStatus("No OAuth providers logged in. Use /login first.");
1713
+ this.ctx.showStatus("No stored provider credentials to remove. Use /login first.");
1714
1714
  return;
1715
1715
  }
1716
1716
  }
1717
1717
 
1718
+ const registry = this.ctx.session.modelRegistry;
1719
+ const providerAllowlist = this.ctx.settings?.get?.("modelProviderAllowlist") ?? [];
1720
+ const providers = buildProviderManagementOptions({
1721
+ mode,
1722
+ providerInventory: registry.getProviderInventory(),
1723
+ configuredProviderIds: registry.getConfiguredProviderIds(),
1724
+ providerAllowlist,
1725
+ getAccessState: selectedProviderId => registry.getProviderAccessState(selectedProviderId),
1726
+ getPickerMetadata: selectedProviderId => registry.getProviderPickerMetadata(selectedProviderId),
1727
+ hasStoredCredential: selectedProviderId => registry.authStorage.has(selectedProviderId),
1728
+ });
1729
+
1718
1730
  this.showSelector(
1719
1731
  done => {
1720
1732
  let selector: OAuthSelectorComponent;
@@ -1736,14 +1748,15 @@ export class SelectorController {
1736
1748
  this.ctx.ui.requestRender();
1737
1749
  },
1738
1750
  {
1751
+ providers,
1752
+ catalogProviders: getLoginOptions().map(option => ({ ...option, providerIds: [option.id] })),
1739
1753
  getAccessState: provider => this.ctx.session.modelRegistry.getProviderAccessState?.(provider),
1740
1754
  validateAccess: async selectedProviderId => {
1741
1755
  await this.ctx.session.modelRegistry.refreshProvider(selectedProviderId, "online");
1742
1756
  return this.ctx.session.modelRegistry.getProviderAccessState?.(selectedProviderId);
1743
1757
  },
1744
1758
  isExcluded: provider => {
1745
- const allowlist = this.ctx.settings?.get?.("modelProviderAllowlist") ?? [];
1746
- return allowlist.length > 0 && !allowlist.includes(provider);
1759
+ return providerAllowlist.length > 0 && !providerAllowlist.includes(provider);
1747
1760
  },
1748
1761
  requestRender: () => {
1749
1762
  this.ctx.ui.requestRender();
@@ -30,6 +30,7 @@ import { BUILTIN_SLASH_COMMANDS, loadSlashCommands } from "../extensibility/slas
30
30
  import { resolveLocalUrlToPath } from "../internal-urls";
31
31
  import { renameApprovedPlanFile } from "../plan-mode/approved-plan";
32
32
  import planModeApprovedPrompt from "../prompts/system/plan-mode-approved.md" with { type: "text" };
33
+ import type { ModelResolutionSource } from "../session/active-model";
33
34
  import type { AgentSession, AgentSessionEvent } from "../session/agent-session";
34
35
  import { HistoryStorage } from "../session/history-storage";
35
36
  import type { SessionContext, SessionManager } from "../session/session-manager";
@@ -83,6 +84,13 @@ const EDITOR_MAX_HEIGHT_MAX = 18;
83
84
  const EDITOR_RESERVED_ROWS = 12;
84
85
  const EDITOR_FALLBACK_ROWS = 24;
85
86
 
87
+ export function shouldAutoLaunchProviderLogin(
88
+ needsLogin: boolean,
89
+ modelResolutionSource: ModelResolutionSource,
90
+ ): boolean {
91
+ return needsLogin && modelResolutionSource !== "launch-flag";
92
+ }
93
+
86
94
  /** Options for creating an InteractiveMode instance (for future API use) */
87
95
  export interface InteractiveModeOptions {
88
96
  /** Providers that were migrated during startup */
@@ -358,7 +366,7 @@ export class InteractiveMode implements InteractiveModeContext {
358
366
  this.ui.setFocus(this.editor);
359
367
 
360
368
  // Auto-launch login wizard when model provider is missing or unreachable
361
- if (needsLogin) {
369
+ if (shouldAutoLaunchProviderLogin(needsLogin, this.session.modelResolutionSource)) {
362
370
  queueMicrotask(() => void this.#selectorController.showFirstRunLogin());
363
371
  }
364
372
 
package/src/sdk.ts CHANGED
@@ -36,8 +36,8 @@ import { ModelRegistry } from "./config/model-registry";
36
36
  import {
37
37
  defaultModelPerProvider,
38
38
  formatModelString,
39
- parseModelPattern,
40
39
  parseModelString,
40
+ resolveCliModel,
41
41
  resolveModelRoleValue,
42
42
  } from "./config/model-resolver";
43
43
  import { loadPromptTemplates as loadPromptTemplatesInternal, type PromptTemplate } from "./config/prompt-templates";
@@ -1394,18 +1394,19 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1394
1394
  // Resolve deferred --model pattern now that extension models are registered.
1395
1395
  if (!model && options.modelPattern) {
1396
1396
  await logger.time("awaitExplicitModelDiscovery", () => modelRegistry.awaitBackgroundRefresh());
1397
- const availableModels = modelRegistry.getAll();
1398
1397
  const matchPreferences = {
1399
1398
  usageOrder: settings.getStorage()?.getModelUsageOrder(),
1400
1399
  };
1401
- const { model: resolved } = parseModelPattern(options.modelPattern, availableModels, matchPreferences, {
1400
+ const resolved = resolveCliModel({
1401
+ cliModel: options.modelPattern,
1402
1402
  modelRegistry,
1403
+ preferences: matchPreferences,
1403
1404
  });
1404
- if (resolved) {
1405
- model = resolved;
1405
+ if (resolved.model) {
1406
+ model = resolved.model;
1406
1407
  modelFallbackMessage = undefined;
1407
1408
  } else {
1408
- modelFallbackMessage = `Model "${options.modelPattern}" not found`;
1409
+ modelFallbackMessage = resolved.error ?? `Model "${options.modelPattern}" not found`;
1409
1410
  }
1410
1411
  }
1411
1412