@kenkaiiii/gg-core 5.79.0 → 5.79.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/dist/index.cjs +161 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -1
- package/dist/index.d.ts +82 -1
- package/dist/index.js +157 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -429,6 +429,87 @@ declare class NotLoggedInError extends Error {
|
|
|
429
429
|
constructor(provider: string);
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
+
type AuthMethod = "oauth" | "apikey";
|
|
433
|
+
/**
|
|
434
|
+
* One API-key option for a provider that splits auth across multiple distinct
|
|
435
|
+
* endpoints/credentials (currently only Xiaomi: Token Plan vs. API Credits).
|
|
436
|
+
* Each variant stores under its own auth.json key so a user can hold both at
|
|
437
|
+
* once — the model registry picks which one a given model resolves via
|
|
438
|
+
* `getAuthStorageKeys()`.
|
|
439
|
+
*/
|
|
440
|
+
interface ApiKeyVariant {
|
|
441
|
+
/** Storage key in auth.json (distinct from `value` when multiple variants exist). */
|
|
442
|
+
key: string;
|
|
443
|
+
/** Display label, e.g. "Token Plan" or "API Credits". */
|
|
444
|
+
label: string;
|
|
445
|
+
/** Base URL stored alongside this variant's credential. */
|
|
446
|
+
baseUrl?: string;
|
|
447
|
+
}
|
|
448
|
+
interface AuthProviderMeta {
|
|
449
|
+
/** Stable provider id (matches the gg-ai Provider union, plus storage keys). */
|
|
450
|
+
value: string;
|
|
451
|
+
/** Display name shown in the login list. */
|
|
452
|
+
label: string;
|
|
453
|
+
/** One-line model summary. */
|
|
454
|
+
description: string;
|
|
455
|
+
/** Supported auth methods, in preferred order (oauth first when both). */
|
|
456
|
+
methods: AuthMethod[];
|
|
457
|
+
/** Friendly label for the API key field (e.g. "Z.AI"). */
|
|
458
|
+
apiKeyLabel?: string;
|
|
459
|
+
/** Fixed base URL stored alongside an API key (e.g. Xiaomi's token plan). */
|
|
460
|
+
apiKeyBaseUrl?: string;
|
|
461
|
+
/**
|
|
462
|
+
* When a provider's API-key auth splits across multiple endpoints, the
|
|
463
|
+
* choices to present (in order). The first variant is the default. Absent
|
|
464
|
+
* for every provider with a single API-key credential.
|
|
465
|
+
*/
|
|
466
|
+
apiKeyVariants?: ApiKeyVariant[];
|
|
467
|
+
/**
|
|
468
|
+
* Per-method guidance overrides. Only providers whose methods differ in
|
|
469
|
+
* billing/entitlement (the dual-auth ones) need these; everything else is
|
|
470
|
+
* described generically by {@link describeAuthMethods}.
|
|
471
|
+
*/
|
|
472
|
+
methodDetails?: Partial<Record<AuthMethod, AuthMethodMeta>>;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* What one auth method means for a provider, so both UIs can answer "which do I
|
|
476
|
+
* pick?" without hardcoding provider knowledge in a component.
|
|
477
|
+
*/
|
|
478
|
+
interface AuthMethodMeta {
|
|
479
|
+
method: AuthMethod;
|
|
480
|
+
/** Button/row label, e.g. "Sign in with Grok (SuperGrok / X Premium)". */
|
|
481
|
+
label: string;
|
|
482
|
+
/** What the user spends on this method. */
|
|
483
|
+
billing: string;
|
|
484
|
+
/** When to choose it. */
|
|
485
|
+
when: string;
|
|
486
|
+
/** Prerequisite the user must already have, if any. */
|
|
487
|
+
requires?: string;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Every provider a user can connect, in login-screen order. `description`
|
|
491
|
+
* lists that provider's models and feeds both the CLI login screen and the
|
|
492
|
+
* app's provider list, so `auth-providers.test.ts` pins each one to the model
|
|
493
|
+
* registry — a registry change that isn't reflected here fails the suite.
|
|
494
|
+
*/
|
|
495
|
+
declare const AUTH_PROVIDERS: AuthProviderMeta[];
|
|
496
|
+
declare function getAuthProvider(value: string): AuthProviderMeta | undefined;
|
|
497
|
+
/**
|
|
498
|
+
* Per-method guidance for a provider, in resolution order. Providers with a
|
|
499
|
+
* single method get a generic description; the dual-auth ones (Kimi, Grok) carry
|
|
500
|
+
* explicit `methodDetails` because the choice changes what the user is billed.
|
|
501
|
+
*/
|
|
502
|
+
declare function describeAuthMethods(provider: string): AuthMethodMeta[];
|
|
503
|
+
/**
|
|
504
|
+
* How the runtime picks between two connected methods, phrased for the UI. Only
|
|
505
|
+
* dual-auth providers have a choice to explain; everything else returns
|
|
506
|
+
* undefined so callers can omit the note entirely.
|
|
507
|
+
*
|
|
508
|
+
* Keep this wording in sync with AuthStorage's actual resolution order in
|
|
509
|
+
* gg-core (`DUAL_AUTH_PROVIDERS`) — it is the user-facing description of it.
|
|
510
|
+
*/
|
|
511
|
+
declare function authPriorityNote(provider: string): string | undefined;
|
|
512
|
+
|
|
432
513
|
type SubscriptionUsageProvider = "anthropic" | "openai" | "moonshot";
|
|
433
514
|
interface SubscriptionUsageWindow {
|
|
434
515
|
kind: "current" | "weekly";
|
|
@@ -759,4 +840,4 @@ interface AutoUpdater {
|
|
|
759
840
|
}
|
|
760
841
|
declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
|
|
761
842
|
|
|
762
|
-
export { AuthStorage, type AutoUpdateConfig, type AutoUpdater, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, FALLBACK_CONTEXT_WINDOW, type InlineButton, LOCAL_API_KEY_PLACEHOLDER, LOCAL_AUTH_KEY_PREFIX, type LocalEndpoint, type LocalEndpointKind, type LocalEndpointProbe, type LocalModel, type LogLevel, MOONSHOT_OAUTH_KEY, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, PLAN_MODE_THINKING_CAP, type ProbeOptions, type ProgressCallback, SubscriptionUsageError, type SubscriptionUsageProvider, type SubscriptionUsageSnapshot, type SubscriptionUsageWindow, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XAI_OAUTH_KEY, XIAOMI_CREDITS_KEY, clampThinkingForPlanMode, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, fetchSubscriptionUsage, findProbedModel, formatLocalModelId, generatePKCE, getClaudeCliUserAgent, getClaudeCodeVersion, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isGrokCliEndpoint, isKimiCodingEndpoint, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, log, loginAnthropic, loginGemini, loginKimi, loginOpenAI, loginXai, oauthStorageKey, openLog, parseLocalModelId, probeEndpoint, providerStorageKeys, readStoredBaseUrlSync, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, setProgressCallback, toModelInfo, transcribeVoice, withFileLock };
|
|
843
|
+
export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, FALLBACK_CONTEXT_WINDOW, type InlineButton, LOCAL_API_KEY_PLACEHOLDER, LOCAL_AUTH_KEY_PREFIX, type LocalEndpoint, type LocalEndpointKind, type LocalEndpointProbe, type LocalModel, type LogLevel, MOONSHOT_OAUTH_KEY, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, PLAN_MODE_THINKING_CAP, type ProbeOptions, type ProgressCallback, SubscriptionUsageError, type SubscriptionUsageProvider, type SubscriptionUsageSnapshot, type SubscriptionUsageWindow, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XAI_OAUTH_KEY, XIAOMI_CREDITS_KEY, authPriorityNote, clampThinkingForPlanMode, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, fetchSubscriptionUsage, findProbedModel, formatLocalModelId, generatePKCE, getAuthProvider, getClaudeCliUserAgent, getClaudeCodeVersion, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isGrokCliEndpoint, isKimiCodingEndpoint, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, log, loginAnthropic, loginGemini, loginKimi, loginOpenAI, loginXai, oauthStorageKey, openLog, parseLocalModelId, probeEndpoint, providerStorageKeys, readStoredBaseUrlSync, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, setProgressCallback, toModelInfo, transcribeVoice, withFileLock };
|
package/dist/index.d.ts
CHANGED
|
@@ -429,6 +429,87 @@ declare class NotLoggedInError extends Error {
|
|
|
429
429
|
constructor(provider: string);
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
+
type AuthMethod = "oauth" | "apikey";
|
|
433
|
+
/**
|
|
434
|
+
* One API-key option for a provider that splits auth across multiple distinct
|
|
435
|
+
* endpoints/credentials (currently only Xiaomi: Token Plan vs. API Credits).
|
|
436
|
+
* Each variant stores under its own auth.json key so a user can hold both at
|
|
437
|
+
* once — the model registry picks which one a given model resolves via
|
|
438
|
+
* `getAuthStorageKeys()`.
|
|
439
|
+
*/
|
|
440
|
+
interface ApiKeyVariant {
|
|
441
|
+
/** Storage key in auth.json (distinct from `value` when multiple variants exist). */
|
|
442
|
+
key: string;
|
|
443
|
+
/** Display label, e.g. "Token Plan" or "API Credits". */
|
|
444
|
+
label: string;
|
|
445
|
+
/** Base URL stored alongside this variant's credential. */
|
|
446
|
+
baseUrl?: string;
|
|
447
|
+
}
|
|
448
|
+
interface AuthProviderMeta {
|
|
449
|
+
/** Stable provider id (matches the gg-ai Provider union, plus storage keys). */
|
|
450
|
+
value: string;
|
|
451
|
+
/** Display name shown in the login list. */
|
|
452
|
+
label: string;
|
|
453
|
+
/** One-line model summary. */
|
|
454
|
+
description: string;
|
|
455
|
+
/** Supported auth methods, in preferred order (oauth first when both). */
|
|
456
|
+
methods: AuthMethod[];
|
|
457
|
+
/** Friendly label for the API key field (e.g. "Z.AI"). */
|
|
458
|
+
apiKeyLabel?: string;
|
|
459
|
+
/** Fixed base URL stored alongside an API key (e.g. Xiaomi's token plan). */
|
|
460
|
+
apiKeyBaseUrl?: string;
|
|
461
|
+
/**
|
|
462
|
+
* When a provider's API-key auth splits across multiple endpoints, the
|
|
463
|
+
* choices to present (in order). The first variant is the default. Absent
|
|
464
|
+
* for every provider with a single API-key credential.
|
|
465
|
+
*/
|
|
466
|
+
apiKeyVariants?: ApiKeyVariant[];
|
|
467
|
+
/**
|
|
468
|
+
* Per-method guidance overrides. Only providers whose methods differ in
|
|
469
|
+
* billing/entitlement (the dual-auth ones) need these; everything else is
|
|
470
|
+
* described generically by {@link describeAuthMethods}.
|
|
471
|
+
*/
|
|
472
|
+
methodDetails?: Partial<Record<AuthMethod, AuthMethodMeta>>;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* What one auth method means for a provider, so both UIs can answer "which do I
|
|
476
|
+
* pick?" without hardcoding provider knowledge in a component.
|
|
477
|
+
*/
|
|
478
|
+
interface AuthMethodMeta {
|
|
479
|
+
method: AuthMethod;
|
|
480
|
+
/** Button/row label, e.g. "Sign in with Grok (SuperGrok / X Premium)". */
|
|
481
|
+
label: string;
|
|
482
|
+
/** What the user spends on this method. */
|
|
483
|
+
billing: string;
|
|
484
|
+
/** When to choose it. */
|
|
485
|
+
when: string;
|
|
486
|
+
/** Prerequisite the user must already have, if any. */
|
|
487
|
+
requires?: string;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Every provider a user can connect, in login-screen order. `description`
|
|
491
|
+
* lists that provider's models and feeds both the CLI login screen and the
|
|
492
|
+
* app's provider list, so `auth-providers.test.ts` pins each one to the model
|
|
493
|
+
* registry — a registry change that isn't reflected here fails the suite.
|
|
494
|
+
*/
|
|
495
|
+
declare const AUTH_PROVIDERS: AuthProviderMeta[];
|
|
496
|
+
declare function getAuthProvider(value: string): AuthProviderMeta | undefined;
|
|
497
|
+
/**
|
|
498
|
+
* Per-method guidance for a provider, in resolution order. Providers with a
|
|
499
|
+
* single method get a generic description; the dual-auth ones (Kimi, Grok) carry
|
|
500
|
+
* explicit `methodDetails` because the choice changes what the user is billed.
|
|
501
|
+
*/
|
|
502
|
+
declare function describeAuthMethods(provider: string): AuthMethodMeta[];
|
|
503
|
+
/**
|
|
504
|
+
* How the runtime picks between two connected methods, phrased for the UI. Only
|
|
505
|
+
* dual-auth providers have a choice to explain; everything else returns
|
|
506
|
+
* undefined so callers can omit the note entirely.
|
|
507
|
+
*
|
|
508
|
+
* Keep this wording in sync with AuthStorage's actual resolution order in
|
|
509
|
+
* gg-core (`DUAL_AUTH_PROVIDERS`) — it is the user-facing description of it.
|
|
510
|
+
*/
|
|
511
|
+
declare function authPriorityNote(provider: string): string | undefined;
|
|
512
|
+
|
|
432
513
|
type SubscriptionUsageProvider = "anthropic" | "openai" | "moonshot";
|
|
433
514
|
interface SubscriptionUsageWindow {
|
|
434
515
|
kind: "current" | "weekly";
|
|
@@ -759,4 +840,4 @@ interface AutoUpdater {
|
|
|
759
840
|
}
|
|
760
841
|
declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
|
|
761
842
|
|
|
762
|
-
export { AuthStorage, type AutoUpdateConfig, type AutoUpdater, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, FALLBACK_CONTEXT_WINDOW, type InlineButton, LOCAL_API_KEY_PLACEHOLDER, LOCAL_AUTH_KEY_PREFIX, type LocalEndpoint, type LocalEndpointKind, type LocalEndpointProbe, type LocalModel, type LogLevel, MOONSHOT_OAUTH_KEY, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, PLAN_MODE_THINKING_CAP, type ProbeOptions, type ProgressCallback, SubscriptionUsageError, type SubscriptionUsageProvider, type SubscriptionUsageSnapshot, type SubscriptionUsageWindow, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XAI_OAUTH_KEY, XIAOMI_CREDITS_KEY, clampThinkingForPlanMode, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, fetchSubscriptionUsage, findProbedModel, formatLocalModelId, generatePKCE, getClaudeCliUserAgent, getClaudeCodeVersion, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isGrokCliEndpoint, isKimiCodingEndpoint, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, log, loginAnthropic, loginGemini, loginKimi, loginOpenAI, loginXai, oauthStorageKey, openLog, parseLocalModelId, probeEndpoint, providerStorageKeys, readStoredBaseUrlSync, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, setProgressCallback, toModelInfo, transcribeVoice, withFileLock };
|
|
843
|
+
export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, FALLBACK_CONTEXT_WINDOW, type InlineButton, LOCAL_API_KEY_PLACEHOLDER, LOCAL_AUTH_KEY_PREFIX, type LocalEndpoint, type LocalEndpointKind, type LocalEndpointProbe, type LocalModel, type LogLevel, MOONSHOT_OAUTH_KEY, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, PLAN_MODE_THINKING_CAP, type ProbeOptions, type ProgressCallback, SubscriptionUsageError, type SubscriptionUsageProvider, type SubscriptionUsageSnapshot, type SubscriptionUsageWindow, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XAI_OAUTH_KEY, XIAOMI_CREDITS_KEY, authPriorityNote, clampThinkingForPlanMode, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, fetchSubscriptionUsage, findProbedModel, formatLocalModelId, generatePKCE, getAuthProvider, getClaudeCliUserAgent, getClaudeCodeVersion, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isGrokCliEndpoint, isKimiCodingEndpoint, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, log, loginAnthropic, loginGemini, loginKimi, loginOpenAI, loginXai, oauthStorageKey, openLog, parseLocalModelId, probeEndpoint, providerStorageKeys, readStoredBaseUrlSync, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, setProgressCallback, toModelInfo, transcribeVoice, withFileLock };
|
package/dist/index.js
CHANGED
|
@@ -455,6 +455,159 @@ function findProbedModel(probes, modelId) {
|
|
|
455
455
|
return void 0;
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
+
// src/auth-providers.ts
|
|
459
|
+
var AUTH_PROVIDERS = [
|
|
460
|
+
{
|
|
461
|
+
value: "anthropic",
|
|
462
|
+
label: "Anthropic",
|
|
463
|
+
description: "Claude Fable 5.1, Opus 5.5, Sonnet 5.5, Haiku 5.5",
|
|
464
|
+
methods: ["oauth"]
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
value: "openai",
|
|
468
|
+
label: "OpenAI",
|
|
469
|
+
description: "GPT-6 Astra, GPT-6.1 Sol, GPT-6 Luna",
|
|
470
|
+
methods: ["oauth"]
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
value: "gemini",
|
|
474
|
+
label: "Gemini",
|
|
475
|
+
description: "Gemini 3.8 Flash, 3.5 Flash Lite, 3.7 Flash, 3.1 Flash Lite, 3.5 Flash, 3.1 Pro (Preview)",
|
|
476
|
+
methods: ["oauth"]
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
value: "xai",
|
|
480
|
+
label: "xAI (Grok)",
|
|
481
|
+
description: "Grok 4.7 \xB7 OAuth or API key",
|
|
482
|
+
methods: ["oauth", "apikey"],
|
|
483
|
+
apiKeyLabel: "xAI",
|
|
484
|
+
methodDetails: {
|
|
485
|
+
oauth: {
|
|
486
|
+
method: "oauth",
|
|
487
|
+
label: "Sign in with Grok",
|
|
488
|
+
billing: "Included with SuperGrok or X Premium.",
|
|
489
|
+
when: ""
|
|
490
|
+
},
|
|
491
|
+
apikey: {
|
|
492
|
+
method: "apikey",
|
|
493
|
+
label: "xAI API key",
|
|
494
|
+
billing: "Pay-per-token on console.x.ai credits.",
|
|
495
|
+
when: ""
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
value: "moonshot",
|
|
501
|
+
label: "Moonshot",
|
|
502
|
+
description: "Kimi K3, K2.8 Preview (Kimi sign-in), K2.7 Code, K2.7 Code HighSpeed \xB7 OAuth or API key",
|
|
503
|
+
methods: ["oauth", "apikey"],
|
|
504
|
+
apiKeyLabel: "Moonshot",
|
|
505
|
+
methodDetails: {
|
|
506
|
+
oauth: {
|
|
507
|
+
method: "oauth",
|
|
508
|
+
label: "Sign in with Kimi",
|
|
509
|
+
billing: "Included with a Kimi For Coding plan.",
|
|
510
|
+
when: ""
|
|
511
|
+
},
|
|
512
|
+
apikey: {
|
|
513
|
+
method: "apikey",
|
|
514
|
+
label: "Moonshot API key",
|
|
515
|
+
billing: "Pay-per-token on Moonshot credits.",
|
|
516
|
+
when: ""
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
value: "glm",
|
|
522
|
+
label: "Z.AI (GLM)",
|
|
523
|
+
description: "GLM-5.3, GLM-5.3-Flash",
|
|
524
|
+
methods: ["apikey"],
|
|
525
|
+
apiKeyLabel: "Z.AI"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
value: "minimax",
|
|
529
|
+
label: "MiniMax",
|
|
530
|
+
description: "MiniMax M3",
|
|
531
|
+
methods: ["apikey"],
|
|
532
|
+
apiKeyLabel: "MiniMax"
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
value: "xiaomi",
|
|
536
|
+
label: "Xiaomi (MiMo)",
|
|
537
|
+
description: "MiMo-V2.6-Pro, MiMo-V2.6-Flash, MiMo-V2.6-Pro-UltraSpeed \xB7 Token Plan or API Credits",
|
|
538
|
+
methods: ["apikey"],
|
|
539
|
+
apiKeyLabel: "Xiaomi MiMo",
|
|
540
|
+
apiKeyBaseUrl: "https://token-plan-sgp.xiaomimimo.com/v1",
|
|
541
|
+
apiKeyVariants: [
|
|
542
|
+
{
|
|
543
|
+
key: "xiaomi",
|
|
544
|
+
label: "Token Plan",
|
|
545
|
+
baseUrl: "https://token-plan-sgp.xiaomimimo.com/v1"
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
key: XIAOMI_CREDITS_KEY,
|
|
549
|
+
label: "API Credits (required for UltraSpeed)",
|
|
550
|
+
baseUrl: "https://api.xiaomimimo.com/v1"
|
|
551
|
+
}
|
|
552
|
+
]
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
value: "deepseek",
|
|
556
|
+
label: "DeepSeek",
|
|
557
|
+
description: "DeepSeek V4 Pro, V4.1 Flash",
|
|
558
|
+
methods: ["apikey"],
|
|
559
|
+
apiKeyLabel: "DeepSeek"
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
value: "sakana",
|
|
563
|
+
label: "Sakana (Fugu)",
|
|
564
|
+
description: "Fugu, Fugu Max, Fugu Ultra",
|
|
565
|
+
methods: ["apikey"],
|
|
566
|
+
apiKeyLabel: "Sakana"
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
value: "openrouter",
|
|
570
|
+
label: "OpenRouter",
|
|
571
|
+
description: "Qwen3.8 Max \xB7 multi-provider gateway",
|
|
572
|
+
methods: ["apikey"],
|
|
573
|
+
apiKeyLabel: "OpenRouter"
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
value: "huggingface",
|
|
577
|
+
label: "Hugging Face",
|
|
578
|
+
description: "Kimi K2.7 Code, DeepSeek V4.1 Flash, GPT-OSS 120B",
|
|
579
|
+
methods: ["apikey"],
|
|
580
|
+
apiKeyLabel: "Hugging Face"
|
|
581
|
+
}
|
|
582
|
+
];
|
|
583
|
+
function getAuthProvider(value) {
|
|
584
|
+
return AUTH_PROVIDERS.find((p) => p.value === value);
|
|
585
|
+
}
|
|
586
|
+
function describeAuthMethods(provider) {
|
|
587
|
+
const meta = getAuthProvider(provider);
|
|
588
|
+
if (!meta) return [];
|
|
589
|
+
return meta.methods.map((method) => {
|
|
590
|
+
const override = meta.methodDetails?.[method];
|
|
591
|
+
if (override) return { ...override };
|
|
592
|
+
return method === "oauth" ? {
|
|
593
|
+
method,
|
|
594
|
+
label: `Sign in with ${meta.label}`,
|
|
595
|
+
billing: "Uses your existing plan with this provider.",
|
|
596
|
+
when: ""
|
|
597
|
+
} : {
|
|
598
|
+
method,
|
|
599
|
+
label: `${meta.apiKeyLabel ?? meta.label} API key`,
|
|
600
|
+
billing: "Pay-per-token on this provider's API credits.",
|
|
601
|
+
when: ""
|
|
602
|
+
};
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
function authPriorityNote(provider) {
|
|
606
|
+
const dual = dualAuthProvider(provider);
|
|
607
|
+
if (!dual) return void 0;
|
|
608
|
+
return `Uses ${dual.oauthLabel} first; the ${dual.apiKeyLabel} takes over when it runs out, then switches back.`;
|
|
609
|
+
}
|
|
610
|
+
|
|
458
611
|
// src/provider-usage.ts
|
|
459
612
|
var SubscriptionUsageError = class extends Error {
|
|
460
613
|
constructor(message, status, retryAfterMs2) {
|
|
@@ -1190,6 +1343,7 @@ function createAutoUpdater(config) {
|
|
|
1190
1343
|
};
|
|
1191
1344
|
}
|
|
1192
1345
|
export {
|
|
1346
|
+
AUTH_PROVIDERS,
|
|
1193
1347
|
AuthStorage,
|
|
1194
1348
|
DEFAULT_LOCAL_ENDPOINTS,
|
|
1195
1349
|
DEFAULT_MAX_VIDEO_BYTES,
|
|
@@ -1204,12 +1358,14 @@ export {
|
|
|
1204
1358
|
TelegramBot,
|
|
1205
1359
|
XAI_OAUTH_KEY,
|
|
1206
1360
|
XIAOMI_CREDITS_KEY,
|
|
1361
|
+
authPriorityNote,
|
|
1207
1362
|
clampThinkingForPlanMode,
|
|
1208
1363
|
clearLocalDiscoveryCache,
|
|
1209
1364
|
clearRuntimeModels,
|
|
1210
1365
|
closeLogger,
|
|
1211
1366
|
createAutoUpdater,
|
|
1212
1367
|
decodeOggOpus,
|
|
1368
|
+
describeAuthMethods,
|
|
1213
1369
|
discoverLocalModels,
|
|
1214
1370
|
downmixToMono,
|
|
1215
1371
|
dualAuthProvider,
|
|
@@ -1221,6 +1377,7 @@ export {
|
|
|
1221
1377
|
generatePKCE,
|
|
1222
1378
|
getAllModels,
|
|
1223
1379
|
getAppPaths,
|
|
1380
|
+
getAuthProvider,
|
|
1224
1381
|
getAuthStorageKey,
|
|
1225
1382
|
getAuthStorageKeys,
|
|
1226
1383
|
getClaudeCliUserAgent,
|