@prestyj/core 5.32.2 → 5.33.0

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.d.ts CHANGED
@@ -1,8 +1,24 @@
1
1
  import { ModelInfo } from './model-registry.js';
2
- export { ContextWindowOptions, DEFAULT_MAX_VIDEO_BYTES, MODELS, ModelBilling, clearRuntimeModels, getAllModels, getAuthStorageKey, getAuthStorageKeys, getContextWindow, getDefaultModel, getDefaultThinkingLevel, getMaxThinkingLevel, getModel, getModelsForProvider, getSummaryModel, getToolResultCharLimit, getVideoByteLimit, isPaidModel, registerRuntimeModels, usesOpenAICodexTransport, withoutPaidTier } from './model-registry.js';
2
+ export { ContextWindowOptions, DEFAULT_MAX_VIDEO_BYTES, HIDDEN_PROVIDERS, MODELS, ModelBilling, clearRuntimeModels, getAllModels, getAuthStorageKey, getAuthStorageKeys, getContextWindow, getDefaultModel, getDefaultThinkingLevel, getListedModels, getMaxThinkingLevel, getModel, getModelsForProvider, getProviderCatalog, getSummaryModel, getToolResultCharLimit, getVideoByteLimit, isHiddenProvider, isPaidModel, registerRuntimeModels, setProviderCatalog, usesOpenAICodexTransport, withoutPaidTier } from './model-registry.js';
3
3
  import { ThinkingLevel, Provider } from '@prestyj/ai';
4
+ export { getClaudeCliUserAgent, getClaudeCodeVersion, pendingClaudeCodeVersionRefresh } from '@prestyj/ai';
4
5
  export { AppPaths, getAppPaths } from './paths.js';
5
6
 
7
+ /** @prestyj/ai's OPENROUTER_BASE_URL — where the openrouter transport goes with no override. */
8
+ declare const OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
9
+ interface ParsedOpenRouterCatalog {
10
+ models: ModelInfo[];
11
+ /** Rows dropped because they can't call tools (the agent needs tools) or are malformed. */
12
+ skipped: number;
13
+ }
14
+ /**
15
+ * Turn an OpenRouter-style `/models` body into registry rows. Field mapping is
16
+ * the live schema: tools from `supported_parameters`, image input from
17
+ * `architecture.input_modalities`, the effort ladder from
18
+ * `reasoning.supported_efforts`, output cap from `top_provider`.
19
+ */
20
+ declare function parseOpenRouterCatalog(body: unknown): ParsedOpenRouterCatalog;
21
+
6
22
  declare function getSupportedThinkingLevels(provider: Provider, model: string): readonly ThinkingLevel[];
7
23
  /**
8
24
  * The lowest effort `model` accepts — the first rung of its ladder, never
@@ -26,23 +42,6 @@ declare const PLAN_MODE_THINKING_CAP: ThinkingLevel;
26
42
  * `undefined` (thinking off) and already-low levels. */
27
43
  declare function clampThinkingForPlanMode(level: ThinkingLevel | undefined): ThinkingLevel | undefined;
28
44
 
29
- /**
30
- * Local model discovery — Ollama, LM Studio, llama.cpp (`llama-server`), vLLM,
31
- * and any other OpenAI-compatible server the user points us at.
32
- *
33
- * Everything rides the OpenAI-compatible `/v1` transport (see the `local`
34
- * provider in @prestyj/ai's stream.ts); the only per-server difference is where the
35
- * *capabilities* come from, because `GET /v1/models` reports nothing useful:
36
- *
37
- * - Ollama → `/api/show` + `/api/ps` → capabilities + running context
38
- * - LM Studio → `/api/v1/models` (v0 fallback) → capabilities + loaded context
39
- * - llama.cpp → `GET /props` → `default_generation_settings.n_ctx`
40
- * - vLLM/other → nothing; `max_model_len` sometimes rides the model object.
41
- *
42
- * Probing never throws: an unreachable server is a normal state (the user just
43
- * doesn't have it running), not an error to surface.
44
- */
45
-
46
45
  /** Which capability API a local endpoint speaks, beyond plain `/v1/models`. */
