@prestyj/core 5.30.1 → 5.30.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/dist/{chunk-PPHPUAQP.js → chunk-724LOLDH.js} +21 -13
- package/dist/{chunk-PPHPUAQP.js.map → chunk-724LOLDH.js.map} +1 -1
- package/dist/index.cjs +181 -12
- 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 +158 -1
- package/dist/index.js.map +1 -1
- package/dist/model-registry.cjs +20 -12
- package/dist/model-registry.cjs.map +1 -1
- package/dist/model-registry.js +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -458,6 +458,87 @@ declare class NotLoggedInError extends Error {
|
|
|
458
458
|
constructor(provider: string);
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
+
type AuthMethod = "oauth" | "apikey";
|
|
462
|
+
/**
|
|
463
|
+
* One API-key option for a provider that splits auth across multiple distinct
|
|
464
|
+
* endpoints/credentials (currently only Xiaomi: Token Plan vs. API Credits).
|
|
465
|
+
* Each variant stores under its own auth.json key so a user can hold both at
|
|
466
|
+
* once — the model registry picks which one a given model resolves via
|
|
467
|
+
* `getAuthStorageKeys()`.
|
|
468
|
+
*/
|
|
469
|
+
interface ApiKeyVariant {
|
|
470
|
+
/** Storage key in auth.json (distinct from `value` when multiple variants exist). */
|
|
471
|
+
key: string;
|
|
472
|
+
/** Display label, e.g. "Token Plan" or "API Credits". */
|
|
473
|
+
label: string;
|
|
474
|
+
/** Base URL stored alongside this variant's credential. */
|
|
475
|
+
baseUrl?: string;
|
|
476
|
+
}
|
|
477
|
+
interface AuthProviderMeta {
|
|
478
|
+
/** Stable provider id (matches the @prestyj/ai Provider union, plus storage keys). */
|
|
479
|
+
value: string;
|
|
480
|
+
/** Display name shown in the login list. */
|
|
481
|
+
label: string;
|
|
482
|
+
/** One-line model summary. */
|
|
483
|
+
description: string;
|
|
484
|
+
/** Supported auth methods, in preferred order (oauth first when both). */
|
|
485
|
+
methods: AuthMethod[];
|
|
486
|
+
/** Friendly label for the API key field (e.g. "Z.AI"). */
|
|
487
|
+
apiKeyLabel?: string;
|
|
488
|
+
/** Fixed base URL stored alongside an API key (e.g. Xiaomi's token plan). */
|
|
489
|
+
apiKeyBaseUrl?: string;
|
|
490
|
+
/**
|
|
491
|
+
* When a provider's API-key auth splits across multiple endpoints, the
|
|
492
|
+
* choices to present (in order). The first variant is the default. Absent
|
|
493
|
+
* for every provider with a single API-key credential.
|
|
494
|
+
*/
|
|
495
|
+
apiKeyVariants?: ApiKeyVariant[];
|
|
496
|
+
/**
|
|
497
|
+
* Per-method guidance overrides. Only providers whose methods differ in
|
|
498
|
+
* billing/entitlement (the dual-auth ones) need these; everything else is
|
|
499
|
+
* described generically by {@link describeAuthMethods}.
|
|
500
|
+
*/
|
|
501
|
+
methodDetails?: Partial<Record<AuthMethod, AuthMethodMeta>>;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* What one auth method means for a provider, so both UIs can answer "which do I
|
|
505
|
+
* pick?" without hardcoding provider knowledge in a component.
|
|
506
|
+
*/
|
|
507
|
+
interface AuthMethodMeta {
|
|
508
|
+
method: AuthMethod;
|
|
509
|
+
/** Button/row label, e.g. "Sign in with Grok (SuperGrok / X Premium)". */
|
|
510
|
+
label: string;
|
|
511
|
+
/** What the user spends on this method. */
|
|
512
|
+
billing: string;
|
|
513
|
+
/** When to choose it. */
|
|
514
|
+
when: string;
|
|
515
|
+
/** Prerequisite the user must already have, if any. */
|
|
516
|
+
requires?: string;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Every provider a user can connect, in login-screen order. `description`
|
|
520
|
+
* lists that provider's models and feeds both the CLI login screen and the
|
|
521
|
+
* app's provider list, so `auth-providers.test.ts` pins each one to the model
|
|
522
|
+
* registry — a registry change that isn't reflected here fails the suite.
|
|
523
|
+
*/
|
|
524
|
+
declare const AUTH_PROVIDERS: AuthProviderMeta[];
|
|
525
|
+
declare function getAuthProvider(value: string): AuthProviderMeta | undefined;
|
|
526
|
+
/**
|
|
527
|
+
* Per-method guidance for a provider, in resolution order. Providers with a
|
|
528
|
+
* single method get a generic description; the dual-auth ones (Kimi, Grok) carry
|
|
529
|
+
* explicit `methodDetails` because the choice changes what the user is billed.
|
|
530
|
+
*/
|
|
531
|
+
declare function describeAuthMethods(provider: string): AuthMethodMeta[];
|
|
532
|
+
/**
|
|
533
|
+
* How the runtime picks between two connected methods, phrased for the UI. Only
|
|
534
|
+
* dual-auth providers have a choice to explain; everything else returns
|
|
535
|
+
* undefined so callers can omit the note entirely.
|
|
536
|
+
*
|
|
537
|
+
* Keep this wording in sync with AuthStorage's actual resolution order in
|
|
538
|
+
* @prestyj/core (`DUAL_AUTH_PROVIDERS`) — it is the user-facing description of it.
|
|
539
|
+
*/
|
|
540
|
+
declare function authPriorityNote(provider: string): string | undefined;
|
|
541
|
+
|
|
461
542
|
type SubscriptionUsageProvider = "anthropic" | "openai" | "moonshot";
|
|
462
543
|
interface SubscriptionUsageWindow {
|
|
463
544
|
kind: "current" | "weekly";
|
|
@@ -788,4 +869,4 @@ interface AutoUpdater {
|
|
|
788
869
|
}
|
|
789
870
|
declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
|
|
790
871
|
|
|
791
|
-
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, compareClaudeCodeVersions, 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, recordRequiredClaudeCodeVersion, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, setProgressCallback, toModelInfo, transcribeVoice, withFileLock };
|
|
872
|
+
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, compareClaudeCodeVersions, 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, recordRequiredClaudeCodeVersion, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, setProgressCallback, toModelInfo, transcribeVoice, withFileLock };
|
package/dist/index.d.ts
CHANGED
|
@@ -458,6 +458,87 @@ declare class NotLoggedInError extends Error {
|
|
|
458
458
|
constructor(provider: string);
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
+
type AuthMethod = "oauth" | "apikey";
|
|
462
|
+
/**
|
|
463
|
+
* One API-key option for a provider that splits auth across multiple distinct
|
|
464
|
+
* endpoints/credentials (currently only Xiaomi: Token Plan vs. API Credits).
|
|
465
|
+
* Each variant stores under its own auth.json key so a user can hold both at
|
|
466
|
+
* once — the model registry picks which one a given model resolves via
|
|
467
|
+
* `getAuthStorageKeys()`.
|
|
468
|
+
*/
|
|
469
|
+
interface ApiKeyVariant {
|
|
470
|
+
/** Storage key in auth.json (distinct from `value` when multiple variants exist). */
|
|
471
|
+
key: string;
|
|
472
|
+
/** Display label, e.g. "Token Plan" or "API Credits". */
|
|
473
|
+
label: string;
|
|
474
|
+
/** Base URL stored alongside this variant's credential. */
|
|
475
|
+
baseUrl?: string;
|
|
476
|
+
}
|
|
477
|
+
interface AuthProviderMeta {
|
|
478
|
+
/** Stable provider id (matches the @prestyj/ai Provider union, plus storage keys). */
|
|
479
|
+
value: string;
|
|
480
|
+
/** Display name shown in the login list. */
|
|
481
|
+
label: string;
|
|
482
|
+
/** One-line model summary. */
|
|
483
|
+
description: string;
|
|
484
|
+
/** Supported auth methods, in preferred order (oauth first when both). */
|
|
485
|
+
methods: AuthMethod[];
|
|
486
|
+
/** Friendly label for the API key field (e.g. "Z.AI"). */
|
|
487
|
+
apiKeyLabel?: string;
|
|
488
|
+
/** Fixed base URL stored alongside an API key (e.g. Xiaomi's token plan). */
|
|
489
|
+
apiKeyBaseUrl?: string;
|
|
490
|
+
/**
|
|
491
|
+
* When a provider's API-key auth splits across multiple endpoints, the
|
|
492
|
+
* choices to present (in order). The first variant is the default. Absent
|
|
493
|
+
* for every provider with a single API-key credential.
|
|
494
|
+
*/
|
|
495
|
+
apiKeyVariants?: ApiKeyVariant[];
|
|
496
|
+
/**
|
|
497
|
+
* Per-method guidance overrides. Only providers whose methods differ in
|
|
498
|
+
* billing/entitlement (the dual-auth ones) need these; everything else is
|
|
499
|
+
* described generically by {@link describeAuthMethods}.
|
|
500
|
+
*/
|
|
501
|
+
methodDetails?: Partial<Record<AuthMethod, AuthMethodMeta>>;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* What one auth method means for a provider, so both UIs can answer "which do I
|
|
505
|
+
* pick?" without hardcoding provider knowledge in a component.
|
|
506
|
+
*/
|
|
507
|
+
interface AuthMethodMeta {
|
|
508
|
+
method: AuthMethod;
|
|
509
|
+
/** Button/row label, e.g. "Sign in with Grok (SuperGrok / X Premium)". */
|
|
510
|
+
label: string;
|
|
511
|
+
/** What the user spends on this method. */
|
|
512
|
+
billing: string;
|
|
513
|
+
/** When to choose it. */
|
|
514
|
+
when: string;
|
|
515
|
+
/** Prerequisite the user must already have, if any. */
|
|
516
|
+
requires?: string;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Every provider a user can connect, in login-screen order. `description`
|
|
520
|
+
* lists that provider's models and feeds both the CLI login screen and the
|
|
521
|
+
* app's provider list, so `auth-providers.test.ts` pins each one to the model
|
|
522
|
+
* registry — a registry change that isn't reflected here fails the suite.
|
|
523
|
+
*/
|
|
524
|
+
declare const AUTH_PROVIDERS: AuthProviderMeta[];
|
|
525
|
+
declare function getAuthProvider(value: string): AuthProviderMeta | undefined;
|
|
526
|
+
/**
|
|
527
|
+
* Per-method guidance for a provider, in resolution order. Providers with a
|
|
528
|
+
* single method get a generic description; the dual-auth ones (Kimi, Grok) carry
|
|
529
|
+
* explicit `methodDetails` because the choice changes what the user is billed.
|
|
530
|
+
*/
|
|
531
|
+
declare function describeAuthMethods(provider: string): AuthMethodMeta[];
|
|
532
|
+
/**
|
|
533
|
+
* How the runtime picks between two connected methods, phrased for the UI. Only
|
|
534
|
+
* dual-auth providers have a choice to explain; everything else returns
|
|
535
|
+
* undefined so callers can omit the note entirely.
|
|
536
|
+
*
|
|
537
|
+
* Keep this wording in sync with AuthStorage's actual resolution order in
|
|
538
|
+
* @prestyj/core (`DUAL_AUTH_PROVIDERS`) — it is the user-facing description of it.
|
|
539
|
+
*/
|
|
540
|
+
declare function authPriorityNote(provider: string): string | undefined;
|
|
541
|
+
|
|
461
542
|
type SubscriptionUsageProvider = "anthropic" | "openai" | "moonshot";
|
|
462
543
|
interface SubscriptionUsageWindow {
|
|
463
544
|
kind: "current" | "weekly";
|
|
@@ -788,4 +869,4 @@ interface AutoUpdater {
|
|
|
788
869
|
}
|
|
789
870
|
declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
|
|
790
871
|
|
|
791
|
-
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, compareClaudeCodeVersions, 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, recordRequiredClaudeCodeVersion, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, setProgressCallback, toModelInfo, transcribeVoice, withFileLock };
|
|
872
|
+
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, compareClaudeCodeVersions, 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, recordRequiredClaudeCodeVersion, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, setProgressCallback, toModelInfo, transcribeVoice, withFileLock };
|
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
registerRuntimeModels,
|
|
56
56
|
usesOpenAICodexTransport,
|
|
57
57
|
withFileLock
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-724LOLDH.js";
|
|
59
59
|
import {
|
|
60
60
|
getAppPaths
|
|
61
61
|
} from "./chunk-CRU3SSNX.js";
|
|
@@ -457,6 +457,159 @@ function findProbedModel(probes, modelId) {
|
|
|
457
457
|
return void 0;
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
+
// src/auth-providers.ts
|
|
461
|
+
var AUTH_PROVIDERS = [
|
|
462
|
+
{
|
|
463
|
+
value: "anthropic",
|
|
464
|
+
label: "Anthropic",
|
|
465
|
+
description: "Claude Fable 5.1, Opus 5.5, Sonnet 5.5, Haiku 5.5",
|
|
466
|
+
methods: ["oauth"]
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
value: "openai",
|
|
470
|
+
label: "OpenAI",
|
|
471
|
+
description: "GPT-6 Astra, GPT-6.1 Sol, GPT-6 Luna",
|
|
472
|
+
methods: ["oauth"]
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
value: "gemini",
|
|
476
|
+
label: "Gemini",
|
|
477
|
+
description: "Gemini 3.8 Flash, 3.5 Flash Lite, 3.7 Flash, 3.1 Flash Lite, 3.5 Flash, 3.1 Pro (Preview)",
|
|
478
|
+
methods: ["oauth"]
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
value: "xai",
|
|
482
|
+
label: "xAI (Grok)",
|
|
483
|
+
description: "Grok 4.7 \xB7 OAuth or API key",
|
|
484
|
+
methods: ["oauth", "apikey"],
|
|
485
|
+
apiKeyLabel: "xAI",
|
|
486
|
+
methodDetails: {
|
|
487
|
+
oauth: {
|
|
488
|
+
method: "oauth",
|
|
489
|
+
label: "Sign in with Grok",
|
|
490
|
+
billing: "Included with SuperGrok or X Premium.",
|
|
491
|
+
when: ""
|
|
492
|
+
},
|
|
493
|
+
apikey: {
|
|
494
|
+
method: "apikey",
|
|
495
|
+
label: "xAI API key",
|
|
496
|
+
billing: "Pay-per-token on console.x.ai credits.",
|
|
497
|
+
when: ""
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
value: "moonshot",
|
|
503
|
+
label: "Moonshot",
|
|
504
|
+
description: "Kimi K3, K2.8 Preview (Kimi sign-in), K2.7 Code, K2.7 Code HighSpeed \xB7 OAuth or API key",
|
|
505
|
+
methods: ["oauth", "apikey"],
|
|
506
|
+
apiKeyLabel: "Moonshot",
|
|
507
|
+
methodDetails: {
|
|
508
|
+
oauth: {
|
|
509
|
+
method: "oauth",
|
|
510
|
+
label: "Sign in with Kimi",
|
|
511
|
+
billing: "Included with a Kimi For Coding plan.",
|
|
512
|
+
when: ""
|
|
513
|
+
},
|
|
514
|
+
apikey: {
|
|
515
|
+
method: "apikey",
|
|
516
|
+
label: "Moonshot API key",
|
|
517
|
+
billing: "Pay-per-token on Moonshot credits.",
|
|
518
|
+
when: ""
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
value: "glm",
|
|
524
|
+
label: "Z.AI (GLM)",
|
|
525
|
+
description: "GLM-5.3, GLM-5.3-Flash",
|
|
526
|
+
methods: ["apikey"],
|
|
527
|
+
apiKeyLabel: "Z.AI"
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
value: "minimax",
|
|
531
|
+
label: "MiniMax",
|
|
532
|
+
description: "MiniMax M3",
|
|
533
|
+
methods: ["apikey"],
|
|
534
|
+
apiKeyLabel: "MiniMax"
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
value: "xiaomi",
|
|
538
|
+
label: "Xiaomi (MiMo)",
|
|
539
|
+
description: "MiMo-V2.6-Pro, MiMo-V2.6-Flash, MiMo-V2.6-Pro-UltraSpeed \xB7 Token Plan or API Credits",
|
|
540
|
+
methods: ["apikey"],
|
|
541
|
+
apiKeyLabel: "Xiaomi MiMo",
|
|
542
|
+
apiKeyBaseUrl: "https://token-plan-sgp.xiaomimimo.com/v1",
|
|
543
|
+
apiKeyVariants: [
|
|
544
|
+
{
|
|
545
|
+
key: "xiaomi",
|
|
546
|
+
label: "Token Plan",
|
|
547
|
+
baseUrl: "https://token-plan-sgp.xiaomimimo.com/v1"
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
key: XIAOMI_CREDITS_KEY,
|
|
551
|
+
label: "API Credits (required for UltraSpeed)",
|
|
552
|
+
baseUrl: "https://api.xiaomimimo.com/v1"
|
|
553
|
+
}
|
|
554
|
+
]
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
value: "deepseek",
|
|
558
|
+
label: "DeepSeek",
|
|
559
|
+
description: "DeepSeek V4 Pro, V4.1 Flash",
|
|
560
|
+
methods: ["apikey"],
|
|
561
|
+
apiKeyLabel: "DeepSeek"
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
value: "sakana",
|
|
565
|
+
label: "Sakana (Fugu)",
|
|
566
|
+
description: "Fugu, Fugu Max, Fugu Ultra",
|
|
567
|
+
methods: ["apikey"],
|
|
568
|
+
apiKeyLabel: "Sakana"
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
value: "openrouter",
|
|
572
|
+
label: "OpenRouter",
|
|
573
|
+
description: "Qwen3.8 Max \xB7 multi-provider gateway",
|
|
574
|
+
methods: ["apikey"],
|
|
575
|
+
apiKeyLabel: "OpenRouter"
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
value: "huggingface",
|
|
579
|
+
label: "Hugging Face",
|
|
580
|
+
description: "Kimi K2.7 Code, DeepSeek V4.1 Flash, GPT-OSS 120B",
|
|
581
|
+
methods: ["apikey"],
|
|
582
|
+
apiKeyLabel: "Hugging Face"
|
|
583
|
+
}
|
|
584
|
+
];
|
|
585
|
+
function getAuthProvider(value) {
|
|
586
|
+
return AUTH_PROVIDERS.find((p) => p.value === value);
|
|
587
|
+
}
|
|
588
|
+
function describeAuthMethods(provider) {
|
|
589
|
+
const meta = getAuthProvider(provider);
|
|
590
|
+
if (!meta) return [];
|
|
591
|
+
return meta.methods.map((method) => {
|
|
592
|
+
const override = meta.methodDetails?.[method];
|
|
593
|
+
if (override) return { ...override };
|
|
594
|
+
return method === "oauth" ? {
|
|
595
|
+
method,
|
|
596
|
+
label: `Sign in with ${meta.label}`,
|
|
597
|
+
billing: "Uses your existing plan with this provider.",
|
|
598
|
+
when: ""
|
|
599
|
+
} : {
|
|
600
|
+
method,
|
|
601
|
+
label: `${meta.apiKeyLabel ?? meta.label} API key`,
|
|
602
|
+
billing: "Pay-per-token on this provider's API credits.",
|
|
603
|
+
when: ""
|
|
604
|
+
};
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
function authPriorityNote(provider) {
|
|
608
|
+
const dual = dualAuthProvider(provider);
|
|
609
|
+
if (!dual) return void 0;
|
|
610
|
+
return `Uses ${dual.oauthLabel} first; the ${dual.apiKeyLabel} takes over when it runs out, then switches back.`;
|
|
611
|
+
}
|
|
612
|
+
|
|
460
613
|
// src/provider-usage.ts
|
|
461
614
|
var SubscriptionUsageError = class extends Error {
|
|
462
615
|
constructor(message, status, retryAfterMs2) {
|
|
@@ -1192,6 +1345,7 @@ function createAutoUpdater(config) {
|
|
|
1192
1345
|
};
|
|
1193
1346
|
}
|
|
1194
1347
|
export {
|
|
1348
|
+
AUTH_PROVIDERS,
|
|
1195
1349
|
AuthStorage,
|
|
1196
1350
|
DEFAULT_LOCAL_ENDPOINTS,
|
|
1197
1351
|
DEFAULT_MAX_VIDEO_BYTES,
|
|
@@ -1206,6 +1360,7 @@ export {
|
|
|
1206
1360
|
TelegramBot,
|
|
1207
1361
|
XAI_OAUTH_KEY,
|
|
1208
1362
|
XIAOMI_CREDITS_KEY,
|
|
1363
|
+
authPriorityNote,
|
|
1209
1364
|
clampThinkingForPlanMode,
|
|
1210
1365
|
clearLocalDiscoveryCache,
|
|
1211
1366
|
clearRuntimeModels,
|
|
@@ -1213,6 +1368,7 @@ export {
|
|
|
1213
1368
|
compareClaudeCodeVersions,
|
|
1214
1369
|
createAutoUpdater,
|
|
1215
1370
|
decodeOggOpus,
|
|
1371
|
+
describeAuthMethods,
|
|
1216
1372
|
discoverLocalModels,
|
|
1217
1373
|
downmixToMono,
|
|
1218
1374
|
dualAuthProvider,
|
|
@@ -1224,6 +1380,7 @@ export {
|
|
|
1224
1380
|
generatePKCE,
|
|
1225
1381
|
getAllModels,
|
|
1226
1382
|
getAppPaths,
|
|
1383
|
+
getAuthProvider,
|
|
1227
1384
|
getAuthStorageKey,
|
|
1228
1385
|
getAuthStorageKeys,
|
|
1229
1386
|
getClaudeCliUserAgent,
|