opencode-puter-auth 1.0.38 → 1.0.41
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/README.md +194 -0
- package/dist/account-rotation.d.ts +243 -0
- package/dist/account-rotation.d.ts.map +1 -0
- package/dist/account-rotation.js +431 -0
- package/dist/account-rotation.js.map +1 -0
- package/dist/ai-provider/puter-chat-language-model.d.ts +19 -0
- package/dist/ai-provider/puter-chat-language-model.d.ts.map +1 -1
- package/dist/ai-provider/puter-chat-language-model.js +85 -8
- package/dist/ai-provider/puter-chat-language-model.js.map +1 -1
- package/dist/ai-provider/puter-chat-settings.d.ts +18 -0
- package/dist/ai-provider/puter-chat-settings.d.ts.map +1 -1
- package/dist/ai-provider/puter-provider.d.ts.map +1 -1
- package/dist/ai-provider/puter-provider.js +1 -0
- package/dist/ai-provider/puter-provider.js.map +1 -1
- package/dist/auth.d.ts +166 -18
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +167 -20
- package/dist/auth.js.map +1 -1
- package/dist/fallback.d.ts +200 -0
- package/dist/fallback.d.ts.map +1 -0
- package/dist/fallback.js +380 -0
- package/dist/fallback.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/fallback.js
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fallback Manager for opencode-puter-auth
|
|
3
|
+
*
|
|
4
|
+
* Provides automatic model fallback when rate limits are encountered.
|
|
5
|
+
* When a model returns a rate limit error (429/403), the manager:
|
|
6
|
+
* 1. Adds the model to a cooldown list
|
|
7
|
+
* 2. Tries alternative free models in order
|
|
8
|
+
* 3. Returns to the original model after cooldown expires
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const manager = new FallbackManager({
|
|
13
|
+
* fallbackModels: ['openrouter:xiaomi/mimo-v2-flash:free'],
|
|
14
|
+
* cooldownMs: 60000,
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* const result = await manager.executeWithFallback(
|
|
18
|
+
* 'claude-opus-4-5',
|
|
19
|
+
* async (model) => puter.ai.chat(messages, { model }),
|
|
20
|
+
* logger
|
|
21
|
+
* );
|
|
22
|
+
*
|
|
23
|
+
* if (result.wasFallback) {
|
|
24
|
+
* console.log(`Used fallback model: ${result.usedModel}`);
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Default fallback models - FREE OpenRouter models via Puter gateway.
|
|
30
|
+
* Ordered by quality/capability (best first).
|
|
31
|
+
*/
|
|
32
|
+
export const DEFAULT_FALLBACK_MODELS = [
|
|
33
|
+
// Tier 1: Best free models (try these first)
|
|
34
|
+
'openrouter:xiaomi/mimo-v2-flash:free', // 309B MoE, #1 SWE-bench
|
|
35
|
+
'openrouter:deepseek/deepseek-r1-0528:free', // 671B MoE, o1-level reasoning
|
|
36
|
+
'openrouter:mistralai/devstral-2512:free', // 123B, agentic coding
|
|
37
|
+
// Tier 2: Other quality free models
|
|
38
|
+
'openrouter:qwen/qwen3-coder:free', // 480B MoE coding model
|
|
39
|
+
'openrouter:google/gemini-2.0-flash-exp:free', // Google's experimental
|
|
40
|
+
// Tier 3: Fallback free models
|
|
41
|
+
'openrouter:meta-llama/llama-4-maverick:free',
|
|
42
|
+
'openrouter:openai/gpt-oss-120b:free',
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* Default cooldown duration in milliseconds (60 seconds)
|
|
46
|
+
*/
|
|
47
|
+
export const DEFAULT_COOLDOWN_MS = 60000;
|
|
48
|
+
/**
|
|
49
|
+
* Error thrown when all models (primary + fallbacks) have failed
|
|
50
|
+
*/
|
|
51
|
+
export class FallbackExhaustedError extends Error {
|
|
52
|
+
attempts;
|
|
53
|
+
constructor(attempts) {
|
|
54
|
+
const modelsTried = attempts.map(a => a.model).join(', ');
|
|
55
|
+
super(`All models exhausted. Tried: ${modelsTried}`);
|
|
56
|
+
this.name = 'FallbackExhaustedError';
|
|
57
|
+
this.attempts = attempts;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Check if an error indicates a rate limit
|
|
62
|
+
*
|
|
63
|
+
* Detects various rate limit error patterns from different providers:
|
|
64
|
+
* - HTTP 429 (Too Many Requests)
|
|
65
|
+
* - HTTP 403 (Forbidden) - Puter uses this for account limits
|
|
66
|
+
* - Various error message patterns
|
|
67
|
+
*
|
|
68
|
+
* @param error - The error to check
|
|
69
|
+
* @returns true if the error is a rate limit error
|
|
70
|
+
*/
|
|
71
|
+
export function isRateLimitError(error) {
|
|
72
|
+
if (!(error instanceof Error))
|
|
73
|
+
return false;
|
|
74
|
+
const message = error.message.toLowerCase();
|
|
75
|
+
// HTTP status codes that indicate rate limiting
|
|
76
|
+
if (message.includes('(429)') || message.includes('status 429'))
|
|
77
|
+
return true;
|
|
78
|
+
if (message.includes('(403)') || message.includes('status 403'))
|
|
79
|
+
return true;
|
|
80
|
+
// Error message patterns from various providers
|
|
81
|
+
const rateLimitPatterns = [
|
|
82
|
+
'rate limit',
|
|
83
|
+
'rate_limit',
|
|
84
|
+
'ratelimit',
|
|
85
|
+
'too many requests',
|
|
86
|
+
'quota exceeded',
|
|
87
|
+
'quota_exceeded',
|
|
88
|
+
'limit exceeded',
|
|
89
|
+
'request limit',
|
|
90
|
+
'credits exhausted',
|
|
91
|
+
'insufficient credits',
|
|
92
|
+
'usage limit',
|
|
93
|
+
'capacity',
|
|
94
|
+
'overloaded',
|
|
95
|
+
'try again later',
|
|
96
|
+
];
|
|
97
|
+
return rateLimitPatterns.some(pattern => message.includes(pattern));
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Manages automatic model fallback when rate limits are encountered.
|
|
101
|
+
*
|
|
102
|
+
* This is a singleton-style class designed to be shared across all
|
|
103
|
+
* PuterChatLanguageModel instances so cooldown state is consistent.
|
|
104
|
+
*/
|
|
105
|
+
export class FallbackManager {
|
|
106
|
+
cooldownMap = new Map();
|
|
107
|
+
fallbackModels;
|
|
108
|
+
cooldownMs;
|
|
109
|
+
enabled;
|
|
110
|
+
constructor(options = {}) {
|
|
111
|
+
this.fallbackModels = options.fallbackModels ?? DEFAULT_FALLBACK_MODELS;
|
|
112
|
+
this.cooldownMs = options.cooldownMs ?? DEFAULT_COOLDOWN_MS;
|
|
113
|
+
this.enabled = options.enabled ?? true;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Check if a model is currently on cooldown
|
|
117
|
+
*
|
|
118
|
+
* @param model - Model ID to check
|
|
119
|
+
* @returns true if the model is on cooldown
|
|
120
|
+
*/
|
|
121
|
+
isModelOnCooldown(model) {
|
|
122
|
+
const entry = this.cooldownMap.get(model);
|
|
123
|
+
if (!entry)
|
|
124
|
+
return false;
|
|
125
|
+
// Check if cooldown has expired
|
|
126
|
+
if (Date.now() >= entry.expiresAt) {
|
|
127
|
+
this.cooldownMap.delete(model);
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get remaining cooldown time for a model in milliseconds
|
|
134
|
+
*
|
|
135
|
+
* @param model - Model ID to check
|
|
136
|
+
* @returns Remaining cooldown in ms, or 0 if not on cooldown
|
|
137
|
+
*/
|
|
138
|
+
getCooldownRemaining(model) {
|
|
139
|
+
const entry = this.cooldownMap.get(model);
|
|
140
|
+
if (!entry)
|
|
141
|
+
return 0;
|
|
142
|
+
const remaining = entry.expiresAt - Date.now();
|
|
143
|
+
if (remaining <= 0) {
|
|
144
|
+
this.cooldownMap.delete(model);
|
|
145
|
+
return 0;
|
|
146
|
+
}
|
|
147
|
+
return remaining;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Add a model to the cooldown list
|
|
151
|
+
*
|
|
152
|
+
* @param model - Model ID to add to cooldown
|
|
153
|
+
* @param reason - Reason for the cooldown (e.g., error message)
|
|
154
|
+
* @param durationMs - Optional custom cooldown duration
|
|
155
|
+
*/
|
|
156
|
+
addToCooldown(model, reason, durationMs) {
|
|
157
|
+
this.cooldownMap.set(model, {
|
|
158
|
+
expiresAt: Date.now() + (durationMs ?? this.cooldownMs),
|
|
159
|
+
reason,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Remove a model from cooldown (e.g., if it's working again)
|
|
164
|
+
*
|
|
165
|
+
* @param model - Model ID to remove from cooldown
|
|
166
|
+
*/
|
|
167
|
+
removeFromCooldown(model) {
|
|
168
|
+
this.cooldownMap.delete(model);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get all models currently on cooldown
|
|
172
|
+
*
|
|
173
|
+
* @returns Map of model IDs to their cooldown info
|
|
174
|
+
*/
|
|
175
|
+
getCooldownStatus() {
|
|
176
|
+
const status = new Map();
|
|
177
|
+
const now = Date.now();
|
|
178
|
+
for (const [model, entry] of this.cooldownMap) {
|
|
179
|
+
const remaining = entry.expiresAt - now;
|
|
180
|
+
if (remaining > 0) {
|
|
181
|
+
status.set(model, { remainingMs: remaining, reason: entry.reason });
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
// Clean up expired entries
|
|
185
|
+
this.cooldownMap.delete(model);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return status;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Build the queue of models to try, respecting cooldowns
|
|
192
|
+
*
|
|
193
|
+
* @param primaryModel - The primary model requested
|
|
194
|
+
* @returns Ordered array of models to try
|
|
195
|
+
*/
|
|
196
|
+
buildModelQueue(primaryModel) {
|
|
197
|
+
const queue = [];
|
|
198
|
+
// Add primary model first if not on cooldown
|
|
199
|
+
if (!this.isModelOnCooldown(primaryModel)) {
|
|
200
|
+
queue.push(primaryModel);
|
|
201
|
+
}
|
|
202
|
+
// Add fallback models that aren't on cooldown
|
|
203
|
+
for (const model of this.fallbackModels) {
|
|
204
|
+
// Skip if it's the primary (already added) or on cooldown
|
|
205
|
+
if (model === primaryModel)
|
|
206
|
+
continue;
|
|
207
|
+
if (this.isModelOnCooldown(model))
|
|
208
|
+
continue;
|
|
209
|
+
queue.push(model);
|
|
210
|
+
}
|
|
211
|
+
// If primary was on cooldown but we have no fallbacks, add it anyway
|
|
212
|
+
// (better to try and fail than to give up immediately)
|
|
213
|
+
if (queue.length === 0 && this.isModelOnCooldown(primaryModel)) {
|
|
214
|
+
queue.push(primaryModel);
|
|
215
|
+
}
|
|
216
|
+
return queue;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Execute an operation with automatic model fallback
|
|
220
|
+
*
|
|
221
|
+
* Tries the primary model first, and if it fails with a rate limit error,
|
|
222
|
+
* automatically tries fallback models in order.
|
|
223
|
+
*
|
|
224
|
+
* @param primaryModel - The primary model to try first
|
|
225
|
+
* @param operation - Function that performs the API call with the given model
|
|
226
|
+
* @param logger - Optional logger for debugging
|
|
227
|
+
* @returns Result including which model was used and all attempts
|
|
228
|
+
* @throws FallbackExhaustedError if all models fail
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* const result = await manager.executeWithFallback(
|
|
233
|
+
* 'claude-opus-4-5',
|
|
234
|
+
* async (model) => {
|
|
235
|
+
* return await puter.ai.chat(messages, { model });
|
|
236
|
+
* },
|
|
237
|
+
* logger
|
|
238
|
+
* );
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
async executeWithFallback(primaryModel, operation, logger) {
|
|
242
|
+
// If fallback is disabled, just run the operation directly
|
|
243
|
+
if (!this.enabled) {
|
|
244
|
+
const startTime = Date.now();
|
|
245
|
+
try {
|
|
246
|
+
const result = await operation(primaryModel);
|
|
247
|
+
return {
|
|
248
|
+
result,
|
|
249
|
+
usedModel: primaryModel,
|
|
250
|
+
wasFallback: false,
|
|
251
|
+
attempts: [{
|
|
252
|
+
model: primaryModel,
|
|
253
|
+
success: true,
|
|
254
|
+
durationMs: Date.now() - startTime,
|
|
255
|
+
}],
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
throw error;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const modelQueue = this.buildModelQueue(primaryModel);
|
|
263
|
+
const attempts = [];
|
|
264
|
+
logger?.debug('Fallback queue built', {
|
|
265
|
+
primary: primaryModel,
|
|
266
|
+
queue: modelQueue.join(', '),
|
|
267
|
+
cooldowns: this.cooldownMap.size,
|
|
268
|
+
});
|
|
269
|
+
for (const model of modelQueue) {
|
|
270
|
+
const startTime = Date.now();
|
|
271
|
+
const isFallback = model !== primaryModel;
|
|
272
|
+
if (isFallback) {
|
|
273
|
+
logger?.info(`Trying fallback model: ${model}`);
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
const result = await operation(model);
|
|
277
|
+
// Success! If this was a fallback, log it
|
|
278
|
+
if (isFallback) {
|
|
279
|
+
logger?.info(`Fallback model succeeded: ${model}`);
|
|
280
|
+
}
|
|
281
|
+
attempts.push({
|
|
282
|
+
model,
|
|
283
|
+
success: true,
|
|
284
|
+
durationMs: Date.now() - startTime,
|
|
285
|
+
});
|
|
286
|
+
return {
|
|
287
|
+
result,
|
|
288
|
+
usedModel: model,
|
|
289
|
+
wasFallback: isFallback,
|
|
290
|
+
attempts,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
const durationMs = Date.now() - startTime;
|
|
295
|
+
const isRateLimit = isRateLimitError(error);
|
|
296
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
297
|
+
attempts.push({
|
|
298
|
+
model,
|
|
299
|
+
success: false,
|
|
300
|
+
error: errorMessage,
|
|
301
|
+
isRateLimit,
|
|
302
|
+
durationMs,
|
|
303
|
+
});
|
|
304
|
+
if (isRateLimit) {
|
|
305
|
+
// Add to cooldown and continue to next model
|
|
306
|
+
this.addToCooldown(model, errorMessage);
|
|
307
|
+
const cooldownSecs = Math.round(this.cooldownMs / 1000);
|
|
308
|
+
logger?.warn(`Model ${model} rate limited, cooldown ${cooldownSecs}s`);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
// Non-rate-limit error - might be a real problem
|
|
312
|
+
// Still try fallbacks but log it differently
|
|
313
|
+
logger?.warn(`Model ${model} failed: ${errorMessage}`);
|
|
314
|
+
}
|
|
315
|
+
// Continue to next model in queue
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// All models exhausted
|
|
319
|
+
logger?.error('All models exhausted', new FallbackExhaustedError(attempts));
|
|
320
|
+
throw new FallbackExhaustedError(attempts);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Clear all cooldowns (useful for testing or manual reset)
|
|
324
|
+
*/
|
|
325
|
+
clearCooldowns() {
|
|
326
|
+
this.cooldownMap.clear();
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Update configuration
|
|
330
|
+
*/
|
|
331
|
+
configure(options) {
|
|
332
|
+
if (options.fallbackModels !== undefined) {
|
|
333
|
+
this.fallbackModels = options.fallbackModels;
|
|
334
|
+
}
|
|
335
|
+
if (options.cooldownMs !== undefined) {
|
|
336
|
+
this.cooldownMs = options.cooldownMs;
|
|
337
|
+
}
|
|
338
|
+
if (options.enabled !== undefined) {
|
|
339
|
+
this.enabled = options.enabled;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Get current configuration
|
|
344
|
+
*/
|
|
345
|
+
getConfig() {
|
|
346
|
+
return {
|
|
347
|
+
fallbackModels: [...this.fallbackModels],
|
|
348
|
+
cooldownMs: this.cooldownMs,
|
|
349
|
+
enabled: this.enabled,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Global FallbackManager instance shared across all model instances.
|
|
355
|
+
* This ensures cooldown state is consistent across the application.
|
|
356
|
+
*/
|
|
357
|
+
let globalFallbackManager = null;
|
|
358
|
+
/**
|
|
359
|
+
* Get the global FallbackManager instance, creating it if needed
|
|
360
|
+
*
|
|
361
|
+
* @param options - Configuration options (only used when creating)
|
|
362
|
+
* @returns The global FallbackManager instance
|
|
363
|
+
*/
|
|
364
|
+
export function getGlobalFallbackManager(options) {
|
|
365
|
+
if (!globalFallbackManager) {
|
|
366
|
+
globalFallbackManager = new FallbackManager(options);
|
|
367
|
+
}
|
|
368
|
+
else if (options) {
|
|
369
|
+
// Update config if options provided
|
|
370
|
+
globalFallbackManager.configure(options);
|
|
371
|
+
}
|
|
372
|
+
return globalFallbackManager;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Reset the global FallbackManager (useful for testing)
|
|
376
|
+
*/
|
|
377
|
+
export function resetGlobalFallbackManager() {
|
|
378
|
+
globalFallbackManager = null;
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback.js","sourceRoot":"","sources":["../src/fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,6CAA6C;IAC7C,sCAAsC,EAAQ,yBAAyB;IACvE,2CAA2C,EAAG,+BAA+B;IAC7E,yCAAyC,EAAK,uBAAuB;IAErE,oCAAoC;IACpC,kCAAkC,EAAY,wBAAwB;IACtE,6CAA6C,EAAC,wBAAwB;IAEtE,+BAA+B;IAC/B,6CAA6C;IAC7C,qCAAqC;CACtC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AA4CzC;;GAEG;AACH,MAAM,OAAO,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G;AACH,IAAI,qBAAqB,GAA2B,IAAI,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAyB;IAChE,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,qBAAqB,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC;SAAM,IAAI,OAAO,EAAE,CAAC;QACnB,oCAAoC;QACpC,qBAAqB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B;IACxC,qBAAqB,GAAG,IAAI,CAAC;AAC/B,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* and 500+ AI models through Puter.com's "User-Pays" model.
|
|
6
6
|
* Free tier available with undocumented limits.
|
|
7
7
|
*
|
|
8
|
+
* Features automatic model fallback when rate limits are encountered.
|
|
9
|
+
*
|
|
8
10
|
* @author chindris-mihai-alexandru
|
|
9
11
|
* @license MIT
|
|
10
12
|
*/
|
|
@@ -14,5 +16,9 @@ export { createPuter } from './ai-provider/index.js';
|
|
|
14
16
|
export type { PuterProvider, PuterChatSettings, PuterProviderConfig, PuterChatConfig } from './ai-provider/index.js';
|
|
15
17
|
export { createLogger, createLoggerFromConfig, nullLogger, LogLevel } from './logger.js';
|
|
16
18
|
export type { Logger, LoggerOptions } from './logger.js';
|
|
19
|
+
export { FallbackManager, getGlobalFallbackManager, resetGlobalFallbackManager, isRateLimitError, FallbackExhaustedError, DEFAULT_FALLBACK_MODELS, DEFAULT_COOLDOWN_MS, } from './fallback.js';
|
|
20
|
+
export type { FallbackOptions, FallbackResult, FallbackAttempt, } from './fallback.js';
|
|
21
|
+
export { AccountRotationManager, getGlobalAccountRotationManager, resetGlobalAccountRotationManager, AllAccountsOnCooldownError, DEFAULT_ACCOUNT_COOLDOWN_MS, } from './account-rotation.js';
|
|
22
|
+
export type { AccountRotationOptions, AccountRotationResult, AccountStatus, IAuthManager, } from './account-rotation.js';
|
|
17
23
|
export type { PuterConfig, PuterAccount, PuterChatOptions, PuterChatResponse, PuterChatMessage, PuterChatStreamChunk, PuterModelInfo } from './types.js';
|
|
18
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9C,OAAO,EAAE,WAAW,IAAI,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGrH,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzF,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,0BAA0B,EAC1B,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,iCAAiC,EACjC,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,YAAY,GACb,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* and 500+ AI models through Puter.com's "User-Pays" model.
|
|
6
6
|
* Free tier available with undocumented limits.
|
|
7
7
|
*
|
|
8
|
+
* Features automatic model fallback when rate limits are encountered.
|
|
9
|
+
*
|
|
8
10
|
* @author chindris-mihai-alexandru
|
|
9
11
|
* @license MIT
|
|
10
12
|
*/
|
|
@@ -21,4 +23,8 @@ export { createPuter as default } from './ai-provider/index.js';
|
|
|
21
23
|
export { createPuter } from './ai-provider/index.js';
|
|
22
24
|
// Logger exports for debug mode
|
|
23
25
|
export { createLogger, createLoggerFromConfig, nullLogger, LogLevel } from './logger.js';
|
|
26
|
+
// Fallback Manager exports for automatic model fallback
|
|
27
|
+
export { FallbackManager, getGlobalFallbackManager, resetGlobalFallbackManager, isRateLimitError, FallbackExhaustedError, DEFAULT_FALLBACK_MODELS, DEFAULT_COOLDOWN_MS, } from './fallback.js';
|
|
28
|
+
// Account Rotation Manager exports for multi-account support
|
|
29
|
+
export { AccountRotationManager, getGlobalAccountRotationManager, resetGlobalAccountRotationManager, AllAccountsOnCooldownError, DEFAULT_ACCOUNT_COOLDOWN_MS, } from './account-rotation.js';
|
|
24
30
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,kDAAkD;AAClD,2DAA2D;AAC3D,wEAAwE;AACxE,yFAAyF;AACzF,gFAAgF;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,gEAAgE;AAChE,uEAAuE;AACvE,OAAO,EAAE,WAAW,IAAI,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEhE,0BAA0B;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,gCAAgC;AAChC,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGzF,wDAAwD;AACxD,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,0BAA0B,EAC1B,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAOvB,6DAA6D;AAC7D,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,iCAAiC,EACjC,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -36,6 +36,15 @@ export declare const PuterConfigSchema: z.ZodObject<{
|
|
|
36
36
|
retry_delay_ms: z.ZodDefault<z.ZodNumber>;
|
|
37
37
|
stream_buffer_size: z.ZodDefault<z.ZodNumber>;
|
|
38
38
|
cache_ttl_ms: z.ZodDefault<z.ZodNumber>;
|
|
39
|
+
fallback_enabled: z.ZodDefault<z.ZodBoolean>;
|
|
40
|
+
fallback_models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
41
|
+
fallback_cooldown_ms: z.ZodDefault<z.ZodNumber>;
|
|
42
|
+
account_rotation_enabled: z.ZodDefault<z.ZodBoolean>;
|
|
43
|
+
account_rotation_strategy: z.ZodDefault<z.ZodEnum<{
|
|
44
|
+
"round-robin": "round-robin";
|
|
45
|
+
"least-recently-used": "least-recently-used";
|
|
46
|
+
}>>;
|
|
47
|
+
account_rotation_cooldown_ms: z.ZodDefault<z.ZodNumber>;
|
|
39
48
|
}, z.core.$strip>;
|
|
40
49
|
export type PuterConfig = z.infer<typeof PuterConfigSchema>;
|
|
41
50
|
export interface PuterChatMessage {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,kBAAkB;;;;;;;iBAO7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAG9D,eAAO,MAAM,0BAA0B;;;;;;;;;;;iBAIrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAG9E,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,kBAAkB;;;;;;;iBAO7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAG9D,eAAO,MAAM,0BAA0B;;;;;;;;;;;iBAIrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAG9E,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;iBAgC5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAG5D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC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BAAiB,EAAE,MAAM,CAAC;QAC1B,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAGD,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAGD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,eAAO,MAAM,mBAAmB,8HAOtB,CAAC;AAGX,eAAO,MAAM,gBAAgB,mHAWnB,CAAC;AAGX,eAAO,MAAM,mBAAmB,8FAKtB,CAAC;AAGX,MAAM,MAAM,YAAY,GACpB,OAAO,mBAAmB,CAAC,MAAM,CAAC,GAClC,OAAO,gBAAgB,CAAC,MAAM,CAAC,GAC/B,OAAO,mBAAmB,CAAC,MAAM,CAAC,GAClC,MAAM,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -35,6 +35,14 @@ export const PuterConfigSchema = z.object({
|
|
|
35
35
|
stream_buffer_size: z.number().default(1024),
|
|
36
36
|
// Cache Settings
|
|
37
37
|
cache_ttl_ms: z.number().default(300000), // 5 minutes
|
|
38
|
+
// Fallback Settings
|
|
39
|
+
fallback_enabled: z.boolean().default(true),
|
|
40
|
+
fallback_models: z.array(z.string()).optional(), // Uses DEFAULT_FALLBACK_MODELS if not set
|
|
41
|
+
fallback_cooldown_ms: z.number().default(60000), // 1 minute
|
|
42
|
+
// Account Rotation Settings
|
|
43
|
+
account_rotation_enabled: z.boolean().default(true),
|
|
44
|
+
account_rotation_strategy: z.enum(['round-robin', 'least-recently-used']).default('round-robin'),
|
|
45
|
+
account_rotation_cooldown_ms: z.number().default(300000), // 5 minutes
|
|
38
46
|
});
|
|
39
47
|
// Available Claude Models
|
|
40
48
|
export const PUTER_CLAUDE_MODELS = [
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,uBAAuB;AACvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;IACpC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACxC,CAAC,CAAC;AAIH,gCAAgC;AAChC,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9B,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC;IACrC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CA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AAI;IACJ,SAAS;IACT,SAAS;IACT,IAAI;CACI,CAAC;AAEX,0BAA0B;AAC1B,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,gBAAgB;IAChB,kBAAkB;IAClB,uBAAuB;IACvB,kBAAkB;CACV,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-puter-auth",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.41",
|
|
4
4
|
"description": "Puter.com OAuth plugin for OpenCode - Easy access to Claude, GPT, Gemini & 500+ AI models. No API keys needed, credit-based usage.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"puter-auth": "dist/cli.js"
|