47
46
  type LocalEndpointKind = "ollama" | "lmstudio" | "llamacpp" | "vllm" | "custom";
48
47
  interface LocalEndpoint {
@@ -56,6 +55,8 @@ interface LocalEndpoint {
56
55
  apiKey?: string;
57
56
  /** True for endpoints the user added by hand (removable). */
58
57
  custom?: boolean;
58
+ /** User-pinned context window; wins over whatever the server reports. */
59
+ contextLength?: number;
59
60
  }
60
61
  /** One model as reported (and enriched) by a local server. */
61
62
  interface LocalModel {
@@ -90,7 +91,7 @@ declare const DEFAULT_LOCAL_ENDPOINTS: readonly LocalEndpoint[];
90
91
  * auto-compaction already sailed past, while under-guessing only compacts early.
91
92
  */
92
93
  declare const FALLBACK_CONTEXT_WINDOW = 4096;
93
- /** Placeholder token for endpoints with no key — these servers ignore it. */
94
+ /** Token stored for endpoints with no key; never sent on the wire. */
94
95
  declare const LOCAL_API_KEY_PLACEHOLDER = "local";
95
96
  /**
96
97
  * `local/<endpointId>/<rawModelId>`. The raw id can itself contain slashes
@@ -101,6 +102,11 @@ declare function parseLocalModelId(id: string): {
101
102
  endpointId: string;
102
103
  rawId: string;
103
104
  } | undefined;
105
+ /**
106
+ * The model's own name, for a UI that shows the endpoint separately: the last
107
+ * segment of the raw id, so `minimax/minimax-m2:free` reads `minimax-m2:free`.
108
+ */
109
+ declare function localModelShortName(rawId: string): string;
104
110
  declare function isLocalModelId(id: string): boolean;
105
111
  /** Auth-storage key holding the credential (and baseUrl) for one local endpoint. */
106
112
  declare function localAuthStorageKey(endpointId: string): string;
@@ -116,6 +122,17 @@ interface ProbeOptions {
116
122
  * error toast.
117
123
  */
118
124
  declare function probeEndpoint(endpoint: LocalEndpoint, { timeoutMs, signal }?: ProbeOptions): Promise<LocalEndpointProbe>;
125
+ /**
126
+ * The context Ollama serves `rawId` with, read from `/api/ps`. With `load`, first
127
+ * loads the model the way a chat request would (default options), since an
128
+ * unloaded model's size is only decided at load time: the OpenAI endpoint
129
+ * ignores `num_ctx`, so this is the window the agent will really get.
130
+ */
131
+ declare function ollamaServedContext(endpoint: LocalEndpoint, rawId: string, { load, timeoutMs, signal, }?: {
132
+ load?: boolean;
133
+ timeoutMs?: number;
134
+ signal?: AbortSignal;
135
+ }): Promise<number | undefined>;
119
136
  /** Convert a probed local model into the registry shape the whole app speaks. */
120
137
  declare function toModelInfo(model: LocalModel, endpoint: LocalEndpoint): ModelInfo;
121
138
  interface DiscoveryResult {
@@ -176,42 +193,6 @@ declare function closeLogger(opts?: {
176
193
  */
177
194
  declare function withFileLock<T>(filePath: string, fn: () => Promise<T>): Promise<T>;
178
195
 
179
- /**
180
- * Compare two dotted version strings numerically.
181
- *
182
- * Returns >0 when `a` is newer, <0 when older, 0 when equal. Segment-wise
183
- * numeric comparison matters here: Claude Code is deep into 2.1.x, where a
184
- * lexical compare puts "2.1.9" above "2.1.280" and would happily serve a UA
185
- * that Anthropic rejects.
186
- */
187
- declare function compareClaudeCodeVersions(a: string, b: string): number;
188
- /**
189
- * Resolve the current Claude Code release version for spoofing the claude-cli
190
- * User-Agent on OAuth and inference requests.
191
- *
192
- * A cached value under an hour old is served straight away. An older one is
193
- * still served immediately — the hot path never waits on npm — but triggers a
194
- * background refresh, so a client-version gate on a newly released model costs
195
- * at most one request instead of a full day of lockout. Past 24h the cache is
196
- * refreshed synchronously, and only falls back to the stale value (then the
197
- * bundled constant) if npm cannot be reached at all.
198
- */
199
- declare function getClaudeCodeVersion(): Promise<string>;
200
- /**
201
- * Learn the minimum client version from a provider rejection.
202
- *
203
- * Anthropic gates newly released models on a minimum Claude Code version and
204
- * names it in the error ("version 2.1.280 or newer is required"). That message
205
- * is authoritative — more current than the npm registry can be at launch — so
206
- * we pin it as a floor, persist it, and drop the memoised value. The next
207
- * request builds its User-Agent from the floor and succeeds.
208
- *
209
- * Returns the newly applied floor, or null when the error is unrelated.
210
- */
211
- declare function recordRequiredClaudeCodeVersion(message: string): string | null;
212
- /** Build the User-Agent string Anthropic's OAuth + inference edges expect. */
213
- declare function getClaudeCliUserAgent(): Promise<string>;
214
-
215
196
  interface OAuthCredentials {
216
197
  accessToken: string;
217
198
  refreshToken: string;
@@ -244,6 +225,99 @@ interface OAuthLoginCallbacks {
244
225
  onStatus: (message: string) => void;
245
226
  }
246
227
 
228
+ interface ClaudeCodePlatformAsset {
229
+ url: string;
230
+ /** npm `dist.integrity`: "sha512-<base64>". */
231
+ integrity: string;
232
+ bin: string;
233
+ }
234
+ interface ClaudeCodeManifest {
235
+ sdkVersion: string;
236
+ claudeCodeVersion: string;
237
+ platforms: Record<string, ClaudeCodePlatformAsset>;
238
+ }
239
+ declare const CLAUDE_CODE_MANIFEST: ClaudeCodeManifest;
240
+ /** auth.json key for "signed in with Claude through Claude Code". Holds only the marker. */
241
+ declare const CLAUDE_CODE_AUTH_KEY = "anthropic-claude-code";
242
+ declare const CLAUDE_CODE_AUTH_MARKER: {
243
+ readonly via: "claude-code";
244
+ };
245
+ declare function isClaudeCodeAuthMarker(value: unknown): boolean;
246
+ /** An old EZ Coder Claude sign-in token (`sk-ant-oat…`). It no longer works; the user must sign in again. */
247
+ declare function isLegacyClaudeOAuth(value: unknown): boolean;
248
+ type ClaudeCodeInstallProgress = {
249
+ phase: "download";
250
+ receivedBytes: number;
251
+ totalBytes?: number;
252
+ } | {
253
+ phase: "verify";
254
+ } | {
255
+ phase: "extract";
256
+ };
257
+ interface ClaudeCodeRuntimeOptions {
258
+ /** Defaults to `~/.ezcoder/claude-code`. */
259
+ home?: string;
260
+ manifest?: ClaudeCodeManifest;
261
+ /** Platform key in the manifest; detected from the running process by default. */
262
+ platformKey?: string;
263
+ }
264
+ interface EnsureClaudeCodeOptions extends ClaudeCodeRuntimeOptions {
265
+ onProgress?: (progress: ClaudeCodeInstallProgress) => void;
266
+ signal?: AbortSignal;
267
+ fetch?: typeof fetch;
268
+ }
269
+ interface ClaudeCodeRunOptions extends ClaudeCodeRuntimeOptions {
270
+ /** Executable to run instead of the installed binary (tests). */
271
+ binary?: string;
272
+ /** Arguments placed before the `auth …` arguments (tests run a script via node). */
273
+ binaryArgs?: string[];
274
+ signal?: AbortSignal;
275
+ /** How long sign-in waits for the browser URL before falling back to the paste-code page. */
276
+ browserWaitMs?: number;
277
+ }
278
+ interface ClaudeCodeAuthStatus {
279
+ loggedIn: boolean;
280
+ /** "claude.ai" for a Claude subscription. */
281
+ authMethod?: string;
282
+ email?: string;
283
+ subscriptionType?: string;
284
+ }
285
+ interface PlatformInfo {
286
+ platform: NodeJS.Platform;
287
+ arch: string;
288
+ musl: boolean;
289
+ }
290
+ /** Manifest key for a platform, or null where Claude Code has no build. */
291
+ declare function claudeCodePlatformKey(info?: PlatformInfo): string | null;
292
+ declare function claudeCodeHome(opts?: ClaudeCodeRuntimeOptions): string;
293
+ declare function claudeCodeConfigDir(opts?: ClaudeCodeRuntimeOptions): string;
294
+ /** Where the pinned binary lives once installed (it may not exist yet). */
295
+ declare function claudeCodeBinaryPath(opts?: ClaudeCodeRuntimeOptions): string;
296
+ /** The installed binary for the pinned version, or null when it still needs downloading. */
297
+ declare function resolveClaudeCodeBinary(opts?: ClaudeCodeRuntimeOptions): string | null;
298
+ /**
299
+ * Download, verify and unpack the pinned Claude Code binary if it isn't
300
+ * installed yet. Concurrent callers in this process share one download;
301
+ * other processes race safely because each unpacks into its own staging dir
302
+ * and only one rename wins.
303
+ */
304
+ declare function ensureClaudeCodeBinary(opts?: EnsureClaudeCodeOptions): Promise<string>;
305
+ /** Plain-language status line for an install progress event. */
306
+ declare function formatClaudeCodeInstallProgress(progress: ClaudeCodeInstallProgress): string;
307
+ /** Environment for every Claude Code process EZ Coder starts: our own login, no stray keys. */
308
+ declare function claudeCodeEnv(opts?: ClaudeCodeRuntimeOptions, base?: NodeJS.ProcessEnv): Record<string, string>;
309
+ /** `claude auth status` for EZ Coder's own login. Logged out when the binary is missing. */
310
+ declare function claudeCodeAuthStatus(opts?: ClaudeCodeRunOptions): Promise<ClaudeCodeAuthStatus>;
311
+ declare function logoutClaudeCode(opts?: ClaudeCodeRunOptions): Promise<void>;
312
+ /** The browser sign-in URL with Claude Code's localhost callback instead of the paste-code page. */
313
+ declare function claudeCodeCallbackUrl(manualUrl: string, captured: string): string | null;
314
+ /**
315
+ * Run `claude auth login` for EZ Coder's own Claude login. The browser URL goes
316
+ * to `onOpenUrl`; Claude Code's localhost callback finishes sign-in, and a
317
+ * pasted code (from the fallback page) is accepted too.
318
+ */
319
+ declare function loginClaudeCode(callbacks: OAuthLoginCallbacks, opts?: ClaudeCodeRunOptions): Promise<void>;
320
+
247
321
  /**
248
322
  * Storage key for Kimi Code OAuth credentials. Kept distinct from the
249
323
  * `moonshot` API-key entry so a user can configure BOTH and we always
@@ -340,7 +414,12 @@ declare class AuthStorage {
340
414
  private snapshotIno;
341
415
  /** Per-provider lock to serialize concurrent refresh calls. */
342
416
  private refreshLocks;
343
- constructor(filePath?: string);
417
+ private readonly detectMiniMaxRegion;
418
+ private readonly detectXiaomiCluster;
419
+ constructor(filePath?: string, options?: {
420
+ detectMiniMaxBaseUrl?: (apiKey: string) => Promise<string | undefined>;
421
+ detectXiaomiTokenPlanBaseUrl?: (apiKey: string) => Promise<string | undefined>;
422
+ });
344
423
  /** Path to the on-disk auth file. Useful for status output. */
345
424
  get path(): string;
346
425
  /** List provider keys with stored credentials. */
@@ -361,6 +440,11 @@ declare class AuthStorage {
361
440
  * satisfies it.
362
441
  */
363
442
  hasProviderAuth(provider: string): Promise<boolean>;
443
+ /** True when the user signed in with Claude through Claude Code (marker only, no token). */
444
+ hasClaudeCodeLogin(): Promise<boolean>;
445
+ /** Record a Claude Code sign-in. Claude Code keeps the token; auth.json gets only the marker. */
446
+ setClaudeCodeLogin(): Promise<void>;
447
+ clearClaudeCodeLogin(): Promise<void>;
364
448
  /** Endpoint ids that currently have a `local:<id>` credential stored. */
365
449
  listLocalEndpointIds(): Promise<string[]>;
366
450
  /**
@@ -418,7 +502,22 @@ declare class AuthStorage {
418
502
  private mutateLatest;
419
503
  private reloadLatest;
420
504
  getCredentials(provider: string): Promise<OAuthCredentials | undefined>;
505
+ /**
506
+ * A MiniMax key saved without an endpoint (every key, until its first use)
507
+ * gets the endpoint of the region that issued it, saved so the check runs
508
+ * once. Without this a Mainland China key went to the Global API, got a 401,
509
+ * and was deleted as invalid.
510
+ */
511
+ private withMiniMaxRegion;
421
512
  setCredentials(provider: string, creds: OAuthCredentials): Promise<void>;
513
+ /**
514
+ * After a 401, move a regional key to the cluster that issued it instead of
515
+ * treating it as invalid. Only the Xiaomi Token Plan is regional: every key
516
+ * used to go to Singapore, so Europe and China keys were rejected and deleted.
517
+ * Returns the new base URL, or undefined when no other cluster accepts the key.
518
+ */
519
+ relocateRegionalApiKey(storageKeys: string[]): Promise<string | undefined>;
520
+ clearRejectedApiKey(storageKey: string): Promise<boolean>;
422
521
  clearCredentials(provider: string): Promise<void>;
423
522
  /**
424
523
  * Mark the credential stored under `storageKey` as usage-exhausted until
@@ -468,6 +567,117 @@ declare class NotLoggedInError extends Error {
468
567
  constructor(provider: string);
469
568
  }
470
569
 
570
+ type ClaudeCodeSignInOptions = EnsureClaudeCodeOptions & ClaudeCodeRunOptions;
571
+ /**
572
+ * "Sign in with Claude": download Claude Code if it is missing, run its browser
573
+ * sign-in, confirm it with `claude auth status`, then record the marker.
574
+ */
575
+ declare function signInWithClaudeCode(auth: Pick<AuthStorage, "setClaudeCodeLogin">, callbacks: OAuthLoginCallbacks, opts?: ClaudeCodeSignInOptions): Promise<ClaudeCodeAuthStatus>;
576
+ /** Sign out of Claude Code and drop the marker. The marker goes even if `claude auth logout` fails. */
577
+ declare function signOutOfClaudeCode(auth: Pick<AuthStorage, "clearClaudeCodeLogin">, opts?: ClaudeCodeRunOptions): Promise<void>;
578
+
579
+ type SubscriptionUsageProvider = "anthropic" | "openai" | "moonshot";
580
+ /** Providers whose usage endpoint we call with a token. Claude reports its own (claude-code/usage.ts). */
581
+ type FetchedSubscriptionUsageProvider = Exclude<SubscriptionUsageProvider, "anthropic">;
582
+ interface SubscriptionUsageWindow {
583
+ kind: "current" | "weekly";
584
+ label: string;
585
+ usedPercent: number;
586
+ /** Unix epoch milliseconds. */
587
+ resetsAt?: number;
588
+ }
589
+ interface SubscriptionUsageSnapshot {
590
+ provider: SubscriptionUsageProvider;
591
+ displayName: string;
592
+ windows: SubscriptionUsageWindow[];
593
+ fetchedAt: number;
594
+ }
595
+ declare class SubscriptionUsageError extends Error {
596
+ readonly status?: number | undefined;
597
+ readonly retryAfterMs?: number | undefined;
598
+ constructor(message: string, status?: number | undefined, retryAfterMs?: number | undefined);
599
+ }
600
+ type FetchFn = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
601
+ interface FetchSubscriptionUsageOptions {
602
+ fetchFn?: FetchFn;
603
+ timeoutMs?: number;
604
+ now?: () => number;
605
+ }
606
+ /**
607
+ * Fetch subscription quota windows with an already-resolved OAuth credential.
608
+ * Tokens stay server-side: callers expose only the normalized percentages and
609
+ * reset timestamps to their UI.
610
+ */
611
+ declare function fetchSubscriptionUsage(provider: SubscriptionUsageProvider, credentials: Pick<OAuthCredentials, "accessToken" | "accountId">, options?: FetchSubscriptionUsageOptions): Promise<SubscriptionUsageSnapshot>;
612
+
613
+ /** The parts of the SDK's `rate_limit_event.rate_limit_info` the usage meter reads. */
614
+ interface ClaudeCodeRateLimitInfo {
615
+ rateLimitType?: string;
616
+ /** Fraction of the window used, 0–1. */
617
+ utilization?: number;
618
+ /** Unix epoch seconds. */
619
+ resetsAt?: number;
620
+ /** Not in the SDK types yet; carries every window the response reported. */
621
+ unifiedWindows?: Record<string, {
622
+ utilization?: number;
623
+ resetsAt?: number;
624
+ } | undefined>;
625
+ }
626
+ /**
627
+ * Fold one SDK rate-limit report into the last snapshot. A report can carry a
628
+ * single window, so windows it doesn't mention keep their previous values.
629
+ */
630
+ declare function mergeClaudeCodeRateLimit(info: ClaudeCodeRateLimitInfo, previous: SubscriptionUsageSnapshot | null, now?: number): SubscriptionUsageSnapshot;
631
+ /**
632
+ * The latest Claude subscription usage Claude Code reported, from any GG
633
+ * process on this machine. Windows whose reset time has passed are dropped:
634
+ * their old percentage no longer holds and the new one isn't known yet.
635
+ */
636
+ declare function readClaudeCodeUsage(opts?: ClaudeCodeRuntimeOptions & {
637
+ now?: number;
638
+ }): Promise<SubscriptionUsageSnapshot | null>;
639
+ /** Save an SDK rate-limit report so the usage meter (app or CLI) can show it. */
640
+ declare function recordClaudeCodeRateLimit(info: ClaudeCodeRateLimitInfo, opts?: ClaudeCodeRuntimeOptions & {
641
+ now?: number;
642
+ }): Promise<void>;
643
+ /** Forget saved usage, e.g. on sign-out, so another account never inherits it. */
644
+ declare function clearClaudeCodeUsage(opts?: ClaudeCodeRuntimeOptions): Promise<void>;
645
+
646
+ /**
647
+ * MiniMax runs two separate platforms, and a key only works on the one that
648
+ * issued it: Global (platform.minimax.io) or Mainland China
649
+ * (platform.minimaxi.com). The user's location doesn't matter. Sending a key to
650
+ * the other region's API is rejected as an invalid key.
651
+ */
652
+ declare const MINIMAX_GLOBAL_BASE_URL = "https://api.minimax.io/anthropic";
653
+ declare const MINIMAX_CN_BASE_URL = "https://api.minimax.cn/anthropic";
654
+ /**
655
+ * The Anthropic-compatible base URL for the region that issued `apiKey`, found
656
+ * by asking both regions about the key. Undefined when neither region gives a
657
+ * clear answer (offline, timeouts) — callers then keep the Global default and
658
+ * may ask again later.
659
+ */
660
+ declare function detectMiniMaxBaseUrl(apiKey: string, options?: {
661
+ fetch?: typeof fetch;
662
+ timeoutMs?: number;
663
+ }): Promise<string | undefined>;
664
+
665
+ /**
666
+ * Xiaomi MiMo Token Plan runs separate clusters, and a `tp-` key only works on
667
+ * the cluster that issued it (shown on the user's Token Plan page). Any other
668
+ * cluster answers 401 "Invalid API Key". Pay-as-you-go (API Credits) keys use
669
+ * the single global host and are unaffected.
670
+ */
671
+ declare const XIAOMI_TOKEN_PLAN_BASE_URLS: readonly ["https://token-plan-sgp.xiaomimimo.com/v1", "https://token-plan-ams.xiaomimimo.com/v1", "https://token-plan-cn.xiaomimimo.com/v1"];
672
+ /**
673
+ * The Token Plan base URL whose cluster accepts `apiKey`, found by listing
674
+ * models (free, auth-only) on every cluster. Undefined when none accepts it.
675
+ */
676
+ declare function detectXiaomiTokenPlanBaseUrl(apiKey: string, options?: {
677
+ fetch?: typeof fetch;
678
+ timeoutMs?: number;
679
+ }): Promise<string | undefined>;
680
+
471
681
  type AuthMethod = "oauth" | "apikey";
472
682
  /**
473
683
  * One API-key option for a provider that splits auth across multiple distinct
@@ -525,12 +735,7 @@ interface AuthMethodMeta {
525
735
  /** Prerequisite the user must already have, if any. */
526
736
  requires?: string;
527
737
  }
528
- /**
529
- * Every provider a user can connect, in login-screen order. `description`
530
- * lists that provider's models and feeds both the CLI login screen and the
531
- * app's provider list, so `auth-providers.test.ts` pins each one to the model
532
- * registry — a registry change that isn't reflected here fails the suite.
533
- */
738
+ /** Every provider a user can connect right now, in login-screen order. */
534
739
  declare const AUTH_PROVIDERS: AuthProviderMeta[];
535
740
  declare function getAuthProvider(value: string): AuthProviderMeta | undefined;
536
741
  /**
@@ -549,38 +754,6 @@ declare function describeAuthMethods(provider: string): AuthMethodMeta[];
549
754
  */
550
755
  declare function authPriorityNote(provider: string): string | undefined;
551
756
 
552
- type SubscriptionUsageProvider = "anthropic" | "openai" | "moonshot";
553
- interface SubscriptionUsageWindow {
554
- kind: "current" | "weekly";
555
- label: string;
556
- usedPercent: number;
557
- /** Unix epoch milliseconds. */
558
- resetsAt?: number;
559
- }
560
- interface SubscriptionUsageSnapshot {
561
- provider: SubscriptionUsageProvider;
562
- displayName: string;
563
- windows: SubscriptionUsageWindow[];
564
- fetchedAt: number;
565
- }
566
- declare class SubscriptionUsageError extends Error {
567
- readonly status?: number | undefined;
568
- readonly retryAfterMs?: number | undefined;
569
- constructor(message: string, status?: number | undefined, retryAfterMs?: number | undefined);
570
- }
571
- type FetchFn = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
572
- interface FetchSubscriptionUsageOptions {
573
- fetchFn?: FetchFn;
574
- timeoutMs?: number;
575
- now?: () => number;
576
- }
577
- /**
578
- * Fetch subscription quota windows with an already-resolved OAuth credential.
579
- * Tokens stay server-side: callers expose only the normalized percentages and
580
- * reset timestamps to their UI.
581
- */
582
- declare function fetchSubscriptionUsage(provider: SubscriptionUsageProvider, credentials: Pick<OAuthCredentials, "accessToken" | "accountId">, options?: FetchSubscriptionUsageOptions): Promise<SubscriptionUsageSnapshot>;
583
-
584
757
  declare function generatePKCE(): Promise<{
585
758
  verifier: string;
586
759
  challenge: string;
@@ -879,4 +1052,4 @@ interface AutoUpdater {
879
1052
  }
880
1053
  declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
881
1054
 
882
- 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, GEMINI_API_KEY, GEMINI_API_KEY_BASE_URL, 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 };
1055
+ export { AUTH_PROVIDERS, type ApiKeyVariant, type AuthMethod, type AuthMethodMeta, type AuthProviderMeta, AuthStorage, type AutoUpdateConfig, type AutoUpdater, CLAUDE_CODE_AUTH_KEY, CLAUDE_CODE_AUTH_MARKER, CLAUDE_CODE_MANIFEST, type ClaudeCodeAuthStatus, type ClaudeCodeInstallProgress, type ClaudeCodeManifest, type ClaudeCodePlatformAsset, type ClaudeCodeRateLimitInfo, type ClaudeCodeRunOptions, type ClaudeCodeRuntimeOptions, type ClaudeCodeSignInOptions, DEFAULT_LOCAL_ENDPOINTS, type DiscoverOptions, type DiscoveryResult, type DualAuthProvider, type EnsureClaudeCodeOptions, FALLBACK_CONTEXT_WINDOW, type FetchedSubscriptionUsageProvider, GEMINI_API_KEY, GEMINI_API_KEY_BASE_URL, type InlineButton, LOCAL_API_KEY_PLACEHOLDER, LOCAL_AUTH_KEY_PREFIX, type LocalEndpoint, type LocalEndpointKind, type LocalEndpointProbe, type LocalModel, type LogLevel, MINIMAX_CN_BASE_URL, MINIMAX_GLOBAL_BASE_URL, MOONSHOT_OAUTH_KEY, ModelInfo, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, OPENROUTER_DEFAULT_BASE_URL, PLAN_MODE_THINKING_CAP, type ParsedOpenRouterCatalog, 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, XIAOMI_TOKEN_PLAN_BASE_URLS, authPriorityNote, clampThinkingForPlanMode, claudeCodeAuthStatus, claudeCodeBinaryPath, claudeCodeCallbackUrl, claudeCodeConfigDir, claudeCodeEnv, claudeCodeHome, claudeCodePlatformKey, clearClaudeCodeUsage, clearLocalDiscoveryCache, closeLogger, createAutoUpdater, decodeOggOpus, describeAuthMethods, detectMiniMaxBaseUrl, detectXiaomiTokenPlanBaseUrl, discoverLocalModels, downmixToMono, dualAuthProvider, dualAuthProviderByOAuthKey, endpointRoot, ensureClaudeCodeBinary, fetchSubscriptionUsage, findProbedModel, formatClaudeCodeInstallProgress, formatLocalModelId, generatePKCE, getAuthProvider, getLowestThinkingLevel, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, grokCliBaseUrl, grokCliHeaders, isClaudeCodeAuthMarker, isGrokCliEndpoint, isKimiCodingEndpoint, isLegacyClaudeOAuth, isLocalModelId, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, localAuthStorageKey, localModelShortName, log, loginAnthropic, loginClaudeCode, loginGemini, loginKimi, loginOpenAI, loginXai, logoutClaudeCode, mergeClaudeCodeRateLimit, oauthStorageKey, ollamaServedContext, openLog, parseLocalModelId, parseOpenRouterCatalog, probeEndpoint, providerStorageKeys, readClaudeCodeUsage, readStoredBaseUrlSync, recordClaudeCodeRateLimit, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, refreshXaiToken, registerLogCleanup, resample, resolveClaudeCodeBinary, setProgressCallback, signInWithClaudeCode, signOutOfClaudeCode, toModelInfo, transcribeVoice, withFileLock };