@prestyj/core 5.1.0 → 5.2.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.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { ContextWindowOptions, DEFAULT_MAX_VIDEO_BYTES, MODELS, ModelInfo, getContextWindow, getDefaultModel, getMaxThinkingLevel, getModel, getModelsForProvider, getSummaryModel, getVideoByteLimit, usesOpenAICodexTransport } from './model-registry.cjs';
1
+ export { ContextWindowOptions, DEFAULT_MAX_VIDEO_BYTES, MODELS, ModelInfo, getAuthStorageKey, getAuthStorageKeys, getContextWindow, getDefaultModel, getMaxThinkingLevel, getModel, getModelsForProvider, getSummaryModel, getVideoByteLimit, usesOpenAICodexTransport } from './model-registry.cjs';
2
2
  import { Provider, ThinkingLevel } from '@prestyj/ai';
3
3
  export { AppPaths, getAppPaths } from './paths.cjs';
4
4
 
@@ -71,6 +71,15 @@ interface OAuthLoginCallbacks {
71
71
  * prefer OAuth for the logical `moonshot` provider.
72
72
  */
73
73
  declare const MOONSHOT_OAUTH_KEY = "moonshot-oauth";
74
+ /**
75
+ * Storage key for the Xiaomi API Credits credential (`https://api.xiaomimimo.com/v1`).
76
+ * Kept distinct from the `xiaomi` Token Plan entry (`token-plan-sgp.xiaomimimo.com`)
77
+ * so a user can configure BOTH — `mimo-v2.5-pro-ultraspeed` is API Credits-only,
78
+ * while `mimo-v2.5-pro`/`mimo-v2.5` prefer the Token Plan but fall back to API
79
+ * Credits when only that's configured. Which key(s) a model tries, and in what
80
+ * order, is decided per-model via `getAuthStorageKeys()` in model-registry.ts.
81
+ */
82
+ declare const XIAOMI_CREDITS_KEY = "xiaomi-credits";
74
83
  declare class AuthStorage {
75
84
  private data;
76
85
  private filePath;
@@ -84,6 +93,14 @@ declare class AuthStorage {
84
93
  listProviders(): Promise<string[]>;
85
94
  /** True if credentials exist for `provider`. */
86
95
  hasCredentials(provider: string): Promise<boolean>;
96
+ /**
97
+ * First key in `keys` (in order) that has stored credentials, or `undefined`
98
+ * if none do. Mirrors the first-match logic `resolveCredentials({ storageKeys })`
99
+ * uses internally — callers that need to know WHICH credential will actually
100
+ * be used (e.g. to clear the right one after a 401) call this directly
101
+ * instead of re-deriving the same order.
102
+ */
103
+ pickStorageKey(keys: string[]): Promise<string | undefined>;
87
104
  /**
88
105
  * True if the user has any usable auth for the logical provider. For
89
106
  * `moonshot` this is satisfied by either the Kimi OAuth credential or the
@@ -98,6 +115,14 @@ declare class AuthStorage {
98
115
  isStaticApiKey(provider: string): Promise<boolean>;
99
116
  load(): Promise<void>;
100
117
  private ensureLoaded;
118
+ /**
119
+ * Force a re-read from disk, discarding the in-memory cache. Needed when
120
+ * another process mutates the auth file out-of-band — e.g. the desktop app
121
+ * writes API keys natively (Rust → ~/.ezcoder/auth.json) without going through
122
+ * this instance, so a long-lived daemon's cache would otherwise stay stale and
123
+ * never see a newly added provider key.
124
+ */
125
+ reload(): Promise<void>;
101
126
  getCredentials(provider: string): Promise<OAuthCredentials | undefined>;
102
127
  setCredentials(provider: string, creds: OAuthCredentials): Promise<void>;
103
128
  clearCredentials(provider: string): Promise<void>;
@@ -110,6 +135,7 @@ declare class AuthStorage {
110
135
  */
111
136
  resolveCredentials(provider: string, opts?: {
112
137
  forceRefresh?: boolean;
138
+ storageKeys?: string[];
113
139
  }): Promise<OAuthCredentials>;
114
140
  /**
115
141
  * Returns a valid access token, auto-refreshing if expired.
@@ -356,4 +382,4 @@ interface AutoUpdater {
356
382
  }
357
383
  declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
358
384
 
359
- export { AuthStorage, type AutoUpdateConfig, type AutoUpdater, type InlineButton, type LogLevel, MOONSHOT_OAUTH_KEY, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, type ProgressCallback, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, closeLogger, createAutoUpdater, decodeOggOpus, downmixToMono, generatePKCE, getClaudeCliUserAgent, getClaudeCodeVersion, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, isKimiCodingEndpoint, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, log, loginAnthropic, loginGemini, loginKimi, loginOpenAI, openLog, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, registerLogCleanup, resample, setProgressCallback, transcribeVoice, withFileLock };
385
+ export { AuthStorage, type AutoUpdateConfig, type AutoUpdater, type InlineButton, type LogLevel, MOONSHOT_OAUTH_KEY, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, type ProgressCallback, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XIAOMI_CREDITS_KEY, closeLogger, createAutoUpdater, decodeOggOpus, downmixToMono, generatePKCE, getClaudeCliUserAgent, getClaudeCodeVersion, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, isKimiCodingEndpoint, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, log, loginAnthropic, loginGemini, loginKimi, loginOpenAI, openLog, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, registerLogCleanup, resample, setProgressCallback, transcribeVoice, withFileLock };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { ContextWindowOptions, DEFAULT_MAX_VIDEO_BYTES, MODELS, ModelInfo, getContextWindow, getDefaultModel, getMaxThinkingLevel, getModel, getModelsForProvider, getSummaryModel, getVideoByteLimit, usesOpenAICodexTransport } from './model-registry.js';
1
+ export { ContextWindowOptions, DEFAULT_MAX_VIDEO_BYTES, MODELS, ModelInfo, getAuthStorageKey, getAuthStorageKeys, getContextWindow, getDefaultModel, getMaxThinkingLevel, getModel, getModelsForProvider, getSummaryModel, getVideoByteLimit, usesOpenAICodexTransport } from './model-registry.js';
2
2
  import { Provider, ThinkingLevel } from '@prestyj/ai';
3
3
  export { AppPaths, getAppPaths } from './paths.js';
4
4
 
@@ -71,6 +71,15 @@ interface OAuthLoginCallbacks {
71
71
  * prefer OAuth for the logical `moonshot` provider.
72
72
  */
73
73
  declare const MOONSHOT_OAUTH_KEY = "moonshot-oauth";
74
+ /**
75
+ * Storage key for the Xiaomi API Credits credential (`https://api.xiaomimimo.com/v1`).
76
+ * Kept distinct from the `xiaomi` Token Plan entry (`token-plan-sgp.xiaomimimo.com`)
77
+ * so a user can configure BOTH — `mimo-v2.5-pro-ultraspeed` is API Credits-only,
78
+ * while `mimo-v2.5-pro`/`mimo-v2.5` prefer the Token Plan but fall back to API
79
+ * Credits when only that's configured. Which key(s) a model tries, and in what
80
+ * order, is decided per-model via `getAuthStorageKeys()` in model-registry.ts.
81
+ */
82
+ declare const XIAOMI_CREDITS_KEY = "xiaomi-credits";
74
83
  declare class AuthStorage {
75
84
  private data;
76
85
  private filePath;
@@ -84,6 +93,14 @@ declare class AuthStorage {
84
93
  listProviders(): Promise<string[]>;
85
94
  /** True if credentials exist for `provider`. */
86
95
  hasCredentials(provider: string): Promise<boolean>;
96
+ /**
97
+ * First key in `keys` (in order) that has stored credentials, or `undefined`
98
+ * if none do. Mirrors the first-match logic `resolveCredentials({ storageKeys })`
99
+ * uses internally — callers that need to know WHICH credential will actually
100
+ * be used (e.g. to clear the right one after a 401) call this directly
101
+ * instead of re-deriving the same order.
102
+ */
103
+ pickStorageKey(keys: string[]): Promise<string | undefined>;
87
104
  /**
88
105
  * True if the user has any usable auth for the logical provider. For
89
106
  * `moonshot` this is satisfied by either the Kimi OAuth credential or the
@@ -98,6 +115,14 @@ declare class AuthStorage {
98
115
  isStaticApiKey(provider: string): Promise<boolean>;
99
116
  load(): Promise<void>;
100
117
  private ensureLoaded;
118
+ /**
119
+ * Force a re-read from disk, discarding the in-memory cache. Needed when
120
+ * another process mutates the auth file out-of-band — e.g. the desktop app
121
+ * writes API keys natively (Rust → ~/.ezcoder/auth.json) without going through
122
+ * this instance, so a long-lived daemon's cache would otherwise stay stale and
123
+ * never see a newly added provider key.
124
+ */
125
+ reload(): Promise<void>;
101
126
  getCredentials(provider: string): Promise<OAuthCredentials | undefined>;
102
127
  setCredentials(provider: string, creds: OAuthCredentials): Promise<void>;
103
128
  clearCredentials(provider: string): Promise<void>;
@@ -110,6 +135,7 @@ declare class AuthStorage {
110
135
  */
111
136
  resolveCredentials(provider: string, opts?: {
112
137
  forceRefresh?: boolean;
138
+ storageKeys?: string[];
113
139
  }): Promise<OAuthCredentials>;
114
140
  /**
115
141
  * Returns a valid access token, auto-refreshing if expired.
@@ -356,4 +382,4 @@ interface AutoUpdater {
356
382
  }
357
383
  declare function createAutoUpdater(config: AutoUpdateConfig): AutoUpdater;
358
384
 
359
- export { AuthStorage, type AutoUpdateConfig, type AutoUpdater, type InlineButton, type LogLevel, MOONSHOT_OAUTH_KEY, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, type ProgressCallback, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, closeLogger, createAutoUpdater, decodeOggOpus, downmixToMono, generatePKCE, getClaudeCliUserAgent, getClaudeCodeVersion, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, isKimiCodingEndpoint, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, log, loginAnthropic, loginGemini, loginKimi, loginOpenAI, openLog, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, registerLogCleanup, resample, setProgressCallback, transcribeVoice, withFileLock };
385
+ export { AuthStorage, type AutoUpdateConfig, type AutoUpdater, type InlineButton, type LogLevel, MOONSHOT_OAUTH_KEY, NotLoggedInError, type OAuthCredentials, type OAuthLoginCallbacks, type ProgressCallback, TelegramBot, type TelegramConfig, type TelegramMessage, type TelegramUpdate, type TelegramVoiceMessage, XIAOMI_CREDITS_KEY, closeLogger, createAutoUpdater, decodeOggOpus, downmixToMono, generatePKCE, getClaudeCliUserAgent, getClaudeCodeVersion, getNextThinkingLevel, getSessionId, getSupportedThinkingLevels, isKimiCodingEndpoint, isLoggerOpen, isModelLoaded, isThinkingLevelSupported, kimiCodeBaseUrl, kimiCodingHeaders, log, loginAnthropic, loginGemini, loginKimi, loginOpenAI, openLog, refreshAnthropicToken, refreshGeminiToken, refreshKimiToken, refreshOpenAIToken, registerLogCleanup, resample, setProgressCallback, transcribeVoice, withFileLock };