@caupulican/pi-adaptative 0.80.6 → 0.80.7

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.
@@ -18,7 +18,7 @@ import { FooterDataProvider } from "../../core/footer-data-provider.js";
18
18
  import { configureHttpDispatcher, formatHttpIdleTimeoutMs } from "../../core/http-dispatcher.js";
19
19
  import { KeybindingsManager } from "../../core/keybindings.js";
20
20
  import { createCompactionSummaryMessage } from "../../core/messages.js";
21
- import { defaultModelPerProvider, findExactModelReferenceMatch, resolveModelScope } from "../../core/model-resolver.js";
21
+ import { cliProviderAliases, defaultModelPerProvider, findExactModelReferenceMatch, resolveModelScope, } from "../../core/model-resolver.js";
22
22
  import { DefaultPackageManager } from "../../core/package-manager.js";
23
23
  import { BUILT_IN_PROVIDER_DISPLAY_NAMES } from "../../core/provider-display-names.js";
24
24
  import { getPendingReloadBlockers } from "../../core/reload-blockers.js";
@@ -2389,13 +2389,13 @@ export class InteractiveMode {
2389
2389
  this.editor.setText("");
2390
2390
  return;
2391
2391
  }
2392
- if (text === "/login") {
2393
- this.showOAuthSelector("login");
2392
+ if (text === "/login" || text.startsWith("/login ")) {
2393
+ await this.showOAuthSelector("login", text.slice("/login".length).trim() || undefined);
2394
2394
  this.editor.setText("");
2395
2395
  return;
2396
2396
  }
2397
- if (text === "/logout") {
2398
- this.showOAuthSelector("logout");
2397
+ if (text === "/logout" || text.startsWith("/logout ")) {
2398
+ await this.showOAuthSelector("logout", text.slice("/logout".length).trim() || undefined);
2399
2399
  this.editor.setText("");
2400
2400
  return;
2401
2401
  }
@@ -5021,6 +5021,35 @@ export class InteractiveMode {
5021
5021
  }
5022
5022
  return options.sort((a, b) => a.name.localeCompare(b.name));
5023
5023
  }
5024
+ resolveAuthProviderOption(providerReference, providerOptions) {
5025
+ const normalized = providerReference.trim().toLowerCase();
5026
+ if (!normalized)
5027
+ return undefined;
5028
+ const exactMatch = providerOptions.find((provider) => {
5029
+ const id = provider.id.toLowerCase();
5030
+ const name = provider.name.toLowerCase();
5031
+ return id === normalized || name === normalized;
5032
+ });
5033
+ if (exactMatch)
5034
+ return exactMatch;
5035
+ const aliasTarget = cliProviderAliases[normalized] ?? normalized;
5036
+ return providerOptions.find((provider) => {
5037
+ const id = provider.id.toLowerCase();
5038
+ const name = provider.name.toLowerCase();
5039
+ return id === aliasTarget || name === aliasTarget;
5040
+ });
5041
+ }
5042
+ async startProviderLogin(providerOption) {
5043
+ if (providerOption.authType === "oauth") {
5044
+ await this.showLoginDialog(providerOption.id, providerOption.name);
5045
+ }
5046
+ else if (providerOption.id === BEDROCK_PROVIDER_ID) {
5047
+ this.showBedrockSetupDialog(providerOption.id, providerOption.name);
5048
+ }
5049
+ else {
5050
+ await this.showApiKeyLoginDialog(providerOption.id, providerOption.name);
5051
+ }
5052
+ }
5024
5053
  showLoginAuthTypeSelector() {
5025
5054
  const subscriptionLabel = "Use a subscription";
5026
5055
  const apiKeyLabel = "Use an API key";
@@ -5049,15 +5078,7 @@ export class InteractiveMode {
5049
5078
  if (!providerOption) {
5050
5079
  return;
5051
5080
  }
5052
- if (providerOption.authType === "oauth") {
5053
- await this.showLoginDialog(providerOption.id, providerOption.name);
5054
- }
5055
- else if (providerOption.id === BEDROCK_PROVIDER_ID) {
5056
- this.showBedrockSetupDialog(providerOption.id, providerOption.name);
5057
- }
5058
- else {
5059
- await this.showApiKeyLoginDialog(providerOption.id, providerOption.name);
5060
- }
5081
+ await this.startProviderLogin(providerOption);
5061
5082
  }, () => {
5062
5083
  done();
5063
5084
  this.showLoginAuthTypeSelector();
@@ -5065,8 +5086,18 @@ export class InteractiveMode {
5065
5086
  return { component: selector, focus: selector };
5066
5087
  });
5067
5088
  }
5068
- async showOAuthSelector(mode) {
5089
+ async showOAuthSelector(mode, providerReference) {
5069
5090
  if (mode === "login") {
5091
+ if (providerReference) {
5092
+ const providerOptions = this.getLoginProviderOptions();
5093
+ const providerOption = this.resolveAuthProviderOption(providerReference, providerOptions);
5094
+ if (!providerOption) {
5095
+ this.showError(`Unknown login provider "${providerReference}". Use /login to select from available providers.`);
5096
+ return;
5097
+ }
5098
+ await this.startProviderLogin(providerOption);
5099
+ return;
5100
+ }
5070
5101
  this.showLoginAuthTypeSelector();
5071
5102
  return;
5072
5103
  }
@@ -5075,6 +5106,26 @@ export class InteractiveMode {
5075
5106
  this.showStatus("No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.");
5076
5107
  return;
5077
5108
  }
5109
+ if (providerReference) {
5110
+ const providerOption = this.resolveAuthProviderOption(providerReference, providerOptions);
5111
+ if (!providerOption) {
5112
+ this.showError(`No stored credentials found for "${providerReference}". Use /logout to select a saved provider.`);
5113
+ return;
5114
+ }
5115
+ try {
5116
+ this.session.modelRegistry.authStorage.logout(providerOption.id);
5117
+ this.session.modelRegistry.refresh();
5118
+ await this.updateAvailableProviderCount();
5119
+ const message = providerOption.authType === "oauth"
5120
+ ? `Logged out of ${providerOption.name}`
5121
+ : `Removed stored API key for ${providerOption.name}. Environment variables and models.json config are unchanged.`;
5122
+ this.showStatus(message);
5123
+ }
5124
+ catch (error) {
5125
+ this.showError(`Logout failed: ${error instanceof Error ? error.message : String(error)}`);
5126
+ }
5127
+ return;
5128
+ }
5078
5129
  this.showSelector((done) => {
5079
5130
  const selector = new OAuthSelectorComponent(mode, this.session.modelRegistry.authStorage, providerOptions, async (providerId) => {
5080
5131
  done();